2
0
Nicolas Cannasse 14 жил өмнө
parent
commit
0cba766d9d

+ 37 - 10
tests/unit/TestOps.hx

@@ -1,37 +1,64 @@
 package unit;
 
 class TestOps extends Test {
-	
+
 	public function testOps()
 	{
 		eq(1 + 2 + "", "3");
 		eq((1 + 2) + "", "3");
 		eq(1 + (2 + ""), "12");
-		
+
 		eq(4 - 3 + "", "1");
 		eq((4 - 3) + "", "1");
 		//eq(4 - (3 + ""), "1");
-		
+
 		eq(4 | 3 & 1, 1);
 		eq((4 | 3) & 1, 1);
 		eq(4 | (3 & 1), 5);
-		
+
 		eq(4 & 3 | 1, 1);
 		eq((4 & 3) | 1, 1);
 		eq(4 & (3 | 1), 0);
-		
+
 		eq( - 5 + 1, -4 );
 		eq( - (5 + 1), -6 );
-		
-		t( 3 == 7 >> 1 );
-		
+
+		t( 5 << 2 == 20 );
+		t( (5 << 2) == 20 );
+		t( 20 == 5 << 2 );
+		t( 20 == (5 << 2) );
+
 		eq( 5 % 3 * 4, 8 );
 		eq( (5 % 3) * 4, 8 );
 		eq( 5 % (3 * 4), 5 );
-		
+
 		eq( 20 / 2 / 2, 5 );
 		eq( (20 / 2) / 2, 5 );
 		eq( 20 / (2 / 2), 20 );
+
+		eq( 2 << 3 >> 1, 8 );
+		eq( (2 << 3) >> 1, 8 );
+		eq( 2 << (3 >> 1), 4 );
+
+		f( (1 & 0x8000) != 0 );
+		f( 1 & 0x8000 != 0 );
+		f( 0 != (1 & 0x8000) );
+		f( 0 != 1 & 0x8000 );
+
+		eq( 5 * 10 % 3, 5);
+		eq( 5 * (10 % 3), 5);
+		eq( (5 * 10) % 3, 2);
+
+		eq( 10 % 3 * 5, 5);
+		eq( (10 % 3) * 5, 5);
+		eq( 10 % (3 * 5), 10);
+
+		eq( true ? 1 : 6 * 5, 1);
+		eq( false ? 1 : 6 * 5, 30);
+		eq( (true ? 1 : 6) * 5, 5);
+		eq( (false ? 1 : 6) * 5, 30);
+
+		t( true || false && false );
 	}
-	
+
 }

+ 1 - 12
tests/unit/TestXML.hx

@@ -71,27 +71,16 @@ class TestXML extends Test {
 		var xml = '<html><body><![CDATA[<a href="CDATA"/>&lt;]]></body></html>';
 
 		#if flash8
-		// flash8 can't parse header
-		header = '';
+		return; // too hard for him
 		#end
 
 		var x = Xml.parse(header + doctype + comment + xml);
 
-		#if flash8
-		// cdata is parsed as pcdata in flash8
-		xml = '<html><body>&lt;a href=&quot;CDATA&quot;/&gt;&amp;lt;</body></html>';
-		#end
-
 		#if (flash || php)
 		// doctype is well parsed but is not present in the parsed Xml (php, f8 and f9)
 		doctype = '';
 		#end
 
-		#if flash8
-		// comments are well parsed but are not present in the parsed Xml
-		comment = '';
-		#end
-
 		eq( x.toString(), header + doctype + comment + xml);
 	}
 

+ 1 - 1
tests/unit/unit.hxml

@@ -1,8 +1,8 @@
 -cp ..
 -swf unit8.swf
--swf-version 8
 -swf-header 300:300:30:FFFFFF
 -main unit.Test
+-swf-version 8
 params.hxml
 --next
 -swf9 unit9.swf

+ 1 - 1
tests/unit/unit.hxproj

@@ -21,7 +21,7 @@
     <option flashStrict="False" />
     <option mainClass="unit.Test" />
     <option enabledebug="False" />
-    <option additional="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;-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" />
   </build>
   <!-- haxelib libraries -->
   <haxelib>