1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
package regtest.basic;
class A
{
int x;
}
<I> I id(I);
id(x) = x;
void bidon();
bidon()
{
}
long returnLong();
returnLong()
{
long j = 1;
return j=j;
}
(int, int) min_max(int, int);
min_max(x,y) = x < y ? (x, y) : (y, x);
void test_discards();
test_discards()
{
// Presently fails
//id (x); // x is A's field method, of type A->int
A a = new A(x:2);
int i = 0;
boolean b = false;
// test how surabondant value is discarded
if (b)
i = 14;
else
bidon();
if (b)
i++;
else
bidon();
if (b)
--i;
else
bidon();
if (b)
a.x = 17;
else
bidon();
if (b)
a.x--;
else
bidon();
if (b)
++a.x;
else
bidon();
String s1;
String->void test = String s2 => { s1 = s2; };
}
void test_captures();
test_captures()
{
// modification of a variable captured in a lambda
int j=2;
println("" + j);
println(""+(()=>--j)());
println(""+(()=>j++)());
println(""+(()=>{ return j=2*j; })());
}
void main(String[] args)
{
test_discards();
test_captures();
test_tuples();
test_numeric();
test_arrays();
test_comparable();
test_optional();
test_classes();
test_methods();
test_functions();
test_global();
test_native();
test_exceptions();
test_higher_order();
test_localFunctions();
test_null();
test_constructors();
}
|