Skip to content

Commit 067c8c3

Browse files
committed
[tests] update tests
1 parent 664a10b commit 067c8c3

File tree

5 files changed

+29
-79
lines changed

5 files changed

+29
-79
lines changed

tests/server/src/cases/issues/Issue12001.hx

+20-36
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@ class Issue12001 extends TestCase {
1515
assertSuccess();
1616
}
1717

18-
function testDefineType1(_) {
18+
@:async
19+
@:timeout(3000)
20+
function testRedefineType(async:Async) {
1921
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
2022
vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main.hx"));
21-
var args = ["-main", "Main", "--macro", "Macro.defineType()"];
22-
runHaxe(args);
23-
assertSuccess();
24-
25-
runHaxe(args);
26-
assertSuccess();
27-
assertSkipping("Main", DependencyDirty("Foo - Tainted define_type"));
23+
var args = ["-main", "Main", "--interp", "--macro", "Macro.defineType()"];
24+
var i = 0;
25+
function test() {
26+
// Was failing with nightlies (HxbFailure)
27+
runHaxe(args, () -> {
28+
assertSuccess();
29+
assertHasPrint("Foo.test() = " + i);
30+
if (++i >= 5) async.done();
31+
else test();
32+
});
33+
}
34+
test();
2835
}
2936

3037
function testDefineModule(_) {
@@ -39,48 +46,25 @@ class Issue12001 extends TestCase {
3946
assertSuccess();
4047
}
4148

42-
function testDefineModule1(_) {
43-
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
44-
vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main1.hx"));
45-
var args = ["-main", "Main", "--macro", "Macro.defineModule()"];
46-
runHaxe(args);
47-
assertSuccess();
48-
49-
runHaxe(args);
50-
assertSuccess();
51-
assertSkipping("Main", DependencyDirty("Bar - Tainted define_module"));
52-
}
53-
5449
@:async
5550
@:timeout(3000)
5651
function testRedefineModule(async:Async) {
5752
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
58-
vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main2.hx"));
59-
var args = ["-main", "Main", "--interp", "--macro", "Macro.redefineModule()"];
53+
vfs.putContent("Main.hx", getTemplate("issues/Issue12001/Main1.hx"));
54+
var args = ["-main", "Main", "--interp", "--macro", "Macro.defineModule()"];
6055
var i = 0;
6156
function test() {
57+
// Was failing with nightlies (HxbFailure)
6258
runHaxe(args, () -> {
6359
assertSuccess();
64-
assertHasPrint("Foobar.test() = " + i);
60+
assertHasPrint("Bar.test() = " + i);
6561
if (++i >= 5) async.done();
6662
else test();
6763
});
6864
}
6965
test();
7066
}
7167

72-
function testAfterTyping(_) {
73-
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
74-
vfs.putContent("Empty.hx", getTemplate("Empty.hx"));
75-
var args = ["-main", "Empty", "--macro", "Macro.hook()"];
76-
runHaxe(args);
77-
assertSuccess();
78-
79-
// Nothing is loading Baz, so it can be defined again
80-
runHaxe(args);
81-
assertSuccess();
82-
}
83-
8468
@:async
8569
@:timeout(3000)
8670
function testRedefineAfterTyping(async:Async) {
@@ -92,7 +76,7 @@ class Issue12001 extends TestCase {
9276
runHaxe(args, () -> {
9377
assertSuccess();
9478
// Newest version is being included
95-
assertHasPrint("Foobaz.test() = " + i);
79+
assertHasPrint("Baz.test() = " + i);
9680
if (++i >= 5) async.done();
9781
else test();
9882
});

tests/server/test/templates/issues/Issue12001/Macro.hx

+7-38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import haxe.macro.Context;
22

3+
@:persistent var i = 0;
34
function defineType() {
45
Context.onAfterInitMacros(() -> {
56
Context.defineType({
@@ -8,12 +9,13 @@ function defineType() {
89
name: "Foo",
910
kind: TDClass(null, null, false, false, false),
1011
fields: (macro class Foo {
11-
public static function test() {}
12+
public static function test() Sys.println("Foo.test() = " + $v{i++});
1213
}).fields
1314
});
1415
});
1516
}
1617

18+
@:persistent var j = 0;
1719
function defineModule() {
1820
Context.onAfterInitMacros(() -> {
1921
Context.defineModule("Bar", [{
@@ -22,28 +24,14 @@ function defineModule() {
2224
name: "Bar",
2325
kind: TDClass(null, null, false, false, false),
2426
fields: (macro class Bar {
25-
public static function test() {}
26-
}).fields
27-
}]);
28-
});
29-
}
30-
31-
@:persistent var i = 0;
32-
function redefineModule() {
33-
Context.onAfterInitMacros(() -> {
34-
Context.defineModule("Foobar", [{
35-
pos: Context.currentPos(),
36-
pack: [],
37-
name: "Foobar",
38-
kind: TDClass(null, null, false, false, false),
39-
fields: (macro class Foobar {
40-
public static function test() Sys.println("Foobar.test() = " + $v{i++});
27+
public static function test() Sys.println("Bar.test() = " + $v{j++});
4128
}).fields
4229
}]);
4330
});
4431
}
4532

46-
function hook() {
33+
@:persistent var k = 0;
34+
function hookRedefine() {
4735
var generated = false;
4836
Context.onAfterTyping((_) -> {
4937
if (generated) return;
@@ -55,26 +43,7 @@ function hook() {
5543
name: "Baz",
5644
kind: TDClass(null, null, false, false, false),
5745
fields: (macro class Baz {
58-
public static function test() {}
59-
}).fields
60-
}]);
61-
});
62-
}
63-
64-
@:persistent var j = 0;
65-
function hookRedefine() {
66-
var generated = false;
67-
Context.onAfterTyping((_) -> {
68-
if (generated) return;
69-
generated = true;
70-
71-
Context.defineModule("Foobaz", [{
72-
pos: Context.currentPos(),
73-
pack: [],
74-
name: "Foobaz",
75-
kind: TDClass(null, null, false, false, false),
76-
fields: (macro class Foobaz {
77-
public static function __init__() Sys.println("Foobaz.test() = " + $v{j++});
46+
public static function __init__() Sys.println("Baz.test() = " + $v{k++});
7847
}).fields
7948
}]);
8049
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function main() {
2-
Foo.test;
2+
Foo.test();
33
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function main() {
2-
Bar.test;
2+
Bar.test();
33
}

tests/server/test/templates/issues/Issue12001/Main2.hx

-3
This file was deleted.

0 commit comments

Comments
 (0)