-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.hx
More file actions
134 lines (114 loc) · 2.91 KB
/
Main.hx
File metadata and controls
134 lines (114 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package;
using Std;
class Main {
// Assert fields
var _passed:Int = 0;
var _failed:Int = 0;
var _section:String = "";
public static function main() {
new Main();
}
public function new() {
new ArrayTests(this).run();
new StringTests(this).run();
new MathTests(this).run();
new StringToolsTests(this).run();
new XmlTests(this).run();
new JsonTests(this).run();
new JsonPrinterTests(this).run();
new BytesTests(this).run();
new SerializerTests(this).run();
new CryptoTests(this).run();
new CallStackTests(this).run();
new MetaTests(this).run();
new SysTests(this).run();
new LanguageTests(this).run();
new MapTests(this).run();
new DateTests(this).run();
new DateToolsTests(this).run();
new TimerTests(this).run();
new ReflectTests(this).run();
new LambdaTests(this).run();
new TypeTests(this).run();
new ListTests(this).run();
new ERegTests(this).run();
new StringBufTests(this).run();
new ExceptionTests(this).run();
new HttpTests(this).run();
report();
}
// --- Assert helpers ---
public function section(name:String):Void {
_section = name;
Sys.println('TESTING -> $name: Success');
}
public function isTrue(actual:Dynamic, msg:String):Void {
if (actual == true)
_passed++;
else {
_failed++;
Sys.println("[FAIL] " + _section + " > " + msg);
}
}
public function isFalse(actual:Dynamic, msg:String):Void {
if (actual == false)
_passed++;
else {
_failed++;
Sys.println("[FAIL] " + _section + " > " + msg + " (expected false)");
}
}
public function stringEquals(expected:String, actual:String, msg:String):Void {
if (expected == actual)
_passed++;
else {
_failed++;
Sys.println("[FAIL] " + _section + " > " + msg + " | expected: '" + expected + "' | got: '" + actual + "'");
}
}
public function intEquals(expected:Int, actual:Int, msg:String):Void {
if (expected == actual)
_passed++;
else {
_failed++;
Sys.println("[FAIL] " + _section + " > " + msg + " | expected " + expected + ", got " + actual);
}
}
public function floatNear(expected:Float, actual:Float, msg:String):Void {
var diff = expected - actual;
if (diff < 0)
diff = -diff;
if (diff < 0.001)
_passed++;
else {
_failed++;
Sys.println("[FAIL] " + _section + " > " + msg + " | expected " + expected + ", got " + actual);
}
}
public function report():Void {
var total = _passed + _failed;
Sys.println("==========================================");
Sys.println("TEST RESULTS: " + _passed + "/" + total + " passed");
if (_failed > 0)
Sys.println("FAILURES: " + _failed);
else
Sys.println("ALL TESTS PASSED");
Sys.println("==========================================");
}
}
class MapKey {
public var id:Int;
public function new(val:Int) {
this.id = val;
}
}
enum Colors {
Red;
Green;
Blue;
}
enum abstract ColorValues(Int) from Int to Int {
final Red = 0xff0000;
final Green = 0x00ff00;
final Blue = 0x0000ff;
}