|
@@ -11,13 +11,13 @@ class TestType extends Test {
|
|
|
return s;
|
|
|
#end
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@:macro static public function typedAs(actual:haxe.macro.Expr, expected:haxe.macro.Expr) {
|
|
|
var tExpected = haxe.macro.Context.typeof(expected);
|
|
|
var tActual = haxe.macro.Context.typeof(actual);
|
|
|
return haxe.macro.Context.parse("{Test.count++; eq('" +Std.string(tActual) + "', '" +Std.string(tExpected) + "');}", haxe.macro.Context.currentPos());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@:macro static public function typeError(e:haxe.macro.Expr) {
|
|
|
var result = try {
|
|
|
haxe.macro.Context.typeof(e);
|
|
@@ -25,7 +25,7 @@ class TestType extends Test {
|
|
|
} catch (e:Dynamic) "true";
|
|
|
return { pos: haxe.macro.Context.currentPos(), expr: haxe.macro.Expr.ExprDef.EConst(haxe.macro.Expr.Constant.CIdent(result)) };
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@:macro static public function complete(e:String) : haxe.macro.Expr.ExprOf<String> {
|
|
|
var str = new String(untyped haxe.macro.Context.load("display", 1)(e.__s));
|
|
|
return { expr : EConst(CString(str)), pos : haxe.macro.Context.currentPos() };
|
|
@@ -50,22 +50,22 @@ class TestType extends Test {
|
|
|
var fl = Type.getInstanceFields(unit.MySubClass);
|
|
|
fl.sort(Reflect.compare);
|
|
|
eq( fl.join("|"), fields.join("|") );
|
|
|
-
|
|
|
+
|
|
|
// AS3 generator will create native properties
|
|
|
#if !as3
|
|
|
-
|
|
|
+
|
|
|
// x should not be listed since it's not a variable
|
|
|
var fl = Type.getInstanceFields(VarProps);
|
|
|
var fields = ["get_x","get_y","set_x","set_y","set_z","y","z"];
|
|
|
fl.sort(Reflect.compare);
|
|
|
eq( fl.join("|"), fields.join("|"));
|
|
|
-
|
|
|
+
|
|
|
// same for statics
|
|
|
var fl = Type.getClassFields(VarProps);
|
|
|
var fields = ["SY", "get_SX", "get_SY", "set_SX", "set_SY"];
|
|
|
fl.sort(Reflect.compare);
|
|
|
eq( fl.join("|"), fields.join("|"));
|
|
|
-
|
|
|
+
|
|
|
#end
|
|
|
}
|
|
|
|
|
@@ -85,46 +85,46 @@ class TestType extends Test {
|
|
|
f( Type.enumEq(D(A),D(B)) );
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testPossibleBug() {
|
|
|
var c = Type.getEnumConstructs(MyEnum);
|
|
|
var old = c[0];
|
|
|
c[0] = "modified";
|
|
|
eq( Type.getEnumConstructs(MyEnum)[0], old );
|
|
|
-
|
|
|
+
|
|
|
var i = Type.getInstanceFields(TestType);
|
|
|
var old = i[0];
|
|
|
i[0] = "modified";
|
|
|
eq( Type.getInstanceFields(TestType)[0], old );
|
|
|
-
|
|
|
+
|
|
|
var i = Type.getClassFields(TestType);
|
|
|
var old = i[0];
|
|
|
i[0] = "modified";
|
|
|
eq( Type.getClassFields(TestType)[0], old );
|
|
|
-
|
|
|
+
|
|
|
// we don't check for Type.enumParameters modifications :
|
|
|
// we want it to be as fast as possible even if it references
|
|
|
// the current enum - since it's not cachable
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testAllField() {
|
|
|
eq( Type.allEnums(MyEnum).join("#"), "A#B" );
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testWiderVisibility() {
|
|
|
var c = new MyClass.MyChild1();
|
|
|
eq(12, c.a());
|
|
|
-
|
|
|
+
|
|
|
// TODO: this is also a problem
|
|
|
#if !as3
|
|
|
var mc2 = new MyChild2();
|
|
|
eq(21, mc2.test1(new MyChild1()));
|
|
|
#end
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testUnifyMin() {
|
|
|
// array
|
|
|
-
|
|
|
+
|
|
|
var ti1:Array<I1>;
|
|
|
var tbase:Array<Base>;
|
|
|
var tpbase:Array<PClassBase<Float>>;
|
|
@@ -137,7 +137,7 @@ class TestType extends Test {
|
|
|
#end
|
|
|
var tchild1:Array<Child1>;
|
|
|
var ts:Array<{s:String}>;
|
|
|
-
|
|
|
+
|
|
|
typedAs([new Child1(), new Child2()], tbase);
|
|
|
typedAs([new Child1(), new Child2(), new Base()], tbase);
|
|
|
typedAs([new Child1(), new Child2_1(), new Base()], tbase);
|
|
@@ -147,9 +147,9 @@ class TestType extends Test {
|
|
|
typedAs([new ClassI2(), new Child2()], ti1);
|
|
|
typedAs([new CI1(), new CI2()], tbase);
|
|
|
typedAs([new CII1(), new CII2()], tbase);
|
|
|
-
|
|
|
+
|
|
|
typedAs([new PClass1(), new PClass2(2.0)], tpbase);
|
|
|
-
|
|
|
+
|
|
|
typedAs([null, false], tnullbool);
|
|
|
typedAs([false, null], tnullbool);
|
|
|
typedAs([null, new Base()], tnullbase);
|
|
@@ -162,7 +162,7 @@ class TestType extends Test {
|
|
|
typedAs([new Unrelated(), { s:"foo" } ], ts);
|
|
|
|
|
|
// if
|
|
|
-
|
|
|
+
|
|
|
var tbase:Base;
|
|
|
var ti1:I1;
|
|
|
#if (flash9 || cpp || java || cs)
|
|
@@ -171,7 +171,7 @@ class TestType extends Test {
|
|
|
var tnullbool:Bool;
|
|
|
#end
|
|
|
var ts: { s:String };
|
|
|
-
|
|
|
+
|
|
|
typedAs(if (false) new Child1(); else new Child2(), tbase);
|
|
|
typedAs(
|
|
|
if (false) new Child1();
|
|
@@ -183,26 +183,26 @@ class TestType extends Test {
|
|
|
else new Base(), tbase);
|
|
|
typedAs(if (false) new Child2(); else new Unrelated(), ti1);
|
|
|
typedAs(if (false) new Child2_1(); else new Unrelated(), ti1);
|
|
|
-
|
|
|
+
|
|
|
typedAs(if (false) null; else false, tnullbool);
|
|
|
typedAs(if (false) true; else null, tnullbool);
|
|
|
typedAs(if (false) new Unrelated(); else {s:"foo"}, ts);
|
|
|
typedAs(if (false) { s:"foo" }; else new Unrelated(), ts);
|
|
|
-
|
|
|
+
|
|
|
//switch
|
|
|
-
|
|
|
+
|
|
|
typedAs(switch(false) { case true: new Child1(); case false: new Child2(); }, tbase);
|
|
|
typedAs(switch(1) { case 0: new Child1(); case 1: new Child2_1(); default: new Base(); }, tbase);
|
|
|
typedAs(switch(false) { case true: new Child2(); case false: new Unrelated(); }, ti1);
|
|
|
typedAs(switch(false) { case true: new Child2_1(); case false: new Unrelated(); }, ti1);
|
|
|
-
|
|
|
+
|
|
|
typedAs(switch(false) { case true: null; default: false; }, tnullbool);
|
|
|
typedAs(switch(false) { case true: true; default: null; }, tnullbool);
|
|
|
typedAs(switch(false) { case true: new Unrelated(); default: {s:"foo"}; }, ts);
|
|
|
typedAs(switch(false) { case true: { s:"foo" }; default: new Unrelated(); }, ts);
|
|
|
-
|
|
|
+
|
|
|
typedAs([ { x : new Child1() }, { x : new Child2() } ], [{ x: new Base() }]);
|
|
|
-
|
|
|
+
|
|
|
#if flash9
|
|
|
typedAs(function() { return 0; var v:UInt = 0; return v; } (), 1);
|
|
|
#end
|
|
@@ -221,85 +221,85 @@ class TestType extends Test {
|
|
|
var tstring = function(b:String) return 0;
|
|
|
|
|
|
// all missing
|
|
|
-
|
|
|
+
|
|
|
typedAs(callback(func), func);
|
|
|
typedAs(callback(func, _), func);
|
|
|
typedAs(callback(func, _, _), func);
|
|
|
typedAs(callback(func, _, _, _), func);
|
|
|
|
|
|
// all given
|
|
|
-
|
|
|
+
|
|
|
typedAs(callback(func, 22, "2", 13), tvoid);
|
|
|
|
|
|
// last missing
|
|
|
-
|
|
|
+
|
|
|
typedAs(callback(func, 22, "2"), tfloat);
|
|
|
typedAs(callback(func, 22, "2", _), tfloat);
|
|
|
-
|
|
|
+
|
|
|
// first given
|
|
|
-
|
|
|
+
|
|
|
typedAs(callback(func, 22), tstringfloat);
|
|
|
typedAs(callback(func, 22, _), tstringfloat);
|
|
|
typedAs(callback(func, 22, _, _), tstringfloat);
|
|
|
-
|
|
|
+
|
|
|
// mixed
|
|
|
-
|
|
|
+
|
|
|
typedAs(callback(func, _, _, 12), tintstring);
|
|
|
typedAs(callback(func, _, "22", _), tintfloat);
|
|
|
typedAs(callback(func, _, "22", 12), tint);
|
|
|
typedAs(callback(func, 12, _, 12), tstring);
|
|
|
-
|
|
|
+
|
|
|
// values
|
|
|
-
|
|
|
+
|
|
|
eq(1, callback(func)(1, "2", 3));
|
|
|
eq(2, callback(func, 2)("2", 3));
|
|
|
eq(2, callback(func, 2, "3")(3));
|
|
|
eq(2, callback(func, 2, "3", 4)());
|
|
|
-
|
|
|
+
|
|
|
eq(1, callback(func, _, "2", 3)(1));
|
|
|
eq(1, callback(func, _, "2")(1, 3));
|
|
|
eq(1, callback(func, _)(1, "2", 3));
|
|
|
-
|
|
|
+
|
|
|
eq(1, callback(func, _, "2", _)(1, 2));
|
|
|
-
|
|
|
+
|
|
|
eq(1, callback(callback(func), _, "2", 3)(1));
|
|
|
eq(1, callback(callback(func, 1), "2", 3)());
|
|
|
eq(1, callback(callback(func, 1, _), "2")(3));
|
|
|
eq(1, callback(callback(func, _, "2"), 1)(3));
|
|
|
-
|
|
|
+
|
|
|
var a = 5;
|
|
|
var b = "foo";
|
|
|
var cb = callback(func, a);
|
|
|
a = 6;
|
|
|
func = function(a,b,c):Int return throw "error";
|
|
|
eq(5, cb(b, 0));
|
|
|
-
|
|
|
+
|
|
|
var optfunc = function(a:Int, b:Int, ?c:Int = 2) return a + b + c;
|
|
|
eq(6, callback(optfunc, 1)(3));
|
|
|
eq(6, callback(optfunc, 1, 3)());
|
|
|
-
|
|
|
+
|
|
|
eq(7, callback(optfunc, _, _, _)(1, 2, 4));
|
|
|
eq(7, callback(optfunc, _, 2, _)(1, 4));
|
|
|
-
|
|
|
+
|
|
|
var foo = function ( x : Int, ?p : haxe.PosInfos ) { return "foo" + x; }
|
|
|
var f : Void -> String = callback(foo, 0);
|
|
|
eq("foo0", f());
|
|
|
|
|
|
// TODO: this fails on flash 9
|
|
|
var foo = function(bar = 2) { return bar; };
|
|
|
- #if (flash9 || java) //this fails too on Java, so it may be some problem with typing?
|
|
|
+ #if (flash9)
|
|
|
t(typeError(callback(foo, _)));
|
|
|
#else
|
|
|
var l = callback(foo, _);
|
|
|
eq(2, l());
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
// note that this does not
|
|
|
var foo = function(bar:Null<Int> = 2) { return bar; };
|
|
|
var l = callback(foo, _);
|
|
|
eq(2, l());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testConstantAnonCovariance()
|
|
|
{
|
|
|
var func = function (str:String, ?str1: { x:Float, y:Int }, ?str2: { w:Float, h:Int } ) { };
|
|
@@ -322,48 +322,48 @@ class TestType extends Test {
|
|
|
f(typeError(func("foo", { x:1.2, y:2 } )));
|
|
|
f(typeError(func("foo", { w:1.2, h:2 } )));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testCovariantReturn()
|
|
|
{
|
|
|
var b:Base = null;
|
|
|
var c1:Child1 = null;
|
|
|
var c2_1:Child2_1 = null;
|
|
|
-
|
|
|
+
|
|
|
var c = new Cov2();
|
|
|
typedAs(c.covariant(), c1);
|
|
|
t(Std.is(c.covariant(), Child1));
|
|
|
t(Std.is(cast(c, Cov1).covariant(), Child1));
|
|
|
-
|
|
|
+
|
|
|
// base class reference
|
|
|
var br:Cov1 = c;
|
|
|
typedAs(br.covariant(), b);
|
|
|
t(Std.is(br.covariant(), Child1));
|
|
|
-
|
|
|
+
|
|
|
// interface reference
|
|
|
var ir:CovI = c;
|
|
|
typedAs(ir.covariant(), b);
|
|
|
t(Std.is(ir.covariant(), Child1));
|
|
|
-
|
|
|
+
|
|
|
// dynamic
|
|
|
var dr:Dynamic = c;
|
|
|
t(Std.is(dr.covariant(), Child1));
|
|
|
-
|
|
|
+
|
|
|
// interface covariance
|
|
|
var c3 = new Cov3();
|
|
|
typedAs(c3.covariant(), c2_1);
|
|
|
t(Std.is(c3.covariant(), Child2_1));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testContravariantArgs()
|
|
|
{
|
|
|
var b = function(arg:Base):Void { };
|
|
|
var c1 = function(arg:Child1):Void { };
|
|
|
-
|
|
|
+
|
|
|
var c = new Ctrv2();
|
|
|
typedAs(c.contravariant, b);
|
|
|
typedAs(cast (c, Ctrv1).contravariant, c1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testInitFields()
|
|
|
{
|
|
|
var c = new InitBase();
|
|
@@ -371,22 +371,22 @@ class TestType extends Test {
|
|
|
eq(c.s, "foo");
|
|
|
eq(c.b, true);
|
|
|
eq(c.t, String);
|
|
|
-
|
|
|
+
|
|
|
var c = new InitChild();
|
|
|
eq(c.i, 2);
|
|
|
eq(c.s, "foo");
|
|
|
eq(c.b, true);
|
|
|
eq(c.t, String);
|
|
|
-
|
|
|
+
|
|
|
var c = new InitChildWithCtor(null);
|
|
|
eq(c.i, 2);
|
|
|
eq(c.s, "foo");
|
|
|
eq(c.b, true);
|
|
|
eq(c.t, String);
|
|
|
-
|
|
|
+
|
|
|
var c = Type.createInstance(InitWithoutCtor, []);
|
|
|
eq(c.i, 2);
|
|
|
-
|
|
|
+
|
|
|
var c = new InitProperties();
|
|
|
eq(c.accNull, 3);
|
|
|
eq(c.accDefault, 3);
|
|
@@ -395,7 +395,7 @@ class TestType extends Test {
|
|
|
eq(c.accDynamic, 3);
|
|
|
exc(function() c.accFunc = 4);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testReturnFlow()
|
|
|
{
|
|
|
var l = function():String
|
|
@@ -408,7 +408,7 @@ class TestType extends Test {
|
|
|
}
|
|
|
eq(l(), "foo");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testOptionalParamsSkip() {
|
|
|
function foo( a : MyEnum, ?b : Bool, ?c : MyEnum ) {
|
|
|
return "";
|
|
@@ -418,7 +418,7 @@ class TestType extends Test {
|
|
|
typedAs(foo(A, A), "");
|
|
|
typeError(foo(A, A, false));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testParamConstraints()
|
|
|
{
|
|
|
var pcc = new ParamConstraintsClass();
|
|
@@ -426,63 +426,63 @@ class TestType extends Test {
|
|
|
var c1 = new Child1();
|
|
|
var u = new Unrelated();
|
|
|
var ci1 = new CI1();
|
|
|
-
|
|
|
+
|
|
|
eq(ParamConstraintsClass.staticSingle(b), b);
|
|
|
eq(ParamConstraintsClass.staticSingle(c1), c1);
|
|
|
// TODO: these should fail (param is constrained to Base)
|
|
|
//ParamConstraintsClass.staticSingle(u);
|
|
|
//ParamConstraintsClass.staticSingle(1);
|
|
|
//ParamConstraintsClass.staticSingle("foo");
|
|
|
-
|
|
|
+
|
|
|
eq(pcc.memberSingle(b), b);
|
|
|
eq(pcc.memberSingle(c1), c1);
|
|
|
//typeError(pcc.memberSingle(u));
|
|
|
-
|
|
|
+
|
|
|
eq(pcc.memberMultiple(ci1), ci1);
|
|
|
//typeError(pcc.memberMultiple(b));
|
|
|
//typeError(pcc.memberMultiple(c1));
|
|
|
-
|
|
|
+
|
|
|
var l = new List();
|
|
|
l.push(ci1);
|
|
|
var lmono = new List();
|
|
|
eq(pcc.memberComplex(ci1, l), l);
|
|
|
eq(pcc.memberComplex(ci1, lmono), lmono);
|
|
|
//typeError(pcc.memberComplex(ci1, [ci1]));
|
|
|
-
|
|
|
+
|
|
|
eq(pcc.memberBasic("foo", ["bar"]), "bar");
|
|
|
-
|
|
|
+
|
|
|
eq(pcc.memberAnon( { x : 1, y : 3. } ), 4);
|
|
|
//typeError(pcc.memberAnon( { x : 1 } ));
|
|
|
//typeError(pcc.memberAnon( { y : 3. } ));
|
|
|
-
|
|
|
+
|
|
|
#if !(java || cs)
|
|
|
pcc.memberOverload("foo", "bar");
|
|
|
#end
|
|
|
// TODO: this should not fail (overload accepts)
|
|
|
//pcc.memberOverload(1, [2]);
|
|
|
//t(typeError(pcc.memberOverload(1, ["foo"])));
|
|
|
-
|
|
|
+
|
|
|
var pcc2 = new ParamConstraintsClass2();
|
|
|
pcc2.check([1]);
|
|
|
//typeError(pcc2.check(["foo"]));
|
|
|
-
|
|
|
+
|
|
|
var pcc2 = new ParamConstraintsClass2();
|
|
|
pcc2.bind("foo");
|
|
|
//typeError(pcc2.check([1]));
|
|
|
pcc2.check(["foo"]);
|
|
|
-
|
|
|
+
|
|
|
var pcc2 = new ParamConstraintsClass2<String>();
|
|
|
//t(typeError(pcc2.check([1])));
|
|
|
pcc2.check(["foo"]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testUsing()
|
|
|
{
|
|
|
eq(UsingChild1.test(), "FOOFOOFOO");
|
|
|
eq(UsingChild2.test(), "FOO");
|
|
|
eq(UsingUnrelated.test(), "FOOFOO");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testInlineInit()
|
|
|
{
|
|
|
eq(InitBase.si, 2);
|
|
@@ -491,21 +491,21 @@ class TestType extends Test {
|
|
|
eq(InitBase.st, String);
|
|
|
eq(InitBase.sinline, 60000.);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testInline()
|
|
|
{
|
|
|
typedAs(inlineTest1([1]), var void:Void);
|
|
|
typedAs(inlineTest2([1]), var void:Void);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
inline function inlineTest1<T>(map:Array<T>) {
|
|
|
map[0];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
inline function inlineTest2(map:Array<Dynamic>) {
|
|
|
map[0];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function testMacroRest() {
|
|
|
#if !macro
|
|
|
var r = MyMacro.MyRestMacro.testRest1(1, 2, 3);
|
|
@@ -513,29 +513,29 @@ class TestType extends Test {
|
|
|
eq(r[0], 1);
|
|
|
eq(r[1], 2);
|
|
|
eq(r[2], 3);
|
|
|
-
|
|
|
+
|
|
|
var r : Array<Dynamic> = MyMacro.MyRestMacro.testRest1(1, [2, 3]);
|
|
|
eq(r.length, 2);
|
|
|
eq(r[0], 1);
|
|
|
eq(r[1][0], 2);
|
|
|
eq(r[1][1], 3);
|
|
|
-
|
|
|
+
|
|
|
var r = MyMacro.MyRestMacro.testRest1(1);
|
|
|
eq(r.length, 1);
|
|
|
eq(r[0], 1);
|
|
|
-
|
|
|
+
|
|
|
var r = MyMacro.MyRestMacro.testRest2(1, 2, 3, 4);
|
|
|
eq(r.length, 4);
|
|
|
eq(r[0], 1);
|
|
|
eq(r[1], 2);
|
|
|
eq(r[2], 3);
|
|
|
eq(r[3], 4);
|
|
|
-
|
|
|
+
|
|
|
var r = MyMacro.MyRestMacro.testRest2(1, 2);
|
|
|
eq(r.length, 2);
|
|
|
eq(r[0], 1);
|
|
|
eq(r[1], 2);
|
|
|
-
|
|
|
+
|
|
|
var r : Array<Dynamic> = MyMacro.MyRestMacro.testRest2(1, 2, [3]);
|
|
|
eq(r.length, 3);
|
|
|
eq(r[0], 1);
|
|
@@ -543,91 +543,91 @@ class TestType extends Test {
|
|
|
eq(r[2][0], 3);
|
|
|
#end
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function testGenericFunction() {
|
|
|
gf1(2);
|
|
|
gf1("foo");
|
|
|
gf1(true);
|
|
|
-
|
|
|
+
|
|
|
#if !flash8
|
|
|
// no support for flash8
|
|
|
gf1(new haxe.Template("foo"));
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
gf1(new haxe.FastList<Int>());
|
|
|
hsf(TestType, "gf1_Int");
|
|
|
hsf(TestType, "gf1_String");
|
|
|
hsf(TestType, "gf1_Bool");
|
|
|
-
|
|
|
+
|
|
|
#if !flash8
|
|
|
hsf(TestType, "gf1_haxe_Template");
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
hsf(TestType, #if (flash9 || cpp) "gf1_haxe_FastList_Int" #else "gf1_haxe_FastList" #end);
|
|
|
t(typeError(gf1(null))); // monos don't work
|
|
|
t(typeError(gf1( { foo:1 } ))); // structures don't work
|
|
|
-
|
|
|
+
|
|
|
eq("foo[1,2]", gf2("foo", [1, 2]));
|
|
|
eq("foo[[1,2]]", gf2("foo", [[1, 2]]));
|
|
|
hsf(TestType, "gf2_String_Int");
|
|
|
hsf(TestType, "gf2_String_Array");
|
|
|
-
|
|
|
+
|
|
|
var a = gf3("foo", ["bar", "baz"]);
|
|
|
eq(a[0], "bar");
|
|
|
eq(a[1], "baz");
|
|
|
eq(a[2], "foo");
|
|
|
hsf(TestType, "gf3_String_Array");
|
|
|
-
|
|
|
+
|
|
|
#if !flash8
|
|
|
var t = new haxe.Template("foo");
|
|
|
var ta = gf3(t, [])[0];
|
|
|
f(t == ta);
|
|
|
hsf(TestType, "gf3_haxe_Template_Array");
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
eq(overloadFake(1), 1);
|
|
|
eq(overloadFake("bar"), "barfoo");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@:generic static function gf1<T>(a:T) {
|
|
|
return a;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@:generic static function gf2<A,B>(a:A, b:Array<B>) {
|
|
|
return Std.string(a) + Std.string(b);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@:generic static function gf3 < A, B:Array<A> > (a:A, b:B) {
|
|
|
var clone = new A("foo");
|
|
|
b.push(clone);
|
|
|
return b;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@:generic static function overloadFake<A>(a:A) {
|
|
|
return a;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
static function overloadFake_String(a:String) {
|
|
|
return a + "foo";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testCompletion() {
|
|
|
#if !macro
|
|
|
var s = { foo: 1 };
|
|
|
eq(complete("s.|"), "foo:Int");
|
|
|
eq(complete("var x : haxe.|"), "path(haxe)");
|
|
|
eq(complete("var x : haxe.macro.Expr.|"), "path(haxe.macro:Expr)");
|
|
|
-
|
|
|
+
|
|
|
// could be improved by listing sub types
|
|
|
eq(complete("haxe.macro.Expr.|"), "error(haxe.macro.Expr is not a value)");
|
|
|
-
|
|
|
+
|
|
|
// know issue : the expr optimization will prevent inferring the array content
|
|
|
eq(complete('{
|
|
|
var a = [];
|
|
|
a.push("");
|
|
|
a[0].|
|
|
|
}'),"Unknown<0>");
|
|
|
-
|
|
|
+
|
|
|
// could be improved : expr optimization assume that variable not in scope is a member
|
|
|
// so it will eliminate the assignement that would have forced it into the local context
|
|
|
// that would be useful when you want to write some code and add the member variable afterwards
|
|
@@ -635,17 +635,17 @@ class TestType extends Test {
|
|
|
unknownVar = "";
|
|
|
unknownVar.|
|
|
|
}'),"path(unknownVar)");
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
for (k in [s].iterator()) {
|
|
|
eq(complete("k.|"), "foo:Int");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var f = function():Iterator<{foo:Int}> {
|
|
|
return [s].iterator();
|
|
|
};
|
|
|
eq(complete("for (k in f()) k.|"), "foo:Int");
|
|
|
#end
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|