resin 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -0
- data/amber/bin/nodecompile.js +3 -3
- data/amber/css/amber.css +47 -23
- data/amber/images/off.amber.png +0 -0
- data/amber/images/offHover.amber.png +0 -0
- data/amber/images/sprite.amber.png +0 -0
- data/amber/images/tinylogo.amber.png +0 -0
- data/amber/js/Benchfib.deploy.js +34 -34
- data/amber/js/Benchfib.js +49 -49
- data/amber/js/Canvas.deploy.js +937 -937
- data/amber/js/Canvas.js +1622 -1622
- data/amber/js/Compiler-Tests.deploy.js +97 -0
- data/amber/js/Compiler-Tests.js +137 -0
- data/amber/js/Compiler.deploy.js +1030 -924
- data/amber/js/Compiler.js +1613 -1467
- data/amber/js/Documentation.deploy.js +417 -417
- data/amber/js/Documentation.js +728 -728
- data/amber/js/Examples.deploy.js +24 -13
- data/amber/js/Examples.js +36 -19
- data/amber/js/IDE.deploy.js +1583 -1527
- data/amber/js/IDE.js +2586 -2510
- data/amber/js/Kernel-Announcements.deploy.js +19 -19
- data/amber/js/Kernel-Announcements.js +28 -28
- data/amber/js/Kernel-Classes.deploy.js +332 -229
- data/amber/js/Kernel-Classes.js +532 -384
- data/amber/js/Kernel-Collections.deploy.js +1516 -1712
- data/amber/js/Kernel-Collections.js +2436 -2712
- data/amber/js/Kernel-Exceptions.deploy.js +85 -62
- data/amber/js/Kernel-Exceptions.js +131 -98
- data/amber/js/Kernel-Methods.deploy.js +326 -378
- data/amber/js/Kernel-Methods.js +473 -525
- data/amber/js/Kernel-Objects.deploy.js +1777 -2428
- data/amber/js/Kernel-Objects.js +2599 -3426
- data/amber/js/Kernel-Tests.deploy.js +871 -772
- data/amber/js/Kernel-Tests.js +1207 -1083
- data/amber/js/Kernel-Transcript.deploy.js +57 -57
- data/amber/js/Kernel-Transcript.js +94 -94
- data/amber/js/SUnit.deploy.js +116 -116
- data/amber/js/SUnit.js +211 -211
- data/amber/js/amber.js +10 -11
- data/amber/js/boot.js +132 -156
- data/amber/js/init.js +2 -2
- data/amber/js/parser.js +2095 -3014
- data/amber/js/parser.pegjs +1 -1
- data/amber/st/Benchfib.st +22 -22
- data/amber/st/Canvas.st +471 -471
- data/amber/st/Compiler-Tests.st +471 -0
- data/amber/st/Compiler.st +858 -794
- data/amber/st/Examples.st +22 -5
- data/amber/st/IDE.st +1326 -1291
- data/amber/st/Kernel-Announcements.st +2 -2
- data/amber/st/Kernel-Classes.st +148 -90
- data/amber/st/Kernel-Collections.st +950 -1061
- data/amber/st/Kernel-Exceptions.st +33 -25
- data/amber/st/Kernel-Methods.st +151 -151
- data/amber/st/Kernel-Objects.st +891 -1036
- data/amber/st/Kernel-Tests.st +622 -544
- data/amber/st/Kernel-Transcript.st +38 -38
- data/amber/st/SUnit.st +53 -53
- metadata +27 -20
data/amber/st/Kernel-Tests.st
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
Smalltalk current createPackage: 'Kernel-Tests' properties: #{}!
|
2
2
|
TestCase subclass: #ArrayTest
|
3
3
|
instanceVariableNames: ''
|
4
|
-
|
4
|
+
package: 'Kernel-Tests'!
|
5
5
|
|
6
6
|
!ArrayTest methodsFor: 'testing'!
|
7
7
|
|
8
|
+
testAtIfAbsent
|
9
|
+
| array |
|
10
|
+
array := #('hello' 'world').
|
11
|
+
self assert: (array at: 1) equals: 'hello'.
|
12
|
+
self assert: (array at: 2) equals: 'world'.
|
13
|
+
self assert: (array at: 2 ifAbsent: ['not found']) equals: 'world'.
|
14
|
+
self assert: (array at: 0 ifAbsent: ['not found']) equals: 'not found'.
|
15
|
+
self assert: (array at: -10 ifAbsent: ['not found']) equals: 'not found'.
|
16
|
+
self assert: (array at: 3 ifAbsent: ['not found']) equals: 'not found'.
|
17
|
+
!
|
18
|
+
|
8
19
|
testFirstN
|
9
20
|
self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).
|
10
21
|
!
|
@@ -13,84 +24,211 @@ testIfEmpty
|
|
13
24
|
self assert: 'zork' equals: ( '' ifEmpty: ['zork'] )
|
14
25
|
! !
|
15
26
|
|
16
|
-
TestCase subclass: #
|
27
|
+
TestCase subclass: #BlockClosureTest
|
17
28
|
instanceVariableNames: ''
|
18
|
-
|
29
|
+
package: 'Kernel-Tests'!
|
19
30
|
|
20
|
-
!
|
31
|
+
!BlockClosureTest methodsFor: 'tests'!
|
21
32
|
|
22
|
-
|
23
|
-
self assert:
|
33
|
+
testCompiledSource
|
34
|
+
self assert: ([1+1] compiledSource includesSubString: 'function')
|
24
35
|
!
|
25
36
|
|
26
|
-
|
27
|
-
self
|
28
|
-
assert: 'hello world'
|
29
|
-
equals: (String streamContents: [:aStream| aStream
|
30
|
-
nextPutAll: 'hello'; space;
|
31
|
-
nextPutAll: 'world'])
|
37
|
+
testEnsure
|
38
|
+
self assert: ([Error new] ensure: [true])
|
32
39
|
!
|
33
40
|
|
34
|
-
|
35
|
-
self assert:
|
36
|
-
self
|
41
|
+
testNumArgs
|
42
|
+
self assert: [] numArgs equals: 0.
|
43
|
+
self assert: [:a :b | ] numArgs equals: 2
|
44
|
+
!
|
45
|
+
|
46
|
+
testOnDo
|
47
|
+
self assert: ([Error new signal] on: Error do: [:ex | true])
|
48
|
+
!
|
49
|
+
|
50
|
+
testValue
|
51
|
+
self assert: ([1+1] value) equals: 2.
|
52
|
+
self assert: ([:x | x +1] value: 2) equals: 3.
|
53
|
+
self assert: ([:x :y | x*y] value: 2 value: 4) equals: 8.
|
54
|
+
|
55
|
+
"Arguments are optional in Amber. This isn't ANSI compliant."
|
56
|
+
|
57
|
+
self assert: ([:a :b :c | 1] value) equals: 1
|
58
|
+
!
|
59
|
+
|
60
|
+
testValueWithPossibleArguments
|
61
|
+
self assert: ([1] valueWithPossibleArguments: #(3 4)) equals: 1.
|
62
|
+
self assert: ([:a | a + 4] valueWithPossibleArguments: #(3 4)) equals: 7.
|
63
|
+
self assert: ([:a :b | a + b] valueWithPossibleArguments: #(3 4 5)) equals: 7.
|
64
|
+
!
|
65
|
+
|
66
|
+
testWhileFalse
|
67
|
+
| i |
|
68
|
+
i := 0.
|
69
|
+
[i > 5] whileFalse: [i := i + 1].
|
70
|
+
self assert: i equals: 6.
|
71
|
+
|
72
|
+
i := 0.
|
73
|
+
[i := i + 1. i > 5] whileFalse.
|
74
|
+
self assert: i equals: 6
|
37
75
|
!
|
38
76
|
|
77
|
+
testWhileTrue
|
78
|
+
| i |
|
79
|
+
i := 0.
|
80
|
+
[i < 5] whileTrue: [i := i + 1].
|
81
|
+
self assert: i equals: 5.
|
82
|
+
|
83
|
+
i := 0.
|
84
|
+
[i := i + 1. i < 5] whileTrue.
|
85
|
+
self assert: i equals: 5
|
86
|
+
! !
|
87
|
+
|
88
|
+
TestCase subclass: #BooleanTest
|
89
|
+
instanceVariableNames: ''
|
90
|
+
package: 'Kernel-Tests'!
|
91
|
+
|
92
|
+
!BooleanTest methodsFor: 'tests'!
|
93
|
+
|
39
94
|
testEquality
|
40
|
-
|
41
|
-
self deny: 'hello' = 'world'.
|
95
|
+
"We're on top of JS...just be sure to check the basics!!"
|
42
96
|
|
43
|
-
self
|
44
|
-
self
|
97
|
+
self deny: 0 = false.
|
98
|
+
self deny: false = 0.
|
99
|
+
self deny: '' = false.
|
100
|
+
self deny: false = ''.
|
45
101
|
|
46
|
-
|
47
|
-
self deny:
|
102
|
+
self assert: true = true.
|
103
|
+
self deny: false = true.
|
104
|
+
self deny: true = false.
|
105
|
+
self assert: false = false.
|
106
|
+
|
107
|
+
"JS may do some type coercing after sending a message"
|
108
|
+
self assert: true yourself = true.
|
109
|
+
self assert: true yourself = true yourself
|
48
110
|
!
|
49
111
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
112
|
+
testIdentity
|
113
|
+
"We're on top of JS...just be sure to check the basics!!"
|
114
|
+
|
115
|
+
self deny: 0 == false.
|
116
|
+
self deny: false == 0.
|
117
|
+
self deny: '' == false.
|
118
|
+
self deny: false == ''.
|
119
|
+
|
120
|
+
self assert: true == true.
|
121
|
+
self deny: false == true.
|
122
|
+
self deny: true == false.
|
123
|
+
self assert: false == false.
|
124
|
+
|
125
|
+
"JS may do some type coercing after sending a message"
|
126
|
+
self assert: true yourself == true.
|
127
|
+
self assert: true yourself == true yourself
|
54
128
|
!
|
55
129
|
|
56
|
-
|
57
|
-
|
58
|
-
self assert: (
|
59
|
-
self assert: (
|
130
|
+
testIfTrueIfFalse
|
131
|
+
|
132
|
+
self assert: (true ifTrue: ['alternative block']) = 'alternative block'.
|
133
|
+
self assert: (true ifFalse: ['alternative block']) = nil.
|
134
|
+
|
135
|
+
self assert: (false ifTrue: ['alternative block']) = nil.
|
136
|
+
self assert: (false ifFalse: ['alternative block']) = 'alternative block'.
|
137
|
+
|
138
|
+
self assert: (false ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.
|
139
|
+
self assert: (false ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.
|
140
|
+
|
141
|
+
self assert: (true ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.
|
142
|
+
self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.
|
60
143
|
!
|
61
144
|
|
62
|
-
|
63
|
-
|
64
|
-
|
145
|
+
testLogic
|
146
|
+
|
147
|
+
"Trivial logic table"
|
148
|
+
self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).
|
149
|
+
self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).
|
150
|
+
"Checking that expressions work fine too"
|
151
|
+
self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).
|
152
|
+
self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))
|
65
153
|
!
|
66
154
|
|
67
|
-
|
68
|
-
|
69
|
-
|
155
|
+
testLogicKeywords
|
156
|
+
|
157
|
+
"Trivial logic table"
|
158
|
+
self
|
159
|
+
assert: (true and: [ true]);
|
160
|
+
deny: (true and: [ false ]);
|
161
|
+
deny: (false and: [ true ]);
|
162
|
+
deny: (false and: [ false ]).
|
163
|
+
self
|
164
|
+
assert: (true or: [ true ]);
|
165
|
+
assert: (true or: [ false ]);
|
166
|
+
assert: (false or: [ true ]);
|
167
|
+
deny: (false or: [ false ]).
|
168
|
+
|
169
|
+
"Checking that expressions work fine too"
|
170
|
+
self
|
171
|
+
assert: (true and: [ 1 > 0 ]);
|
172
|
+
deny: ((1 > 0) and: [ false ]);
|
173
|
+
deny: ((1 > 0) and: [ 1 > 2 ]).
|
174
|
+
self
|
175
|
+
assert: (false or: [ 1 > 0 ]);
|
176
|
+
assert: ((1 > 0) or: [ false ]);
|
177
|
+
assert: ((1 > 0) or: [ 1 > 2 ])
|
178
|
+
! !
|
179
|
+
|
180
|
+
TestCase subclass: #ClassBuilderTest
|
181
|
+
instanceVariableNames: 'builder theClass'
|
182
|
+
package: 'Kernel-Tests'!
|
183
|
+
|
184
|
+
!ClassBuilderTest methodsFor: 'running'!
|
185
|
+
|
186
|
+
setUp
|
187
|
+
builder := ClassBuilder new
|
70
188
|
!
|
71
189
|
|
72
|
-
|
73
|
-
|
74
|
-
self should: ['hello' remove: 'h'] raise: Error
|
190
|
+
tearDown
|
191
|
+
theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]
|
75
192
|
!
|
76
193
|
|
77
|
-
|
78
|
-
|
194
|
+
testClassCopy
|
195
|
+
theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
|
196
|
+
self assert: theClass superclass == ObjectMock superclass.
|
197
|
+
self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.
|
198
|
+
self assert: theClass name equals: 'ObjectMock2'.
|
199
|
+
self assert: theClass package == ObjectMock package.
|
200
|
+
self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys
|
201
|
+
!
|
202
|
+
|
203
|
+
testInstanceVariableNames
|
204
|
+
self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')
|
79
205
|
! !
|
80
206
|
|
81
207
|
TestCase subclass: #DictionaryTest
|
82
208
|
instanceVariableNames: ''
|
83
|
-
|
209
|
+
package: 'Kernel-Tests'!
|
84
210
|
|
85
211
|
!DictionaryTest methodsFor: 'tests'!
|
86
212
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
213
|
+
testAccessing
|
214
|
+
| d |
|
215
|
+
|
216
|
+
d := Dictionary new.
|
217
|
+
|
218
|
+
d at: 'hello' put: 'world'.
|
219
|
+
self assert: (d at: 'hello') = 'world'.
|
220
|
+
self assert: (d at: 'hello' ifAbsent: [nil]) = 'world'.
|
221
|
+
self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.
|
222
|
+
|
223
|
+
d at: 1 put: 2.
|
224
|
+
self assert: (d at: 1) = 2.
|
225
|
+
|
226
|
+
d at: 1@3 put: 3.
|
227
|
+
self assert: (d at: 1@3) = 3
|
228
|
+
!
|
229
|
+
|
230
|
+
testDynamicDictionaries
|
231
|
+
self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)
|
94
232
|
!
|
95
233
|
|
96
234
|
testEquality
|
@@ -112,25 +250,60 @@ testEquality
|
|
112
250
|
self deny: d1 = d2.
|
113
251
|
!
|
114
252
|
|
115
|
-
|
116
|
-
self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)
|
117
|
-
!
|
118
|
-
|
119
|
-
testAccessing
|
253
|
+
testKeys
|
120
254
|
| d |
|
121
255
|
|
122
256
|
d := Dictionary new.
|
257
|
+
d at: 1 put: 2.
|
258
|
+
d at: 2 put: 3.
|
259
|
+
d at: 3 put: 4.
|
123
260
|
|
124
|
-
|
125
|
-
|
126
|
-
self assert: (d at: 'hello' ifAbsent: [nil]) = 'world'.
|
127
|
-
self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.
|
261
|
+
self assert: d keys = #(1 2 3)
|
262
|
+
!
|
128
263
|
|
129
|
-
|
130
|
-
self
|
264
|
+
testPrintString
|
265
|
+
self
|
266
|
+
assert: 'a Dictionary(''firstname'' -> ''James'' , ''lastname'' -> ''Bond'')'
|
267
|
+
equals: (Dictionary new
|
268
|
+
at:'firstname' put: 'James';
|
269
|
+
at:'lastname' put: 'Bond';
|
270
|
+
printString)
|
271
|
+
!
|
131
272
|
|
132
|
-
|
133
|
-
|
273
|
+
testRemoveKey
|
274
|
+
| d key |
|
275
|
+
|
276
|
+
d := Dictionary new.
|
277
|
+
d at: 1 put: 2.
|
278
|
+
d at: 2 put: 3.
|
279
|
+
d at: 3 put: 4.
|
280
|
+
|
281
|
+
key := 2.
|
282
|
+
|
283
|
+
self assert: d keys = #(1 2 3).
|
284
|
+
|
285
|
+
d removeKey: key.
|
286
|
+
self assert: d keys = #(1 3).
|
287
|
+
self assert: d values = #(2 4).
|
288
|
+
self deny: (d includesKey: 2)
|
289
|
+
!
|
290
|
+
|
291
|
+
testRemoveKeyIfAbsent
|
292
|
+
| d key |
|
293
|
+
|
294
|
+
d := Dictionary new.
|
295
|
+
d at: 1 put: 2.
|
296
|
+
d at: 2 put: 3.
|
297
|
+
d at: 3 put: 4.
|
298
|
+
|
299
|
+
key := 2.
|
300
|
+
self assert: (d removeKey: key) = 3.
|
301
|
+
|
302
|
+
key := 3.
|
303
|
+
self assert: (d removeKey: key ifAbsent: [42]) = 4.
|
304
|
+
|
305
|
+
key := 'why'.
|
306
|
+
self assert: (d removeKey: key ifAbsent: [42] ) = 42.
|
134
307
|
!
|
135
308
|
|
136
309
|
testSize
|
@@ -155,130 +328,71 @@ testValues
|
|
155
328
|
d at: 3 put: 4.
|
156
329
|
|
157
330
|
self assert: d values = #(2 3 4)
|
158
|
-
!
|
331
|
+
! !
|
159
332
|
|
160
|
-
|
161
|
-
|
333
|
+
TestCase subclass: #JSObjectProxyTest
|
334
|
+
instanceVariableNames: ''
|
335
|
+
package: 'Kernel-Tests'!
|
162
336
|
|
163
|
-
|
164
|
-
d at: 1 put: 2.
|
165
|
-
d at: 2 put: 3.
|
166
|
-
d at: 3 put: 4.
|
337
|
+
!JSObjectProxyTest methodsFor: 'accessing'!
|
167
338
|
|
168
|
-
|
339
|
+
jsObject
|
340
|
+
<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}}>
|
169
341
|
! !
|
170
342
|
|
171
|
-
|
172
|
-
instanceVariableNames: ''
|
173
|
-
category: 'Kernel-Tests'!
|
174
|
-
|
175
|
-
!BooleanTest methodsFor: 'tests'!
|
343
|
+
!JSObjectProxyTest methodsFor: 'tests'!
|
176
344
|
|
177
|
-
|
178
|
-
|
179
|
-
"Trivial logic table"
|
180
|
-
self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).
|
181
|
-
self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).
|
182
|
-
"Checking that expressions work fine too"
|
183
|
-
self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).
|
184
|
-
self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))
|
345
|
+
testDNU
|
346
|
+
self should: [self jsObject foo] raise: MessageNotUnderstood
|
185
347
|
!
|
186
348
|
|
187
|
-
|
188
|
-
"We're on top of JS...just be sure to check the basics!!"
|
349
|
+
testMessageSend
|
189
350
|
|
190
|
-
self
|
191
|
-
self
|
192
|
-
self
|
193
|
-
|
351
|
+
self assert: self jsObject a equals: 1.
|
352
|
+
self assert: self jsObject b equals: 2.
|
353
|
+
self assert: (self jsObject c: 3) equals: 3
|
354
|
+
!
|
194
355
|
|
195
|
-
|
196
|
-
self deny:
|
197
|
-
self deny: true = false.
|
198
|
-
self assert: false = false.
|
356
|
+
testMethodWithArguments
|
357
|
+
self deny: ('body' asJQuery hasClass: 'amber').
|
199
358
|
|
200
|
-
|
201
|
-
self assert:
|
202
|
-
|
359
|
+
'body' asJQuery addClass: 'amber'.
|
360
|
+
self assert: ('body' asJQuery hasClass: 'amber').
|
361
|
+
|
362
|
+
'body' asJQuery removeClass: 'amber'.
|
363
|
+
self deny: ('body' asJQuery hasClass: 'amber').
|
203
364
|
!
|
204
365
|
|
205
|
-
|
206
|
-
|
207
|
-
"Trivial logic table"
|
208
|
-
self
|
209
|
-
assert: (true and: [ true]);
|
210
|
-
deny: (true and: [ false ]);
|
211
|
-
deny: (false and: [ true ]);
|
212
|
-
deny: (false and: [ false ]).
|
213
|
-
self
|
214
|
-
assert: (true or: [ true ]);
|
215
|
-
assert: (true or: [ false ]);
|
216
|
-
assert: (false or: [ true ]);
|
217
|
-
deny: (false or: [ false ]).
|
218
|
-
|
219
|
-
"Checking that expressions work fine too"
|
220
|
-
self
|
221
|
-
assert: (true and: [ 1 > 0 ]);
|
222
|
-
deny: ((1 > 0) and: [ false ]);
|
223
|
-
deny: ((1 > 0) and: [ 1 > 2 ]).
|
224
|
-
self
|
225
|
-
assert: (false or: [ 1 > 0 ]);
|
226
|
-
assert: ((1 > 0) or: [ false ]);
|
227
|
-
assert: ((1 > 0) or: [ 1 > 2 ])
|
366
|
+
testPrinting
|
367
|
+
self assert: self jsObject printString = '[object Object]'
|
228
368
|
!
|
229
369
|
|
230
|
-
|
231
|
-
|
232
|
-
self assert:
|
233
|
-
self assert: (true ifFalse: ['alternative block']) = nil.
|
370
|
+
testPropertyThatReturnsEmptyString
|
371
|
+
<document.location.hash = ''>.
|
372
|
+
self assert: '' equals: document location hash.
|
234
373
|
|
235
|
-
|
236
|
-
self assert:
|
374
|
+
document location hash: 'test'.
|
375
|
+
self assert: '#test' equals: document location hash.
|
376
|
+
!
|
237
377
|
|
238
|
-
|
239
|
-
|
378
|
+
testYourself
|
379
|
+
|body|
|
380
|
+
body := 'body' asJQuery
|
381
|
+
addClass: 'amber';
|
382
|
+
yourself.
|
240
383
|
|
241
|
-
self assert: (
|
242
|
-
|
384
|
+
self assert: (body hasClass: 'amber').
|
385
|
+
|
386
|
+
body removeClass: 'amber'.
|
387
|
+
self deny: (body hasClass: 'amber').
|
243
388
|
! !
|
244
389
|
|
245
390
|
TestCase subclass: #NumberTest
|
246
391
|
instanceVariableNames: ''
|
247
|
-
|
392
|
+
package: 'Kernel-Tests'!
|
248
393
|
|
249
394
|
!NumberTest methodsFor: 'tests'!
|
250
395
|
|
251
|
-
testPrintShowingDecimalPlaces
|
252
|
-
self assert: '23.00' equals: (23 printShowingDecimalPlaces: 2).
|
253
|
-
self assert: '23.57' equals: (23.5698 printShowingDecimalPlaces: 2).
|
254
|
-
self assert: '-234.56700' equals:( 234.567 negated printShowingDecimalPlaces: 5).
|
255
|
-
self assert: '23' equals: (23.4567 printShowingDecimalPlaces: 0).
|
256
|
-
self assert: '24' equals: (23.5567 printShowingDecimalPlaces: 0).
|
257
|
-
self assert: '-23' equals: (23.4567 negated printShowingDecimalPlaces: 0).
|
258
|
-
self assert: '-24' equals: (23.5567 negated printShowingDecimalPlaces: 0).
|
259
|
-
self assert: '100000000.0' equals: (100000000 printShowingDecimalPlaces: 1).
|
260
|
-
self assert: '0.98000' equals: (0.98 printShowingDecimalPlaces: 5).
|
261
|
-
self assert: '-0.98' equals: (0.98 negated printShowingDecimalPlaces: 2).
|
262
|
-
self assert: '2.57' equals: (2.567 printShowingDecimalPlaces: 2).
|
263
|
-
self assert: '-2.57' equals: (-2.567 printShowingDecimalPlaces: 2).
|
264
|
-
self assert: '0.00' equals: (0 printShowingDecimalPlaces: 2).
|
265
|
-
!
|
266
|
-
|
267
|
-
testEquality
|
268
|
-
self assert: 1 = 1.
|
269
|
-
self assert: 0 = 0.
|
270
|
-
self deny: 1 = 0.
|
271
|
-
|
272
|
-
self assert: 1 yourself = 1.
|
273
|
-
self assert: 1 = 1 yourself.
|
274
|
-
self assert: 1 yourself = 1 yourself.
|
275
|
-
|
276
|
-
self deny: 0 = false.
|
277
|
-
self deny: false = 0.
|
278
|
-
self deny: '' = 0.
|
279
|
-
self deny: 0 = ''
|
280
|
-
!
|
281
|
-
|
282
396
|
testArithmetic
|
283
397
|
|
284
398
|
"We rely on JS here, so we won't test complex behavior, just check if
|
@@ -296,18 +410,6 @@ testArithmetic
|
|
296
410
|
self assert: 1 + (2 * 3) = 7
|
297
411
|
!
|
298
412
|
|
299
|
-
testRounded
|
300
|
-
|
301
|
-
self assert: 3 rounded = 3.
|
302
|
-
self assert: 3.212 rounded = 3.
|
303
|
-
self assert: 3.51 rounded = 4
|
304
|
-
!
|
305
|
-
|
306
|
-
testNegated
|
307
|
-
self assert: 3 negated = -3.
|
308
|
-
self assert: -3 negated = 3
|
309
|
-
!
|
310
|
-
|
311
413
|
testComparison
|
312
414
|
|
313
415
|
self assert: 3 > 2.
|
@@ -322,22 +424,24 @@ testComparison
|
|
322
424
|
self assert: 3 <= 3.1
|
323
425
|
!
|
324
426
|
|
325
|
-
testTruncated
|
326
|
-
|
327
|
-
self assert: 3 truncated = 3.
|
328
|
-
self assert: 3.212 truncated = 3.
|
329
|
-
self assert: 3.51 truncated = 3
|
330
|
-
!
|
331
|
-
|
332
427
|
testCopying
|
333
428
|
self assert: 1 copy == 1.
|
334
429
|
self assert: 1 deepCopy == 1
|
335
430
|
!
|
336
431
|
|
337
|
-
|
432
|
+
testEquality
|
433
|
+
self assert: 1 = 1.
|
434
|
+
self assert: 0 = 0.
|
435
|
+
self deny: 1 = 0.
|
436
|
+
|
437
|
+
self assert: 1 yourself = 1.
|
438
|
+
self assert: 1 = 1 yourself.
|
439
|
+
self assert: 1 yourself = 1 yourself.
|
338
440
|
|
339
|
-
self
|
340
|
-
self
|
441
|
+
self deny: 0 = false.
|
442
|
+
self deny: false = 0.
|
443
|
+
self deny: '' = 0.
|
444
|
+
self deny: 0 = ''
|
341
445
|
!
|
342
446
|
|
343
447
|
testIdentity
|
@@ -352,258 +456,141 @@ testIdentity
|
|
352
456
|
self deny: 1 == 2
|
353
457
|
!
|
354
458
|
|
355
|
-
|
356
|
-
|
357
|
-
self assert: 4 sqrt = 2.
|
358
|
-
self assert: 16 sqrt = 4
|
359
|
-
!
|
360
|
-
|
361
|
-
testSquared
|
459
|
+
testMinMax
|
362
460
|
|
363
|
-
self assert:
|
364
|
-
|
365
|
-
|
366
|
-
testTimesRepeat
|
367
|
-
| i |
|
368
|
-
|
369
|
-
i := 0.
|
370
|
-
0 timesRepeat: [i := i + 1].
|
371
|
-
self assert: i equals: 0.
|
372
|
-
|
373
|
-
5 timesRepeat: [i := i + 1].
|
374
|
-
self assert: i equals: 5
|
375
|
-
!
|
376
|
-
|
377
|
-
testTo
|
378
|
-
self assert: (1 to: 5) equals: #(1 2 3 4 5)
|
379
|
-
!
|
380
|
-
|
381
|
-
testToBy
|
382
|
-
self assert: (0 to: 6 by: 2) equals: #(0 2 4 6).
|
383
|
-
|
384
|
-
self should: [1 to: 4 by: 0] raise: Error
|
385
|
-
! !
|
386
|
-
|
387
|
-
TestCase subclass: #JSObjectProxyTest
|
388
|
-
instanceVariableNames: ''
|
389
|
-
category: 'Kernel-Tests'!
|
390
|
-
|
391
|
-
!JSObjectProxyTest methodsFor: 'accessing'!
|
392
|
-
|
393
|
-
jsObject
|
394
|
-
<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}}>
|
395
|
-
! !
|
396
|
-
|
397
|
-
!JSObjectProxyTest methodsFor: 'tests'!
|
398
|
-
|
399
|
-
testMethodWithArguments
|
400
|
-
self deny: ('body' asJQuery hasClass: 'amber').
|
401
|
-
|
402
|
-
'body' asJQuery addClass: 'amber'.
|
403
|
-
self assert: ('body' asJQuery hasClass: 'amber').
|
404
|
-
|
405
|
-
'body' asJQuery removeClass: 'amber'.
|
406
|
-
self deny: ('body' asJQuery hasClass: 'amber').
|
407
|
-
!
|
408
|
-
|
409
|
-
testYourself
|
410
|
-
|body|
|
411
|
-
body := 'body' asJQuery
|
412
|
-
addClass: 'amber';
|
413
|
-
yourself.
|
414
|
-
|
415
|
-
self assert: (body hasClass: 'amber').
|
416
|
-
|
417
|
-
body removeClass: 'amber'.
|
418
|
-
self deny: (body hasClass: 'amber').
|
419
|
-
!
|
420
|
-
|
421
|
-
testPropertyThatReturnsEmptyString
|
422
|
-
<document.location.hash = ''>.
|
423
|
-
self assert: '' equals: document location hash.
|
424
|
-
|
425
|
-
document location hash: 'test'.
|
426
|
-
self assert: '#test' equals: document location hash.
|
427
|
-
!
|
428
|
-
|
429
|
-
testDNU
|
430
|
-
self should: [self jsObject foo] raise: MessageNotUnderstood
|
431
|
-
!
|
432
|
-
|
433
|
-
testMessageSend
|
434
|
-
|
435
|
-
self assert: self jsObject a equals: 1.
|
436
|
-
self assert: self jsObject b equals: 2.
|
437
|
-
self assert: (self jsObject c: 3) equals: 3
|
438
|
-
!
|
439
|
-
|
440
|
-
testPrinting
|
441
|
-
self assert: self jsObject printString = '[object Object]'
|
442
|
-
! !
|
443
|
-
|
444
|
-
TestCase subclass: #PackageTest
|
445
|
-
instanceVariableNames: 'zorkPackage grulPackage backUpCommitPathJs backUpCommitPathSt'
|
446
|
-
category: 'Kernel-Tests'!
|
447
|
-
|
448
|
-
!PackageTest methodsFor: 'running'!
|
449
|
-
|
450
|
-
setUp
|
451
|
-
backUpCommitPathJs := Package defaultCommitPathJs.
|
452
|
-
backUpCommitPathSt := Package defaultCommitPathSt.
|
453
|
-
|
454
|
-
Package resetCommitPaths.
|
455
|
-
|
456
|
-
zorkPackage := Package new name: 'Zork'.
|
457
|
-
grulPackage := Package new
|
458
|
-
name: 'Grul';
|
459
|
-
commitPathJs: 'server/grul/js';
|
460
|
-
commitPathSt: 'grul/st';
|
461
|
-
yourself
|
462
|
-
!
|
463
|
-
|
464
|
-
tearDown
|
465
|
-
Package
|
466
|
-
defaultCommitPathJs: backUpCommitPathJs;
|
467
|
-
defaultCommitPathSt: backUpCommitPathSt
|
468
|
-
! !
|
469
|
-
|
470
|
-
!PackageTest methodsFor: 'tests'!
|
471
|
-
|
472
|
-
testGrulCommitPathStShouldBeGrulSt
|
473
|
-
self assert: 'grul/st' equals: grulPackage commitPathSt
|
474
|
-
!
|
475
|
-
|
476
|
-
testZorkCommitPathStShouldBeSt
|
477
|
-
self assert: 'st' equals: zorkPackage commitPathSt
|
478
|
-
!
|
479
|
-
|
480
|
-
testZorkCommitPathJsShouldBeJs
|
481
|
-
self assert: 'js' equals: zorkPackage commitPathJs
|
461
|
+
self assert: (2 max: 5) equals: 5.
|
462
|
+
self assert: (2 min: 5) equals: 2
|
482
463
|
!
|
483
464
|
|
484
|
-
|
485
|
-
self assert:
|
486
|
-
|
487
|
-
|
488
|
-
TestCase subclass: #BlockClosureTest
|
489
|
-
instanceVariableNames: ''
|
490
|
-
category: 'Kernel-Tests'!
|
491
|
-
|
492
|
-
!BlockClosureTest methodsFor: 'tests'!
|
493
|
-
|
494
|
-
testValue
|
495
|
-
self assert: ([1+1] value) equals: 2.
|
496
|
-
self assert: ([:x | x +1] value: 2) equals: 3.
|
497
|
-
self assert: ([:x :y | x*y] value: 2 value: 4) equals: 8.
|
498
|
-
|
499
|
-
"Arguments are optional in Amber. This isn't ANSI compliant."
|
500
|
-
|
501
|
-
self assert: ([:a :b :c | 1] value) equals: 1
|
465
|
+
testNegated
|
466
|
+
self assert: 3 negated = -3.
|
467
|
+
self assert: -3 negated = 3
|
502
468
|
!
|
503
469
|
|
504
|
-
|
505
|
-
self assert:
|
470
|
+
testPrintShowingDecimalPlaces
|
471
|
+
self assert: '23.00' equals: (23 printShowingDecimalPlaces: 2).
|
472
|
+
self assert: '23.57' equals: (23.5698 printShowingDecimalPlaces: 2).
|
473
|
+
self assert: '-234.56700' equals:( 234.567 negated printShowingDecimalPlaces: 5).
|
474
|
+
self assert: '23' equals: (23.4567 printShowingDecimalPlaces: 0).
|
475
|
+
self assert: '24' equals: (23.5567 printShowingDecimalPlaces: 0).
|
476
|
+
self assert: '-23' equals: (23.4567 negated printShowingDecimalPlaces: 0).
|
477
|
+
self assert: '-24' equals: (23.5567 negated printShowingDecimalPlaces: 0).
|
478
|
+
self assert: '100000000.0' equals: (100000000 printShowingDecimalPlaces: 1).
|
479
|
+
self assert: '0.98000' equals: (0.98 printShowingDecimalPlaces: 5).
|
480
|
+
self assert: '-0.98' equals: (0.98 negated printShowingDecimalPlaces: 2).
|
481
|
+
self assert: '2.57' equals: (2.567 printShowingDecimalPlaces: 2).
|
482
|
+
self assert: '-2.57' equals: (-2.567 printShowingDecimalPlaces: 2).
|
483
|
+
self assert: '0.00' equals: (0 printShowingDecimalPlaces: 2).
|
506
484
|
!
|
507
485
|
|
508
|
-
|
509
|
-
|
486
|
+
testRounded
|
487
|
+
|
488
|
+
self assert: 3 rounded = 3.
|
489
|
+
self assert: 3.212 rounded = 3.
|
490
|
+
self assert: 3.51 rounded = 4
|
510
491
|
!
|
511
492
|
|
512
|
-
|
513
|
-
|
514
|
-
self assert:
|
493
|
+
testSqrt
|
494
|
+
|
495
|
+
self assert: 4 sqrt = 2.
|
496
|
+
self assert: 16 sqrt = 4
|
515
497
|
!
|
516
498
|
|
517
|
-
|
518
|
-
|
519
|
-
self assert:
|
520
|
-
self assert: ([:a :b | a + b] valueWithPossibleArguments: #(3 4 5)) equals: 7.
|
499
|
+
testSquared
|
500
|
+
|
501
|
+
self assert: 4 squared = 16
|
521
502
|
!
|
522
503
|
|
523
|
-
|
504
|
+
testTimesRepeat
|
524
505
|
| i |
|
525
|
-
i := 0.
|
526
|
-
[i < 5] whileTrue: [i := i + 1].
|
527
|
-
self assert: i equals: 5.
|
528
506
|
|
529
507
|
i := 0.
|
530
|
-
[i := i + 1
|
508
|
+
0 timesRepeat: [i := i + 1].
|
509
|
+
self assert: i equals: 0.
|
510
|
+
|
511
|
+
5 timesRepeat: [i := i + 1].
|
531
512
|
self assert: i equals: 5
|
532
513
|
!
|
533
514
|
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
[i > 5] whileFalse: [i := i + 1].
|
538
|
-
self assert: i equals: 6.
|
515
|
+
testTo
|
516
|
+
self assert: (1 to: 5) equals: #(1 2 3 4 5)
|
517
|
+
!
|
539
518
|
|
540
|
-
|
541
|
-
|
542
|
-
|
519
|
+
testToBy
|
520
|
+
self assert: (0 to: 6 by: 2) equals: #(0 2 4 6).
|
521
|
+
|
522
|
+
self should: [1 to: 4 by: 0] raise: Error
|
543
523
|
!
|
544
524
|
|
545
|
-
|
546
|
-
|
525
|
+
testTruncated
|
526
|
+
|
527
|
+
self assert: 3 truncated = 3.
|
528
|
+
self assert: 3.212 truncated = 3.
|
529
|
+
self assert: 3.51 truncated = 3
|
530
|
+
! !
|
531
|
+
|
532
|
+
Object subclass: #ObjectMock
|
533
|
+
instanceVariableNames: 'foo bar'
|
534
|
+
package: 'Kernel-Tests'!
|
535
|
+
|
536
|
+
!ObjectMock methodsFor: 'not yet classified'!
|
537
|
+
|
538
|
+
foo
|
539
|
+
^foo
|
540
|
+
!
|
541
|
+
|
542
|
+
foo: anObject
|
543
|
+
foo := anObject
|
547
544
|
! !
|
548
545
|
|
549
546
|
TestCase subclass: #ObjectTest
|
550
547
|
instanceVariableNames: ''
|
551
|
-
|
548
|
+
package: 'Kernel-Tests'!
|
552
549
|
|
553
550
|
!ObjectTest methodsFor: 'tests'!
|
554
551
|
|
555
|
-
|
552
|
+
testBasicAccess
|
556
553
|
| o |
|
557
554
|
o := Object new.
|
558
|
-
|
559
|
-
self assert: o
|
560
|
-
self assert: o
|
561
|
-
self assert: o = o yourself
|
555
|
+
o basicAt: 'a' put: 1.
|
556
|
+
self assert: (o basicAt: 'a') equals: 1.
|
557
|
+
self assert: (o basicAt: 'b') equals: nil
|
562
558
|
!
|
563
559
|
|
564
|
-
|
560
|
+
testBasicPerform
|
565
561
|
| o |
|
566
562
|
o := Object new.
|
567
|
-
|
568
|
-
|
563
|
+
o basicAt: 'func' put: ['hello'].
|
564
|
+
o basicAt: 'func2' put: [:a | a + 1].
|
565
|
+
|
566
|
+
self assert: (o basicPerform: 'func') equals: 'hello'.
|
567
|
+
self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4
|
569
568
|
!
|
570
569
|
|
571
|
-
|
572
|
-
self should: [Object new
|
570
|
+
testDNU
|
571
|
+
self should: [Object new foo] raise: MessageNotUnderstood
|
573
572
|
!
|
574
573
|
|
575
|
-
|
574
|
+
testEquality
|
576
575
|
| o |
|
577
576
|
o := Object new.
|
578
|
-
|
579
|
-
self assert:
|
580
|
-
self assert:
|
581
|
-
|
582
|
-
|
583
|
-
testNilUndefined
|
584
|
-
"nil in Smalltalk is the undefined object in JS"
|
585
|
-
|
586
|
-
self assert: nil = undefined
|
577
|
+
self deny: o = Object new.
|
578
|
+
self assert: o = o.
|
579
|
+
self assert: o yourself = o.
|
580
|
+
self assert: o = o yourself
|
587
581
|
!
|
588
582
|
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
o1 := Object new.
|
593
|
-
o2 := Object new.
|
594
|
-
|
595
|
-
self assert: o1 identityHash == o1 identityHash.
|
596
|
-
self deny: o1 identityHash == o2 identityHash
|
583
|
+
testHalt
|
584
|
+
self should: [Object new halt] raise: Error
|
597
585
|
!
|
598
586
|
|
599
|
-
|
587
|
+
testIdentity
|
600
588
|
| o |
|
601
589
|
o := Object new.
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
self assert:
|
606
|
-
self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4
|
590
|
+
self deny: o == Object new.
|
591
|
+
self assert: o == o.
|
592
|
+
self assert: o yourself == o.
|
593
|
+
self assert: o == o yourself
|
607
594
|
!
|
608
595
|
|
609
596
|
testIfNil
|
@@ -625,134 +612,113 @@ testInstVars
|
|
625
612
|
self assert: (o instVarAt: 'foo') equals: 1
|
626
613
|
!
|
627
614
|
|
615
|
+
testNilUndefined
|
616
|
+
"nil in Smalltalk is the undefined object in JS"
|
617
|
+
|
618
|
+
self assert: nil = undefined
|
619
|
+
!
|
620
|
+
|
628
621
|
testYourself
|
629
622
|
| o |
|
630
623
|
o := ObjectMock new.
|
631
624
|
self assert: o yourself == o
|
632
625
|
!
|
633
626
|
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
instanceVariableNames: ''
|
640
|
-
category: 'Kernel-Tests'!
|
641
|
-
|
642
|
-
!SymbolTest methodsFor: 'tests'!
|
643
|
-
|
644
|
-
testEquality
|
645
|
-
self assert: #hello = #hello.
|
646
|
-
self deny: #hello = #world.
|
627
|
+
testidentityHash
|
628
|
+
| o1 o2 |
|
629
|
+
|
630
|
+
o1 := Object new.
|
631
|
+
o2 := Object new.
|
647
632
|
|
648
|
-
self assert:
|
649
|
-
self
|
633
|
+
self assert: o1 identityHash == o1 identityHash.
|
634
|
+
self deny: o1 identityHash == o2 identityHash
|
635
|
+
! !
|
650
636
|
|
651
|
-
|
652
|
-
|
653
|
-
!
|
637
|
+
TestCase subclass: #PackageTest
|
638
|
+
instanceVariableNames: 'zorkPackage grulPackage backUpCommitPathJs backUpCommitPathSt'
|
639
|
+
package: 'Kernel-Tests'!
|
654
640
|
|
655
|
-
|
656
|
-
self assert: (#hello at: 1) = 'h'.
|
657
|
-
self assert: (#hello at: 5) = 'o'.
|
658
|
-
self assert: (#hello at: 6 ifAbsent: [nil]) = nil
|
659
|
-
!
|
641
|
+
!PackageTest methodsFor: 'running'!
|
660
642
|
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
!
|
643
|
+
setUp
|
644
|
+
backUpCommitPathJs := Package defaultCommitPathJs.
|
645
|
+
backUpCommitPathSt := Package defaultCommitPathSt.
|
665
646
|
|
666
|
-
|
667
|
-
self assert: #hello == #hello.
|
668
|
-
self deny: #hello == #world.
|
647
|
+
Package resetCommitPaths.
|
669
648
|
|
670
|
-
|
671
|
-
|
649
|
+
zorkPackage := Package new name: 'Zork'.
|
650
|
+
grulPackage := Package new
|
651
|
+
name: 'Grul';
|
652
|
+
commitPathJs: 'server/grul/js';
|
653
|
+
commitPathSt: 'grul/st';
|
654
|
+
yourself
|
672
655
|
!
|
673
656
|
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
self deny: #bb < #ba.
|
680
|
-
|
681
|
-
self assert: #ab >= #aa.
|
682
|
-
self deny: #ab >= #ba.
|
683
|
-
|
684
|
-
self assert: #ab <= #ba.
|
685
|
-
self deny: #bb <= #ba
|
686
|
-
!
|
657
|
+
tearDown
|
658
|
+
Package
|
659
|
+
defaultCommitPathJs: backUpCommitPathJs;
|
660
|
+
defaultCommitPathSt: backUpCommitPathSt
|
661
|
+
! !
|
687
662
|
|
688
|
-
|
689
|
-
self assert: #a size equals: 1.
|
690
|
-
self assert: #aaaaa size equals: 5
|
691
|
-
!
|
663
|
+
!PackageTest methodsFor: 'tests'!
|
692
664
|
|
693
|
-
|
694
|
-
self assert:
|
665
|
+
testGrulCommitPathJsShouldBeServerGrulJs
|
666
|
+
self assert: 'server/grul/js' equals: grulPackage commitPathJs
|
695
667
|
!
|
696
668
|
|
697
|
-
|
698
|
-
self assert:
|
669
|
+
testGrulCommitPathStShouldBeGrulSt
|
670
|
+
self assert: 'grul/st' equals: grulPackage commitPathSt
|
699
671
|
!
|
700
672
|
|
701
|
-
|
702
|
-
self assert:
|
703
|
-
self assert: #hello deepCopy == #hello
|
673
|
+
testZorkCommitPathJsShouldBeJs
|
674
|
+
self assert: 'js' equals: zorkPackage commitPathJs
|
704
675
|
!
|
705
676
|
|
706
|
-
|
707
|
-
self assert:
|
708
|
-
self deny: 'hello' isSymbol.
|
709
|
-
self deny: #hello isString.
|
710
|
-
self assert: 'hello' isString
|
677
|
+
testZorkCommitPathStShouldBeSt
|
678
|
+
self assert: 'st' equals: zorkPackage commitPathSt
|
711
679
|
! !
|
712
680
|
|
713
|
-
|
714
|
-
instanceVariableNames: '
|
715
|
-
|
681
|
+
PackageTest subclass: #PackageWithDefaultCommitPathChangedTest
|
682
|
+
instanceVariableNames: ''
|
683
|
+
package: 'Kernel-Tests'!
|
716
684
|
|
717
|
-
!
|
685
|
+
!PackageWithDefaultCommitPathChangedTest methodsFor: 'running'!
|
718
686
|
|
719
|
-
|
720
|
-
|
721
|
-
!
|
687
|
+
setUp
|
688
|
+
super setUp.
|
722
689
|
|
723
|
-
|
724
|
-
|
690
|
+
Package
|
691
|
+
defaultCommitPathJs: 'javascripts/';
|
692
|
+
defaultCommitPathSt: 'smalltalk/'.
|
725
693
|
! !
|
726
694
|
|
727
|
-
|
728
|
-
instanceVariableNames: ''
|
729
|
-
category: 'Kernel-Tests'!
|
695
|
+
!PackageWithDefaultCommitPathChangedTest methodsFor: 'tests'!
|
730
696
|
|
731
|
-
|
697
|
+
testGrulCommitPathJsShouldBeServerGrulJs
|
698
|
+
self assert: 'server/grul/js' equals: grulPackage commitPathJs
|
699
|
+
!
|
732
700
|
|
733
|
-
|
734
|
-
self assert:
|
735
|
-
self deny: nil notNil.
|
701
|
+
testGrulCommitPathStShouldBeGrulSt
|
702
|
+
self assert: 'grul/st' equals: grulPackage commitPathSt
|
736
703
|
!
|
737
704
|
|
738
|
-
|
739
|
-
self assert:
|
740
|
-
self deny: (nil ifNotNil: [true]) = true.
|
741
|
-
self assert: (nil ifNil: [true] ifNotNil: [false]) equals: true.
|
742
|
-
self deny: (nil ifNotNil: [true] ifNil: [false]) = true
|
705
|
+
testZorkCommitPathJsShouldBeJavascript
|
706
|
+
self assert: 'javascripts/' equals: zorkPackage commitPathJs
|
743
707
|
!
|
744
708
|
|
745
|
-
|
746
|
-
self assert:
|
747
|
-
!
|
709
|
+
testZorkCommitPathStShouldBeSmalltalk
|
710
|
+
self assert: 'smalltalk/' equals: zorkPackage commitPathSt
|
711
|
+
! !
|
748
712
|
|
749
|
-
|
750
|
-
|
713
|
+
!PackageWithDefaultCommitPathChangedTest class methodsFor: 'accessing'!
|
714
|
+
|
715
|
+
shouldInheritSelectors
|
716
|
+
^ false
|
751
717
|
! !
|
752
718
|
|
753
719
|
TestCase subclass: #PointTest
|
754
720
|
instanceVariableNames: ''
|
755
|
-
|
721
|
+
package: 'Kernel-Tests'!
|
756
722
|
|
757
723
|
!PointTest methodsFor: 'tests'!
|
758
724
|
|
@@ -763,6 +729,13 @@ testAccessing
|
|
763
729
|
self assert: (Point new y: 4) y equals: 4
|
764
730
|
!
|
765
731
|
|
732
|
+
testArithmetic
|
733
|
+
self assert: 3@4 * (3@4 ) equals: (Point x: 9 y: 16).
|
734
|
+
self assert: 3@4 + (3@4 ) equals: (Point x: 6 y: 8).
|
735
|
+
self assert: 3@4 - (3@4 ) equals: (Point x: 0 y: 0).
|
736
|
+
self assert: 6@8 / (3@4 ) equals: (Point x: 2 y: 2)
|
737
|
+
!
|
738
|
+
|
766
739
|
testAt
|
767
740
|
self assert: 3@4 equals: (Point x: 3 y: 4)
|
768
741
|
!
|
@@ -772,13 +745,6 @@ testEgality
|
|
772
745
|
self deny: 3@5 = (3@6)
|
773
746
|
!
|
774
747
|
|
775
|
-
testArithmetic
|
776
|
-
self assert: 3@4 * (3@4 ) equals: (Point x: 9 y: 16).
|
777
|
-
self assert: 3@4 + (3@4 ) equals: (Point x: 6 y: 8).
|
778
|
-
self assert: 3@4 - (3@4 ) equals: (Point x: 0 y: 0).
|
779
|
-
self assert: 6@8 / (3@4 ) equals: (Point x: 2 y: 2)
|
780
|
-
!
|
781
|
-
|
782
748
|
testTranslateBy
|
783
749
|
self assert: 3@4 equals: (3@3 translateBy: 0@1).
|
784
750
|
self assert: 3@2 equals: (3@3 translateBy: 0@1 negated).
|
@@ -788,7 +754,7 @@ testTranslateBy
|
|
788
754
|
|
789
755
|
TestCase subclass: #RandomTest
|
790
756
|
instanceVariableNames: ''
|
791
|
-
|
757
|
+
package: 'Kernel-Tests'!
|
792
758
|
|
793
759
|
!RandomTest methodsFor: 'tests'!
|
794
760
|
|
@@ -803,38 +769,37 @@ textNext
|
|
803
769
|
next = current]
|
804
770
|
! !
|
805
771
|
|
806
|
-
TestCase subclass: #
|
807
|
-
instanceVariableNames: '
|
808
|
-
|
772
|
+
TestCase subclass: #SetTest
|
773
|
+
instanceVariableNames: ''
|
774
|
+
package: 'Kernel-Tests'!
|
809
775
|
|
810
|
-
!
|
776
|
+
!SetTest methodsFor: 'tests'!
|
811
777
|
|
812
|
-
|
813
|
-
|
814
|
-
|
778
|
+
testAddRemove
|
779
|
+
| set |
|
780
|
+
set := Set new.
|
781
|
+
|
782
|
+
self assert: set isEmpty.
|
815
783
|
|
816
|
-
|
817
|
-
|
818
|
-
!
|
784
|
+
set add: 3.
|
785
|
+
self assert: (set includes: 3).
|
819
786
|
|
820
|
-
|
821
|
-
|
822
|
-
self assert: theClass superclass == ObjectMock superclass.
|
823
|
-
self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.
|
824
|
-
self assert: theClass name equals: 'ObjectMock2'.
|
825
|
-
self assert: theClass package == ObjectMock package.
|
826
|
-
self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys
|
827
|
-
!
|
787
|
+
set add: 5.
|
788
|
+
self assert: (set includes: 5).
|
828
789
|
|
829
|
-
|
830
|
-
self
|
831
|
-
!
|
790
|
+
set remove: 3.
|
791
|
+
self deny: (set includes: 3)
|
792
|
+
!
|
832
793
|
|
833
|
-
|
834
|
-
|
835
|
-
|
794
|
+
testAt
|
795
|
+
self should: [Set new at: 1 put: 2] raise: Error
|
796
|
+
!
|
836
797
|
|
837
|
-
|
798
|
+
testSize
|
799
|
+
self assert: Set new size equals: 0.
|
800
|
+
self assert: (Set withAll: #(1 2 3 4)) size equals: 4.
|
801
|
+
self assert: (Set withAll: #(1 1 1 1)) size equals: 1
|
802
|
+
!
|
838
803
|
|
839
804
|
testUnicity
|
840
805
|
| set |
|
@@ -849,69 +814,182 @@ testUnicity
|
|
849
814
|
self assert: set size = 2.
|
850
815
|
|
851
816
|
self assert: set asArray equals: #(21 'hello')
|
817
|
+
! !
|
818
|
+
|
819
|
+
TestCase subclass: #StringTest
|
820
|
+
instanceVariableNames: ''
|
821
|
+
package: 'Kernel-Tests'!
|
822
|
+
|
823
|
+
!StringTest methodsFor: 'tests'!
|
824
|
+
|
825
|
+
testAddRemove
|
826
|
+
self should: ['hello' add: 'a'] raise: Error.
|
827
|
+
self should: ['hello' remove: 'h'] raise: Error
|
828
|
+
!
|
829
|
+
|
830
|
+
testAsArray
|
831
|
+
self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').
|
852
832
|
!
|
853
833
|
|
854
834
|
testAt
|
855
|
-
self
|
835
|
+
self assert: ('hello' at: 1) = 'h'.
|
836
|
+
self assert: ('hello' at: 5) = 'o'.
|
837
|
+
self assert: ('hello' at: 6 ifAbsent: [nil]) = nil
|
856
838
|
!
|
857
839
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
self assert: set isEmpty.
|
840
|
+
testAtPut
|
841
|
+
"String instances are read-only"
|
842
|
+
self should: ['hello' at: 1 put: 'a'] raise: Error
|
843
|
+
!
|
863
844
|
|
864
|
-
|
865
|
-
self
|
845
|
+
testCopyWithoutAll
|
846
|
+
self
|
847
|
+
assert: 'hello world'
|
848
|
+
equals: ('*hello* *world*' copyWithoutAll: '*')
|
849
|
+
!
|
866
850
|
|
867
|
-
|
868
|
-
self assert:
|
851
|
+
testEquality
|
852
|
+
self assert: 'hello' = 'hello'.
|
853
|
+
self deny: 'hello' = 'world'.
|
869
854
|
|
870
|
-
|
871
|
-
self
|
855
|
+
self assert: 'hello' = 'hello' yourself.
|
856
|
+
self assert: 'hello' yourself = 'hello'.
|
857
|
+
|
858
|
+
"test JS falsy value"
|
859
|
+
self deny: '' = 0
|
860
|
+
!
|
861
|
+
|
862
|
+
testIdentity
|
863
|
+
self assert: 'hello' == 'hello'.
|
864
|
+
self deny: 'hello' == 'world'.
|
865
|
+
|
866
|
+
self assert: 'hello' == 'hello' yourself.
|
867
|
+
self assert: 'hello' yourself == 'hello'.
|
868
|
+
|
869
|
+
"test JS falsy value"
|
870
|
+
self deny: '' == 0
|
871
|
+
!
|
872
|
+
|
873
|
+
testIncludesSubString
|
874
|
+
self assert: ('amber' includesSubString: 'ber').
|
875
|
+
self deny: ('amber' includesSubString: 'zork').
|
876
|
+
!
|
877
|
+
|
878
|
+
testJoin
|
879
|
+
self assert: 'hello,world' equals: (',' join: #('hello' 'world'))
|
872
880
|
!
|
873
881
|
|
874
882
|
testSize
|
875
|
-
self assert:
|
876
|
-
self assert:
|
877
|
-
|
883
|
+
self assert: 'smalltalk' size equals: 9.
|
884
|
+
self assert: '' size equals: 0
|
885
|
+
!
|
886
|
+
|
887
|
+
testStreamContents
|
888
|
+
self
|
889
|
+
assert: 'hello world'
|
890
|
+
equals: (String streamContents: [:aStream| aStream
|
891
|
+
nextPutAll: 'hello'; space;
|
892
|
+
nextPutAll: 'world'])
|
878
893
|
! !
|
879
894
|
|
880
|
-
|
895
|
+
TestCase subclass: #SymbolTest
|
881
896
|
instanceVariableNames: ''
|
882
|
-
|
897
|
+
package: 'Kernel-Tests'!
|
883
898
|
|
884
|
-
!
|
899
|
+
!SymbolTest methodsFor: 'tests'!
|
885
900
|
|
886
|
-
|
887
|
-
|
901
|
+
testAsString
|
902
|
+
self assert: #hello asString equals: 'hello'
|
903
|
+
!
|
888
904
|
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
! !
|
905
|
+
testAsSymbol
|
906
|
+
self assert: #hello == #hello asSymbol
|
907
|
+
!
|
893
908
|
|
894
|
-
|
909
|
+
testAt
|
910
|
+
self assert: (#hello at: 1) = 'h'.
|
911
|
+
self assert: (#hello at: 5) = 'o'.
|
912
|
+
self assert: (#hello at: 6 ifAbsent: [nil]) = nil
|
913
|
+
!
|
895
914
|
|
896
|
-
|
897
|
-
|
915
|
+
testAtPut
|
916
|
+
"Symbol instances are read-only"
|
917
|
+
self should: ['hello' at: 1 put: 'a'] raise: Error
|
898
918
|
!
|
899
919
|
|
900
|
-
|
901
|
-
self assert:
|
920
|
+
testComparing
|
921
|
+
self assert: #ab > #aa.
|
922
|
+
self deny: #ab > #ba.
|
923
|
+
|
924
|
+
self assert: #ab < #ba.
|
925
|
+
self deny: #bb < #ba.
|
926
|
+
|
927
|
+
self assert: #ab >= #aa.
|
928
|
+
self deny: #ab >= #ba.
|
929
|
+
|
930
|
+
self assert: #ab <= #ba.
|
931
|
+
self deny: #bb <= #ba
|
902
932
|
!
|
903
933
|
|
904
|
-
|
905
|
-
self assert:
|
934
|
+
testCopying
|
935
|
+
self assert: #hello copy == #hello.
|
936
|
+
self assert: #hello deepCopy == #hello
|
906
937
|
!
|
907
938
|
|
908
|
-
|
909
|
-
self assert:
|
939
|
+
testEquality
|
940
|
+
self assert: #hello = #hello.
|
941
|
+
self deny: #hello = #world.
|
942
|
+
|
943
|
+
self assert: #hello = #hello yourself.
|
944
|
+
self assert: #hello yourself = #hello.
|
945
|
+
|
946
|
+
self deny: #hello = 'hello'.
|
947
|
+
self deny: 'hello' = #hello.
|
948
|
+
!
|
949
|
+
|
950
|
+
testIdentity
|
951
|
+
self assert: #hello == #hello.
|
952
|
+
self deny: #hello == #world.
|
953
|
+
|
954
|
+
self assert: #hello = #hello yourself.
|
955
|
+
self assert: #hello yourself = #hello asString asSymbol
|
956
|
+
!
|
957
|
+
|
958
|
+
testIsSymbolIsString
|
959
|
+
self assert: #hello isSymbol.
|
960
|
+
self deny: 'hello' isSymbol.
|
961
|
+
self deny: #hello isString.
|
962
|
+
self assert: 'hello' isString
|
963
|
+
!
|
964
|
+
|
965
|
+
testSize
|
966
|
+
self assert: #a size equals: 1.
|
967
|
+
self assert: #aaaaa size equals: 5
|
910
968
|
! !
|
911
969
|
|
912
|
-
|
970
|
+
TestCase subclass: #UndefinedTest
|
971
|
+
instanceVariableNames: ''
|
972
|
+
package: 'Kernel-Tests'!
|
913
973
|
|
914
|
-
|
915
|
-
|
974
|
+
!UndefinedTest methodsFor: 'tests'!
|
975
|
+
|
976
|
+
testCopying
|
977
|
+
self assert: nil copy equals: nil
|
978
|
+
!
|
979
|
+
|
980
|
+
testDeepCopy
|
981
|
+
self assert: nil deepCopy = nil
|
982
|
+
!
|
983
|
+
|
984
|
+
testIfNil
|
985
|
+
self assert: (nil ifNil: [true]) equals: true.
|
986
|
+
self deny: (nil ifNotNil: [true]) = true.
|
987
|
+
self assert: (nil ifNil: [true] ifNotNil: [false]) equals: true.
|
988
|
+
self deny: (nil ifNotNil: [true] ifNil: [false]) = true
|
989
|
+
!
|
990
|
+
|
991
|
+
testIsNil
|
992
|
+
self assert: nil isNil.
|
993
|
+
self deny: nil notNil.
|
916
994
|
! !
|
917
995
|
|