2
0
Эх сурвалжийг харах

added tests for JSON, disabled the one for Reflect.get/setProperty (pushed back to haXe3)

Nicolas Cannasse 13 жил өмнө
parent
commit
f4268cb80d

+ 11 - 0
tests/unit/TestMisc.hx

@@ -327,4 +327,15 @@ class TestMisc extends Test {
 	}
 	#end
 	
+	function testJSon() {
+		var str = haxe.Json.stringify( { x : -4500, y : 1.456, a : ["hello", "wor'\"\n\t\rd"] } );
+		str = str.substr(1, str.length - 2); // remove {}
+		var parts = str.split(",");
+		t( parts.remove('"x":-4500') );
+		t( parts.remove('"y":1.456') );
+		t( parts.remove('"a":["hello"') );
+		t( parts.remove('"wor\'\\"\\n\\t\\rd"]') );
+		eq( parts.join("#"), "" );
+	}
+	
 }

+ 2 - 0
tests/unit/TestReflect.hx

@@ -239,6 +239,7 @@ class TestReflect extends Test {
 		f( Reflect.compareMethods(null,a.add) );
 	}
 	
+	#if haxe3
 	function testGetProp() {
 		
 		var c = new ClassWithProp();
@@ -270,5 +271,6 @@ class TestReflect extends Test {
 		eq( ClassWithProp.STAT_X, 16 );
 		eq( Reflect.getProperty(ClassWithProp, "STAT_X"), 16 );
 	}
+	#end
 
 }

+ 2 - 1
tests/unit/unit.hxml

@@ -6,7 +6,8 @@
 -swf-version 8
 params.hxml
 --next
--swf9 unit9.swf
+-swf unit9.swf
+-swf-version 11
 -main unit.Test
 params.hxml
 --next

+ 2 - 1
tests/unit/unit.hxproj

@@ -23,7 +23,7 @@
     <option flashStrict="False" />
     <option mainClass="unit.Test" />
     <option enabledebug="False" />
-    <option additional="-swf-version 8&#xA;params.hxml&#xA;&#xA;# Flash9&#xA;--next&#xA;-swf9 unit9.swf&#xA;-main unit.Test&#xA;params.hxml&#xA;&#xA;# AS3&#xA;--next&#xA;-as3 as3&#xA;-cp ..&#xA;-main unit.Test&#xA;#-cmd mxmlc -default-size 800 600 -debug -output unit9_as3.swf as3/__main__.as&#xA;&#xA;# JS&#xA;--next&#xA;-js unit.js&#xA;unit.Test&#xA;params.hxml&#xA;&#xA;# Neko&#xA;--next&#xA;-neko unit.n&#xA;-main unit.Test&#xA;params.hxml&#xA;&#xA;# MACROS&#xA;--next&#xA;-main unit.Test&#xA;params.hxml&#xA;--interp&#xA;&#xA;# RemotingServer&#xA;--next&#xA;-neko remoting.n&#xA;-main unit.RemotingServer&#xA;-cp ..&#xA;&#xA;# PHP&#xA;--next&#xA;-php php&#xA;-main unit.Test&#xA;params.hxml&#xA;&#xA;# CPP&#xA;--next&#xA;-neko runcpp.n&#xA;-main RunCpp&#xA;--next&#xA;-cpp cpp&#xA;-main unit.Test&#xA;params.hxml" />
+    <option additional="-swf-version 8&#xA;params.hxml&#xA;&#xA;# Flash9&#xA;--next&#xA;-swf unit9.swf&#xA;-swf-version 11&#xA;-main unit.Test&#xA;params.hxml&#xA;&#xA;# AS3&#xA;--next&#xA;-as3 as3&#xA;-cp ..&#xA;-main unit.Test&#xA;#-cmd mxmlc -default-size 800 600 -debug -output unit9_as3.swf as3/__main__.as&#xA;&#xA;# JS&#xA;--next&#xA;-js unit.js&#xA;unit.Test&#xA;params.hxml&#xA;&#xA;# Neko&#xA;--next&#xA;-neko unit.n&#xA;-main unit.Test&#xA;params.hxml&#xA;&#xA;# MACROS&#xA;--next&#xA;-main unit.Test&#xA;params.hxml&#xA;--interp&#xA;&#xA;# RemotingServer&#xA;--next&#xA;-neko remoting.n&#xA;-main unit.RemotingServer&#xA;-cp ..&#xA;&#xA;# PHP&#xA;--next&#xA;-php php&#xA;-main unit.Test&#xA;params.hxml&#xA;&#xA;# CPP&#xA;--next&#xA;-neko runcpp.n&#xA;-main RunCpp&#xA;--next&#xA;-cpp cpp&#xA;-main unit.Test&#xA;params.hxml" />
   </build>
   <!-- haxelib libraries -->
   <haxelib>
@@ -53,6 +53,7 @@
     <hidden path="unit8.swf" />
     <hidden path="unit9.swf" />
     <hidden path="unit9_as3.swf" />
+    <hidden path="unit.js.map" />
   </hiddenPaths>
   <!-- Executed before build -->
   <preBuildCommand />