Browse Source

[tests] update tests

Rudy Ges 7 months ago
parent
commit
067c8c3d5a

+ 20 - 36
tests/server/src/cases/issues/Issue12001.hx

@@ -15,16 +15,23 @@ class Issue12001 extends TestCase {
 		assertSuccess();
 	}
 
-	function testDefineType1(_) {
+	@:async
+	@:timeout(3000)
+	function testRedefineType(async:Async) {
 		vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
 		vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main.hx"));
-		var args = ["-main", "Main", "--macro", "Macro.defineType()"];
-		runHaxe(args);
-		assertSuccess();
-
-		runHaxe(args);
-		assertSuccess();
-		assertSkipping("Main", DependencyDirty("Foo - Tainted define_type"));
+		var args = ["-main", "Main", "--interp", "--macro", "Macro.defineType()"];
+		var i = 0;
+		function test() {
+			// Was failing with nightlies (HxbFailure)
+			runHaxe(args, () -> {
+				assertSuccess();
+				assertHasPrint("Foo.test() = " + i);
+				if (++i >= 5) async.done();
+				else test();
+			});
+		}
+		test();
 	}
 
 	function testDefineModule(_) {
@@ -39,29 +46,18 @@ class Issue12001 extends TestCase {
 		assertSuccess();
 	}
 
-	function testDefineModule1(_) {
-		vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
-		vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main1.hx"));
-		var args = ["-main", "Main", "--macro", "Macro.defineModule()"];
-		runHaxe(args);
-		assertSuccess();
-
-		runHaxe(args);
-		assertSuccess();
-		assertSkipping("Main", DependencyDirty("Bar - Tainted define_module"));
-	}
-
 	@:async
 	@:timeout(3000)
 	function testRedefineModule(async:Async) {
 		vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
-		vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main2.hx"));
-		var args = ["-main", "Main", "--interp", "--macro", "Macro.redefineModule()"];
+		vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main1.hx"));
+		var args = ["-main", "Main", "--interp", "--macro", "Macro.defineModule()"];
 		var i = 0;
 		function test() {
+			// Was failing with nightlies (HxbFailure)
 			runHaxe(args, () -> {
 				assertSuccess();
-				assertHasPrint("Foobar.test() = " + i);
+				assertHasPrint("Bar.test() = " + i);
 				if (++i >= 5) async.done();
 				else test();
 			});
@@ -69,18 +65,6 @@ class Issue12001 extends TestCase {
 		test();
 	}
 
-	function testAfterTyping(_) {
-		vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
-		vfs.putContent("Empty.hx", getTemplate("Empty.hx"));
-		var args = ["-main", "Empty", "--macro", "Macro.hook()"];
-		runHaxe(args);
-		assertSuccess();
-
-		// Nothing is loading Baz, so it can be defined again
-		runHaxe(args);
-		assertSuccess();
-	}
-
 	@:async
 	@:timeout(3000)
 	function testRedefineAfterTyping(async:Async) {
@@ -92,7 +76,7 @@ class Issue12001 extends TestCase {
 			runHaxe(args, () -> {
 				assertSuccess();
 				// Newest version is being included
-				assertHasPrint("Foobaz.test() = " + i);
+				assertHasPrint("Baz.test() = " + i);
 				if (++i >= 5) async.done();
 				else test();
 			});

+ 7 - 38
tests/server/test/templates/issues/Issue12001/Macro.hx

@@ -1,5 +1,6 @@
 import haxe.macro.Context;
 
+@:persistent var i = 0;
 function defineType() {
 	Context.onAfterInitMacros(() -> {
 		Context.defineType({
@@ -8,12 +9,13 @@ function defineType() {
 			name: "Foo",
 			kind: TDClass(null, null, false, false, false),
 			fields: (macro class Foo {
-				public static function test() {}
+				public static function test() Sys.println("Foo.test() = " + $v{i++});
 			}).fields
 		});
 	});
 }
 
+@:persistent var j = 0;
 function defineModule() {
 	Context.onAfterInitMacros(() -> {
 		Context.defineModule("Bar", [{
@@ -22,28 +24,14 @@ function defineModule() {
 			name: "Bar",
 			kind: TDClass(null, null, false, false, false),
 			fields: (macro class Bar {
-				public static function test() {}
-			}).fields
-		}]);
-	});
-}
-
-@:persistent var i = 0;
-function redefineModule() {
-	Context.onAfterInitMacros(() -> {
-		Context.defineModule("Foobar", [{
-			pos: Context.currentPos(),
-			pack: [],
-			name: "Foobar",
-			kind: TDClass(null, null, false, false, false),
-			fields: (macro class Foobar {
-				public static function test() Sys.println("Foobar.test() = " + $v{i++});
+				public static function test() Sys.println("Bar.test() = " + $v{j++});
 			}).fields
 		}]);
 	});
 }
 
-function hook() {
+@:persistent var k = 0;
+function hookRedefine() {
 	var generated = false;
 	Context.onAfterTyping((_) -> {
 		if (generated) return;
@@ -55,26 +43,7 @@ function hook() {
 			name: "Baz",
 			kind: TDClass(null, null, false, false, false),
 			fields: (macro class Baz {
-				public static function test() {}
-			}).fields
-		}]);
-	});
-}
-
-@:persistent var j = 0;
-function hookRedefine() {
-	var generated = false;
-	Context.onAfterTyping((_) -> {
-		if (generated) return;
-		generated = true;
-
-		Context.defineModule("Foobaz", [{
-			pos: Context.currentPos(),
-			pack: [],
-			name: "Foobaz",
-			kind: TDClass(null, null, false, false, false),
-			fields: (macro class Foobaz {
-				public static function __init__() Sys.println("Foobaz.test() = " + $v{j++});
+				public static function __init__() Sys.println("Baz.test() = " + $v{k++});
 			}).fields
 		}]);
 	});

+ 1 - 1
tests/server/test/templates/issues/Issue12001/Main.hx

@@ -1,3 +1,3 @@
 function main() {
-	Foo.test;
+	Foo.test();
 }

+ 1 - 1
tests/server/test/templates/issues/Issue12001/Main1.hx

@@ -1,3 +1,3 @@
 function main() {
-	Bar.test;
+	Bar.test();
 }

+ 0 - 3
tests/server/test/templates/issues/Issue12001/Main2.hx

@@ -1,3 +0,0 @@
-function main() {
-	Foobar.test();
-}