-
Notifications
You must be signed in to change notification settings - Fork 0
/
warbler.wren
56 lines (44 loc) · 1.09 KB
/
warbler.wren
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
class Test {
construct new(unitTitle) {
System.print("Testing %(unitTitle).")
_title = unitTitle
}
assert { true }
assert(actual, expected) {
if (actual != expected) {
System.print("FAIL: %(actual) was not %(expected) in %(_title).")
} else {
System.print("GREAT SUCCESS")
}
}
assert(actual, expected, message) {
if (actual != expected) {
System.print("FAIL: %(message)")
} else {
System.print("GREAT SUCCESS: %(message)")
}
}
assertListEqual(xs, ys, message) {
var equal = true
var i = 0
if (xs.count != ys.count) {
System.print("FAIL: %(xs) and %(ys) are not equal or even the same length after %(message)!")
return false
}
while (equal && i < xs.count) {
if (xs[i] != ys[i]) {
equal = false
}
i = i + 1
}
if (equal) {
System.print("GREAT SUCCESS: %(message)")
} else {
System.print("FAIL: %(xs) does not equal %(ys). %(message)")
}
}
describe(description, specs) {
System.print("Describe: %(description)")
specs.call()
}
}