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
|
package regtest.multipkg;
/*
This file test usage of methods defined in another package.
We use methods from regtest.basic, which must have been compiled earlier
and should NOT be recompiled together with regtest.multipkg, but only loaded
(this is done by the regtest script).
*/
import regtest.basic;
// test kind extension accross packages
final class KAA implements I2 {}
kf(k@KAA) = k;
void test_import()
{
// tests reading of @null patterns
?String s = null;
println(pToString(s));
println(0);
println(isNull(0));
println(isNull(null));
println("0=" + getZero());
println("1=" + overload1(1) + ", 1=" + overload2(1));
if (clash([true]))
println(clash([1, 2]));
polymorphic1(new regtest.basic.Multi());
polymorphic2(new regtest.basic.Multi());
iter(["A"], String str => println(str));
/* Must fail: map(["A"], fun(String s)=>{println(s);}); */
cov2(null);
// Tests using function with optional parameters from an imported package.
oP(1, b:3, d:3, e:4, skip:true);
oPFunction(1, b:3, d:3, e:4, skip:true);
}
void test_funs(Funs f0)
{
Funs f = new Funs
(f1 : int x => x,
f2 : int x => f0.f1,
f3 : int x => f0.f2,
f4 : int->int x => x(0),
f5 : int->int x => int y => x(y),
f6 : (int x, int y) => x - y,
f7 : null,
f8 : null,
f9 : int x => [x],
f10 : [ f0.f1 ]);
}
|