浏览代码

[lua] make sure string fields are kept for reflection

Justin Donaldson 8 年之前
父节点
当前提交
e108528059
共有 4 个文件被更改,包括 30 次插入0 次删除
  1. 1 0
      .gitignore
  2. 3 0
      tests/RunCi.hx
  3. 21 0
      tests/misc/luaDeadCode/issue6276/Issue6276.hx
  4. 5 0
      tests/misc/luaDeadCode/issue6276/compile.hxml

+ 1 - 0
.gitignore

@@ -77,6 +77,7 @@ tests/sys/bin/
 /tests/sys/dump/
 tests/optimization/dump/
 tests/misc/projects/*/*.n
+tests/misc/*/*/*.lua
 tests/unit/bin/
 tests/*.n
 tests/misc/projects/Issue3756/cpp/

+ 3 - 0
tests/RunCi.hx

@@ -863,6 +863,9 @@ class RunCi {
 						  changeDirectory(sysDir);
 						  runCommand("haxe", ["compile-lua.hxml"].concat(args));
 						  runCommand("lua", ["bin/lua/sys.lua"]);
+
+						  changeDirectory(miscDir + "");
+						  runCommand("haxe", ["compile.hxml"]);
 						}
 					case Cpp:
 						getCppDependencies();

+ 21 - 0
tests/misc/luaDeadCode/issue6276/Issue6276.hx

@@ -0,0 +1,21 @@
+class Issue6276 {
+	public static function main() {
+		var s = "foo";
+		var indexOf = Reflect.field(s, "indexOf");
+		var isfunc = lua.Lua.type(indexOf) == "function";
+		if (!isfunc){
+			trace("DCE should not remove string functions in lua");
+			Sys.exit(1);
+		}
+		var res = Reflect.callMethod(s, indexOf, ["o"]);
+		if (res != 1){
+			trace("Something went wrong with calling string methods via reflect");
+			Sys.exit(1);
+		}
+		var eq = Reflect.compareMethods(Reflect.field(s, 'indexOf'), Reflect.field(s, 'indexOf'));
+		if (!eq){
+			trace("Reflect.compareMethods should work for string methods");
+			Sys.exit(1);
+		}
+	}
+}

+ 5 - 0
tests/misc/luaDeadCode/issue6276/compile.hxml

@@ -0,0 +1,5 @@
+-main Issue6276
+-lua issue6276.lua
+-cmd lua issue6276.lua
+-cp tests/misc/luaDeadCode/issue6276
+