Bläddra i källkod

Lua: sys-specific test alterations and additions

Justin Donaldson 9 år sedan
förälder
incheckning
6602f3ab11

+ 6 - 4
tests/sys/src/ExitCode.hx

@@ -31,13 +31,15 @@ class ExitCode {
 		"bin/python/ExitCode.py";
 	#elseif php
 		"bin/php/ExitCode/index.php";
+	#elseif lua
+		"bin/lua/ExitCode.lua";
 	#else
 		null;
 	#end
 
 	static public function getNative():String {
-		// This is just a script that behaves like ExitCode.hx, 
-		// which exits with the code same as the first given argument. 
+		// This is just a script that behaves like ExitCode.hx,
+		// which exits with the code same as the first given argument.
 		// var scriptContent = switch (Sys.systemName()) {
 		// 	case "Windows":
 		// 		'@echo off\nexit /b %1';
@@ -80,8 +82,8 @@ class ExitCode {
 
 		return binPath;
 	}
-	
+
 	static function main():Void {
 		Sys.exit(Std.parseInt(Sys.args()[0]));
 	}
-}
+}

+ 2 - 1
tests/sys/src/TestArguments.hx

@@ -82,6 +82,8 @@ class TestArguments extends haxe.unit.TestCase {
 		"bin/python/TestArguments.py";
 	#elseif php
 		"bin/php/TestArguments/index.php";
+	#elseif lua
+		"bin/lua/TestArguments.lua";
 	#else
 		null;
 	#end
@@ -90,7 +92,6 @@ class TestArguments extends haxe.unit.TestCase {
 
 	function testArgs() {
 		var args = Sys.args();
-		// trace(args);
 		for (i in 0...expectedArgs.length) {
 			assertEquals(expectedArgs[i], args[i]);
 		}

+ 12 - 2
tests/sys/src/TestCommandBase.hx

@@ -37,6 +37,11 @@ class TestCommandBase extends haxe.unit.TestCase {
 				run(Sys.executablePath(), [bin].concat(args));
 			#elseif php
 				run(untyped __php__("defined('PHP_BINARY') ? PHP_BINARY : 'php'"), [bin].concat(args));
+			#elseif lua
+				switch(Sys.getEnv("LUA")){
+					case null : run("lua", [bin].concat(args));
+					default   : run(Sys.getEnv("LUA"), [bin].concat(args));
+				};
 			#else
 				-1;
 			#end
@@ -45,7 +50,7 @@ class TestCommandBase extends haxe.unit.TestCase {
 		assertEquals(0, exitCode);
 	}
 
-	function testCommandName() {		
+	function testCommandName() {
 		var binExt = switch (Sys.systemName()) {
 			case "Windows":
 				".exe";
@@ -117,6 +122,11 @@ class TestCommandBase extends haxe.unit.TestCase {
 					run(Sys.executablePath(), [bin].concat(args));
 				#elseif php
 					run(untyped __php__("defined('PHP_BINARY') ? PHP_BINARY : 'php'"), [bin].concat(args));
+				#elseif lua
+					switch(Sys.getEnv("LUA")){
+						case null: run("lua", [bin].concat(args));
+						default : run(Sys.getEnv("LUA"), [bin].concat(args));
+					};
 				#else
 					-1;
 				#end
@@ -130,4 +140,4 @@ class TestCommandBase extends haxe.unit.TestCase {
 		var exitCode = run('$native 1 || $native 0');
 		assertEquals(0, exitCode);
 	}
-}
+}

+ 4 - 2
tests/sys/src/TestSys.hx

@@ -4,13 +4,13 @@ class TestSys extends TestCommandBase {
 	}
 
 	function testEnv() {
-		#if !(java || php)
+		#if !(java || php || lua)
 		Sys.putEnv("foo", "value");
 		assertEquals("value", Sys.getEnv("foo"));
 		#end
 		assertEquals(null, Sys.getEnv("doesn't exist"));
 
-		#if !(java || php)
+		#if !(java || php || lua)
 		var env = Sys.environment();
 		assertEquals("value", env.get("foo"));
 		#end
@@ -48,6 +48,8 @@ class TestSys extends TestCommandBase {
 			assertTrue(StringTools.endsWith(p, "sys.py"));
 		#elseif php
 			assertTrue(StringTools.endsWith(p, "index.php"));
+		#elseif lua
+			assertTrue(StringTools.endsWith(p, "sys.lua"));
 		#end
 	}