浏览代码

fixed tests : Reflect is not always guaranteed to work if the field has been renamed. Normal field access should still work (bug in PHP for 'const')

Nicolas Cannasse 13 年之前
父节点
当前提交
d7ef0c68a6
共有 1 个文件被更改,包括 11 次插入3 次删除
  1. 11 3
      tests/unit/TestBasetypes.hx

+ 11 - 3
tests/unit/TestBasetypes.hx

@@ -202,7 +202,7 @@ class TestBasetypes extends Test {
 		eq( Std.parseInt("0xFF"), 255 );
 		eq( Std.parseInt("0x123"), 291 );
 		eq( Std.parseInt("0XFF"), 255 );
-		eq( Std.parseInt("0X123"), 291 );		
+		eq( Std.parseInt("0X123"), 291 );
 		unspec(function() Std.parseInt("0xFG"));
 
 		eq( Std.parseFloat("0"), 0. );
@@ -307,8 +307,16 @@ class TestBasetypes extends Test {
 		f( h.remove(1) );
 	}
 	
-	function testObject() {
+	function testObjectKeyword() {
+		// new is a keyword in Haxe
 		var l = { "new": "test" };
-		eq(Reflect.field(l, "new"), "test");
+		var prefix = #if as3 "_" #else "" #end;
+		eq(Reflect.field(l, prefix + "new"), "test");
+		// const is a keyword on some platforms but not in Haxe
+		// check that with can still access it normally
+		var o = { const : 6 }
+		eq(o.const, 6);
+		eq(Reflect.field(o, prefix+"const"), 6);
 	}
+
 }