-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforsp_test.odin
108 lines (101 loc) · 3.8 KB
/
forsp_test.odin
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
package forsp
import "core:testing"
@(test)
test_is :: proc(t: ^testing.T) {
{
obj := obj_new()
defer free(obj)
ok := is(obj, Nil)
testing.expect(t, ok, "Expected is(Nil) to be true with Nil Obj")
ok = is(obj, Atom)
testing.expect(t, !ok, "Expected is(Atom) to be false with Nil Obj")
ok = is(obj, Number)
testing.expect(t, !ok, "Expected is(Number) to be false with Nil Obj")
ok = is(obj, Pair)
testing.expect(t, !ok, "Expected is(Pair) to be false with Nil Obj")
ok = is(obj, Closure)
testing.expect(t, !ok, "Expected is(Closure) to be false with Nil Obj")
ok = is(obj, Primitive)
testing.expect(t, !ok, "Expected is(Primitive) to be false with Nil Obj")
}
{
obj := obj_new("test")
defer free(obj)
ok := is(obj, Nil)
testing.expect(t, !ok, "Expected is(Nil) to be true with Atom Obj")
ok = is(obj, Atom)
testing.expect(t, ok, "Expected is(Atom) to be false with Atom Obj")
ok = is(obj, Number)
testing.expect(t, !ok, "Expected is(Number) to be false with Atom Obj")
ok = is(obj, Pair)
testing.expect(t, !ok, "Expected is(Pair) to be false with Atom Obj")
ok = is(obj, Closure)
testing.expect(t, !ok, "Expected is(Closure) to be false with Atom Obj")
ok = is(obj, Primitive)
testing.expect(t, !ok, "Expected is(Primitive) to be false with Atom Obj")
}
{
obj := obj_new(5)
defer free(obj)
ok := is(obj, Nil)
testing.expect(t, !ok, "Expected is(Nil) to be true with Number Obj")
ok = is(obj, Atom)
testing.expect(t, !ok, "Expected is(Atom) to be false with Number Obj")
ok = is(obj, Number)
testing.expect(t, ok, "Expected is(Number) to be false with Number Obj")
ok = is(obj, Pair)
testing.expect(t, !ok, "Expected is(Pair) to be false with Number Obj")
ok = is(obj, Closure)
testing.expect(t, !ok, "Expected is(Closure) to be false with Number Obj")
ok = is(obj, Primitive)
testing.expect(t, !ok, "Expected is(Primitive) to be false with Number Obj")
}
{
obj := obj_new(Pair{})
defer free(obj)
ok := is(obj, Nil)
testing.expect(t, !ok, "Expected is(Nil) to be true with Pair Obj")
ok = is(obj, Atom)
testing.expect(t, !ok, "Expected is(Atom) to be false with Pair Obj")
ok = is(obj, Number)
testing.expect(t, !ok, "Expected is(Number) to be false with Pair Obj")
ok = is(obj, Pair)
testing.expect(t, ok, "Expected is(Pair) to be false with Pair Obj")
ok = is(obj, Closure)
testing.expect(t, !ok, "Expected is(Closure) to be false with Pair Obj")
ok = is(obj, Primitive)
testing.expect(t, !ok, "Expected is(Primitive) to be false with Pair Obj")
}
{
obj := obj_new(Closure{})
defer free(obj)
ok := is(obj, Nil)
testing.expect(t, !ok, "Expected is(Nil) to be true with Closure Obj")
ok = is(obj, Atom)
testing.expect(t, !ok, "Expected is(Atom) to be false with Closure Obj")
ok = is(obj, Number)
testing.expect(t, !ok, "Expected is(Number) to be false with Closure Obj")
ok = is(obj, Pair)
testing.expect(t, !ok, "Expected is(Pair) to be false with Closure Obj")
ok = is(obj, Closure)
testing.expect(t, ok, "Expected is(Closure) to be false with Closure Obj")
ok = is(obj, Primitive)
testing.expect(t, !ok, "Expected is(Primitive) to be false with Closure Obj")
}
{
obj := obj_new(proc(env: ^^Obj) {})
defer free(obj)
ok := is(obj, Nil)
testing.expect(t, !ok, "Expected is(Nil) to be true with Primitive Obj")
ok = is(obj, Atom)
testing.expect(t, !ok, "Expected is(Atom) to be false with Primitive Obj")
ok = is(obj, Number)
testing.expect(t, !ok, "Expected is(Number) to be false with Primitive Obj")
ok = is(obj, Pair)
testing.expect(t, !ok, "Expected is(Pair) to be false with Primitive Obj")
ok = is(obj, Closure)
testing.expect(t, !ok, "Expected is(Closure) to be false with Primitive Obj")
ok = is(obj, Primitive)
testing.expect(t, ok, "Expected is(Primitive) to be false with Primitive Obj")
}
}