|
@@ -1,9 +1,54 @@
|
|
|
package unit;
|
|
package unit;
|
|
|
|
|
+import haxe.io.Bytes;
|
|
|
|
|
+import haxe.test.Base;
|
|
|
|
|
+import haxe.test.Base.Base_InnerClass;
|
|
|
|
|
+import haxe.test.TEnum;
|
|
|
|
|
|
|
|
//C#-specific tests, like unsafe code
|
|
//C#-specific tests, like unsafe code
|
|
|
class TestCSharp extends Test
|
|
class TestCSharp extends Test
|
|
|
{
|
|
{
|
|
|
- #if cs
|
|
|
|
|
|
|
+#if cs
|
|
|
|
|
+
|
|
|
|
|
+ // -net-lib tests
|
|
|
|
|
+ function testHaxeKeywords()
|
|
|
|
|
+ {
|
|
|
|
|
+ eq(Base._inline, 42);
|
|
|
|
|
+ eq(Base._callback, 43);
|
|
|
|
|
+ eq(Base._cast, 44);
|
|
|
|
|
+ eq(Base._untyped, 45);
|
|
|
|
|
+ Base._untyped = 40;
|
|
|
|
|
+ eq(Base._untyped, 40);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function testTypes()
|
|
|
|
|
+ {
|
|
|
|
|
+ eq(Base.charTest(cast 10), cast 10);
|
|
|
|
|
+ eq(Base.byteTest(cast 10), cast 10);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function testInnerClass()
|
|
|
|
|
+ {
|
|
|
|
|
+ //-java-lib should be able to detect inner classes on import
|
|
|
|
|
+ var i = new Base_InnerClass();
|
|
|
|
|
+ eq(10,i.nameClash());
|
|
|
|
|
+
|
|
|
|
|
+ var i2 = new Base_InnerClass_InnerInnerClass();
|
|
|
|
|
+ t(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function testGenerics()
|
|
|
|
|
+ {
|
|
|
|
|
+ var jcl:cs.system.Type = cast Base_InnerClass_InnerInnerClass;
|
|
|
|
|
+ t(haxe.test.GenericHelper.staticTypedGeneric(jcl) != null);
|
|
|
|
|
+
|
|
|
|
|
+ var helper = new haxe.test.GenericHelper();
|
|
|
|
|
+
|
|
|
|
|
+ var val = new Base_InnerClass();
|
|
|
|
|
+ var g1 = new haxe.test.Generic1(val);
|
|
|
|
|
+ g1.complexTypeParameterOfTypeParameter(new Base_InnerClass_InnerInnerClass());
|
|
|
|
|
+ //if no compile-time error, we're fine!
|
|
|
|
|
+ t(true);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@:skipReflection private function refTest(i:cs.Ref<Int>):Void
|
|
@:skipReflection private function refTest(i:cs.Ref<Int>):Void
|
|
|
{
|
|
{
|
|
@@ -15,20 +60,20 @@ class TestCSharp extends Test
|
|
|
out = x * 2;
|
|
out = x * 2;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // test for https://github.com/HaxeFoundation/haxe/issues/2528
|
|
|
|
|
- public function testDynObjectSetField()
|
|
|
|
|
- {
|
|
|
|
|
- var a:Dynamic = {};
|
|
|
|
|
- a.status = 10;
|
|
|
|
|
- var b:{status:Int} = a;
|
|
|
|
|
- b.status = 15;
|
|
|
|
|
-
|
|
|
|
|
- eq(a, b);
|
|
|
|
|
- eq(Reflect.fields(a).length, 1);
|
|
|
|
|
- eq(Reflect.fields(b).length, 1);
|
|
|
|
|
- eq(a.status, 15);
|
|
|
|
|
- eq(b.status, 15);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // test for https://github.com/HaxeFoundation/haxe/issues/2528
|
|
|
|
|
+ public function testDynObjectSetField()
|
|
|
|
|
+ {
|
|
|
|
|
+ var a:Dynamic = {};
|
|
|
|
|
+ a.status = 10;
|
|
|
|
|
+ var b:{status:Int} = a;
|
|
|
|
|
+ b.status = 15;
|
|
|
|
|
+
|
|
|
|
|
+ eq(a, b);
|
|
|
|
|
+ eq(Reflect.fields(a).length, 1);
|
|
|
|
|
+ eq(Reflect.fields(b).length, 1);
|
|
|
|
|
+ eq(a.status, 15);
|
|
|
|
|
+ eq(b.status, 15);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public function testRef()
|
|
public function testRef()
|
|
|
{
|
|
{
|
|
@@ -55,18 +100,18 @@ class TestCSharp extends Test
|
|
|
public function testChecked()
|
|
public function testChecked()
|
|
|
{
|
|
{
|
|
|
exc(function()
|
|
exc(function()
|
|
|
- {
|
|
|
|
|
- cs.Lib.checked({
|
|
|
|
|
- var x = 1000;
|
|
|
|
|
- while(true)
|
|
|
|
|
{
|
|
{
|
|
|
- x *= x;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ cs.Lib.checked({
|
|
|
|
|
+ var x = 1000;
|
|
|
|
|
+ while(true)
|
|
|
|
|
+ {
|
|
|
|
|
+ x *= x;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- #if unsafe
|
|
|
|
|
|
|
+#if unsafe
|
|
|
|
|
|
|
|
@:unsafe public function testUnsafe()
|
|
@:unsafe public function testUnsafe()
|
|
|
{
|
|
{
|
|
@@ -74,18 +119,18 @@ class TestCSharp extends Test
|
|
|
cs.Lib.fixed({
|
|
cs.Lib.fixed({
|
|
|
var p = cs.Lib.pointerOfArray(x);
|
|
var p = cs.Lib.pointerOfArray(x);
|
|
|
for (i in 0...10)
|
|
for (i in 0...10)
|
|
|
- {
|
|
|
|
|
- p[0] = i;
|
|
|
|
|
- p = p.add(1);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ p[0] = i;
|
|
|
|
|
+ p = p.add(1);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
cs.Lib.fixed( {
|
|
cs.Lib.fixed( {
|
|
|
var p = cs.Lib.pointerOfArray(x);
|
|
var p = cs.Lib.pointerOfArray(x);
|
|
|
for (i in 0...10)
|
|
for (i in 0...10)
|
|
|
- {
|
|
|
|
|
- eq(p[i], i);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ eq(p[i], i);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
var x:Int = 0;
|
|
var x:Int = 0;
|
|
@@ -100,7 +145,7 @@ class TestCSharp extends Test
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- #end
|
|
|
|
|
|
|
+#end
|
|
|
|
|
|
|
|
// test these because C# generator got a special filter for these expressions
|
|
// test these because C# generator got a special filter for these expressions
|
|
|
public function testNullConstEq()
|
|
public function testNullConstEq()
|
|
@@ -112,7 +157,7 @@ class TestCSharp extends Test
|
|
|
t(null != a);
|
|
t(null != a);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- #end
|
|
|
|
|
|
|
+#end
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@:nativeGen private class NativeClass
|
|
@:nativeGen private class NativeClass
|