/
core_spec.ik
234 lines (195 loc) · 5.37 KB
/
core_spec.ik
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
use("ispec")
describe("nil",
it("should have the correct kind",
nil should have kind("nil")
)
it("should not be possible to mimic",
fn(nil mimic) should signal(Condition Error CantMimicOddball)
)
it("should act as false in if statement",
if(nil, 42, 43) should == 43
)
it("should be nil",
nil should == nil
)
)
describe("false",
it("should have the correct kind",
false should have kind("false")
)
it("should not be possible to mimic",
fn(false mimic) should signal(Condition Error CantMimicOddball)
)
it("should act as false in if statement",
if(false, 42, 43) should == 43
)
it("should not be nil",
false should not == nil
)
)
describe("true",
it("should have the correct kind",
true should have kind("true")
)
it("should not be possible to mimic",
fn(true mimic) should signal(Condition Error CantMimicOddball)
)
it("should act as true in if statement",
if(true, 42, 43) should == 42
)
it("should not be nil",
true should not == nil
)
)
describe("Base",
it("should have the correct kind",
Base kind should == "Base"
)
it("should have a 'mimic' cell",
Base cell?(:mimic) should == true
)
)
describe("Ground",
it("should have the correct kind",
Ground should have kind("Ground")
)
it("should have all the expected cells",
Ground should have cell(:Base)
Ground should have cell(:DefaultBehavior)
Ground should have cell(:Ground)
Ground should have cell(:Origin)
Ground should have cell(:System)
Ground should have cell(:Runtime)
Ground should have cell(:Text)
Ground should have cell(:Number)
Ground should have cell(:nil)
Ground should have cell(:true)
Ground should have cell(:false)
Ground should have cell(:Method)
Ground should have cell(:DefaultMethod)
Ground should have cell(:JavaMethod)
Ground should have cell(:Symbol)
Ground should have cell(:LexicalBlock)
Ground should have cell(:Mixins)
Ground should have cell(:Restart)
Ground should have cell(:List)
Ground should have cell(:Dict)
Ground should have cell(:Set)
Ground should have cell(:Pair)
Ground should have cell(:DefaultMacro)
Ground should have cell(:Call)
Ground should have cell(:Range)
Ground should have cell(:Condition)
Ground should have cell(:Rescue)
Ground should have cell(:Handler)
Ground should have cell(:IO)
)
)
describe("System",
it("should have the correct kind",
System should have kind("System")
)
; describe("ifMain",
; it("should run block when the currently running code is the main",
; runtime = IokeRuntime.get_runtime
; runtime.system.data.current_program = "<eval>"
; runtime.evaluate_stream("<eval>", StringReader.new("System ifMain(xx = 42)"), runtime.message, runtime.ground)
; runtime.ground.find_cell(nil, nil, "xx").data.as_java_integer.should == 42
; )
; it("should not run block when the currently running code is not the main",
; runtime = IokeRuntime.get_runtime
; runtime.system.data.current_program = "<eval>"
; runtime.evaluate_stream("<eval2>", StringReader.new("System ifMain(xx = 42)"), runtime.message, runtime.ground)
; runtime.ground.find_cell(nil, nil, "xx").should == runtime.nul
; )
; )
it("should be possible to mimic system",
System mimic
)
)
describe("Runtime",
it("should have the correct kind",
Runtime should have kind("Runtime")
)
)
describe("DefaultBehavior",
it("should have the correct kind",
DefaultBehavior kind should == "DefaultBehavior"
)
)
describe("Call",
it("should have the correct kind",
Call should have kind("Call")
)
)
describe("Origin",
it("should have the correct kind",
Origin should have kind("Origin")
)
)
describe("Text",
it("should have the correct kind",
Text should have kind("Text")
)
)
describe("Range",
it("should have the correct kind",
Range should have kind("Range")
)
)
describe("Method",
it("should have the correct kind",
cell(:Method) kind should == "Method"
)
)
describe("DefaultMethod",
it("should have the correct kind",
cell(:DefaultMethod) kind should == "DefaultMethod"
)
)
describe("DefaultMacro",
it("should have the correct kind",
cell(:DefaultMacro) kind should == "DefaultMacro"
)
)
describe("JavaMethod",
it("should have the correct kind",
cell(:JavaMethod) kind should == "JavaMethod"
)
)
describe("LexicalBlock",
it("should have the correct kind",
LexicalBlock should have kind("LexicalBlock")
)
)
describe("Mixins",
it("should have the correct kind",
Mixins kind should == "Mixins"
)
it("should have Comparing defined",
Mixins cell?(:Comparing) should == true
)
it("should have Enumerable defined",
Mixins cell?(:Enumerable) should == true
)
describe("Enumerable",
it("should have the correct kind",
Mixins Enumerable kind should == "Mixins Enumerable"
)
)
describe("Comparing",
it("should have the correct kind",
Mixins Comparing kind should == "Mixins Comparing"
)
)
)
describe("Message",
it("should have the correct kind",
Message should have kind("Message")
)
)
describe("Condition",
it("should have the correct kind",
Condition should have kind("Condition")
)
)