Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] View of /tests/rtest/tests/int-arith/int-arith.diderot
 [diderot] / tests / rtest / tests / int-arith / int-arith.diderot

# View of /tests/rtest/tests/int-arith/int-arith.diderot

Tue Aug 15 03:04:14 2017 UTC (21 months ago) by jhr
File size: 969 byte(s)
`added regression test`
```#version 2

/* real-arith.diderot
*
* This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
*
* COPYRIGHT (c) 2017 The University of Chicago
*/

/* test various arithmetic operations on reals; these tests are to
* verify that the code generator is producing basically correct
*/

int[] data = { -12, -1, 0, 2, 42 };

initialize {
// +, -, *, /, fmod, min, max
print (data[0], " + ", data[3], " = ", data[0]+data[3], "\n");
print (data[0], " - ", data[3], " = ", data[0]-data[3], "\n");
print (data[0], " * ", data[3], " = ", data[0]*data[3], "\n");
print (data[4], " / ", data[0], " = ", data[4]/data[0], "\n");
print (data[4], " % ", data[0], " = ", data[4]%data[0], "\n");

// test integral operators
foreach (int x in data) {
print ("abs(", x, ") = ", |x|, "\n");
}
}

strand S () {

output int out = 0;

update { stabilize; }

}

create_collection { S() | i in 1..1 }
```