resin 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/amber/css/amber-normalize.css +73 -73
- data/amber/css/amber-normalize.less +1 -1
- data/amber/css/amber.css +106 -106
- data/amber/css/helios.css +242 -0
- data/amber/images/hsplitter.png +0 -0
- data/amber/images/vsplitter.png +0 -0
- data/amber/js/Benchfib.deploy.js +116 -38
- data/amber/js/Benchfib.js +120 -42
- data/amber/js/Canvas.deploy.js +674 -403
- data/amber/js/Canvas.js +682 -411
- data/amber/js/Compiler-AST.deploy.js +1150 -0
- data/amber/js/Compiler-AST.js +1591 -0
- data/amber/js/Compiler-Core.deploy.js +1562 -0
- data/amber/js/Compiler-Core.js +1972 -0
- data/amber/js/Compiler-Exceptions.deploy.js +114 -0
- data/amber/js/Compiler-Exceptions.js +161 -0
- data/amber/js/Compiler-IR.deploy.js +2326 -0
- data/amber/js/Compiler-IR.js +3146 -0
- data/amber/js/Compiler-Inlining.deploy.js +1147 -0
- data/amber/js/Compiler-Inlining.js +1514 -0
- data/amber/js/Compiler-Semantic.deploy.js +1207 -0
- data/amber/js/Compiler-Semantic.js +1628 -0
- data/amber/js/Compiler-Tests.deploy.js +646 -60
- data/amber/js/Compiler-Tests.js +843 -82
- data/amber/js/Compiler.deploy.js +1097 -159
- data/amber/js/Compiler.js +1414 -161
- data/amber/js/Examples.deploy.js +31 -15
- data/amber/js/Examples.js +33 -17
- data/amber/js/Helios-Announcements.deploy.js +127 -0
- data/amber/js/Helios-Announcements.js +157 -0
- data/amber/js/Helios-Browser.deploy.js +1473 -0
- data/amber/js/Helios-Browser.js +1953 -0
- data/amber/js/Helios-Commands.deploy.js +403 -0
- data/amber/js/Helios-Commands.js +563 -0
- data/amber/js/Helios-Core.deploy.js +1070 -0
- data/amber/js/Helios-Core.js +1445 -0
- data/amber/js/Helios-Environments.deploy.js +132 -0
- data/amber/js/Helios-Environments.js +179 -0
- data/amber/js/Helios-Inspector.deploy.js +855 -0
- data/amber/js/Helios-Inspector.js +1155 -0
- data/amber/js/Helios-KeyBindings.deploy.js +753 -0
- data/amber/js/Helios-KeyBindings.js +1023 -0
- data/amber/js/Helios-Layout.deploy.js +383 -0
- data/amber/js/Helios-Layout.js +523 -0
- data/amber/js/Helios-Workspace.deploy.js +799 -0
- data/amber/js/Helios-Workspace.js +1074 -0
- data/amber/js/IDE.deploy.js +2541 -1490
- data/amber/js/IDE.js +2721 -1660
- data/amber/js/Importer-Exporter.deploy.js +671 -0
- data/amber/js/Importer-Exporter.js +816 -0
- data/amber/js/Kernel-Announcements.deploy.js +137 -20
- data/amber/js/Kernel-Announcements.js +176 -22
- data/amber/js/Kernel-Classes.deploy.js +555 -168
- data/amber/js/Kernel-Classes.js +662 -205
- data/amber/js/Kernel-Collections.deploy.js +1403 -618
- data/amber/js/Kernel-Collections.js +1545 -690
- data/amber/js/Kernel-Exceptions.deploy.js +109 -45
- data/amber/js/Kernel-Exceptions.js +123 -49
- data/amber/js/Kernel-Methods.deploy.js +196 -81
- data/amber/js/Kernel-Methods.js +214 -89
- data/amber/js/Kernel-Objects.deploy.js +1542 -1117
- data/amber/js/Kernel-Objects.js +1593 -1148
- data/amber/js/Kernel-Tests.deploy.js +1725 -772
- data/amber/js/Kernel-Tests.js +2301 -1123
- data/amber/js/Kernel-Transcript.deploy.js +23 -25
- data/amber/js/Kernel-Transcript.js +24 -26
- data/amber/js/SUnit.deploy.js +204 -131
- data/amber/js/SUnit.js +222 -139
- data/amber/js/Spaces.deploy.js +240 -0
- data/amber/js/Spaces.js +326 -0
- data/amber/js/amber.js +26 -7
- data/amber/js/boot.js +65 -47
- data/amber/js/init.js +1 -1
- data/amber/js/lib/CodeMirror/amber.css +21 -21
- data/amber/js/lib/CodeMirror/codemirror.css +119 -13
- data/amber/js/lib/CodeMirror/codemirror.js +2219 -1220
- data/amber/js/lib/CodeMirror/smalltalk.js +134 -129
- data/amber/js/lib/bootstrap/css/bootstrap.css +5837 -0
- data/amber/js/lib/bootstrap/css/bootstrap.min.css +841 -0
- data/amber/js/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/amber/js/lib/bootstrap/img/glyphicons-halflings.png +0 -0
- data/amber/js/lib/bootstrap/js/bootstrap.js +2038 -0
- data/amber/js/lib/bootstrap/js/bootstrap.min.js +7 -0
- data/amber/js/lib/jQuery/jquery-1.8.2.min.js +2 -0
- data/amber/js/lib/jQuery/jquery-ui-1.8.24.custom.min.js +125 -0
- data/amber/st/Compiler-AST.st +505 -0
- data/amber/st/Compiler-Core.st +835 -0
- data/amber/st/Compiler-Exceptions.st +87 -0
- data/amber/st/Compiler-IR.st +1097 -0
- data/amber/st/Compiler-Inlining.st +650 -0
- data/amber/st/Compiler-Semantic.st +558 -0
- data/amber/st/Compiler-Tests.st +285 -381
- data/amber/st/Compiler.st +725 -2
- data/amber/st/Helios-Announcements.st +104 -0
- data/amber/st/Helios-Browser.st +708 -0
- data/amber/st/Helios-Commands.st +223 -0
- data/amber/st/Helios-Core.st +532 -0
- data/amber/st/Helios-Environments.st +98 -0
- data/amber/st/Helios-Inspector.st +367 -0
- data/amber/st/Helios-KeyBindings.st +337 -0
- data/amber/st/Helios-Layout.st +199 -0
- data/amber/st/Helios-Workspace.st +367 -0
- data/amber/st/IDE.st +75 -53
- data/amber/st/Importer-Exporter.st +386 -0
- data/amber/st/Kernel-Announcements.st +92 -0
- data/amber/st/Kernel-Classes.st +137 -15
- data/amber/st/Kernel-Collections.st +137 -47
- data/amber/st/Kernel-Exceptions.st +14 -0
- data/amber/st/Kernel-Methods.st +9 -1
- data/amber/st/Kernel-Objects.st +29 -5
- data/amber/st/Kernel-Tests.st +545 -199
- data/amber/st/SUnit.st +10 -0
- data/amber/st/Spaces.st +142 -0
- data/lib/resin/app.rb +1 -1
- metadata +86 -31
- data/amber/js/lib/jQuery/jquery-1.4.4.min.js +0 -167
- data/amber/js/lib/jQuery/jquery-1.6.4.min.js +0 -4
|
@@ -75,6 +75,20 @@ receiver: anObject
|
|
|
75
75
|
receiver := anObject
|
|
76
76
|
! !
|
|
77
77
|
|
|
78
|
+
Error subclass: #NonBooleanReceiver
|
|
79
|
+
instanceVariableNames: 'object'
|
|
80
|
+
package: 'Kernel-Exceptions'!
|
|
81
|
+
|
|
82
|
+
!NonBooleanReceiver methodsFor: 'accessing'!
|
|
83
|
+
|
|
84
|
+
object
|
|
85
|
+
^ object
|
|
86
|
+
!
|
|
87
|
+
|
|
88
|
+
object: anObject
|
|
89
|
+
object := anObject
|
|
90
|
+
! !
|
|
91
|
+
|
|
78
92
|
Object subclass: #ErrorHandler
|
|
79
93
|
instanceVariableNames: ''
|
|
80
94
|
package: 'Kernel-Exceptions'!
|
data/amber/st/Kernel-Methods.st
CHANGED
|
@@ -181,6 +181,10 @@ methodClass
|
|
|
181
181
|
^self basicAt: 'methodClass'
|
|
182
182
|
!
|
|
183
183
|
|
|
184
|
+
protocol
|
|
185
|
+
^ self category
|
|
186
|
+
!
|
|
187
|
+
|
|
184
188
|
referencedClasses
|
|
185
189
|
^self basicAt: 'referencedClasses'
|
|
186
190
|
!
|
|
@@ -241,7 +245,7 @@ printString
|
|
|
241
245
|
!
|
|
242
246
|
|
|
243
247
|
sendTo: anObject
|
|
244
|
-
Smalltalk current send: self selector to: anObject arguments: self arguments
|
|
248
|
+
^ Smalltalk current send: self selector to: anObject arguments: self arguments
|
|
245
249
|
! !
|
|
246
250
|
|
|
247
251
|
!Message class methodsFor: 'instance creation'!
|
|
@@ -273,6 +277,10 @@ home
|
|
|
273
277
|
<return self.homeContext>
|
|
274
278
|
!
|
|
275
279
|
|
|
280
|
+
pc
|
|
281
|
+
<return self.pc>
|
|
282
|
+
!
|
|
283
|
+
|
|
276
284
|
printString
|
|
277
285
|
^super printString, '(', self asString, ')'
|
|
278
286
|
!
|
data/amber/st/Kernel-Objects.st
CHANGED
|
@@ -83,6 +83,10 @@ size
|
|
|
83
83
|
self error: 'Object not indexable'
|
|
84
84
|
!
|
|
85
85
|
|
|
86
|
+
value
|
|
87
|
+
^ self
|
|
88
|
+
!
|
|
89
|
+
|
|
86
90
|
yourself
|
|
87
91
|
^self
|
|
88
92
|
! !
|
|
@@ -196,6 +200,10 @@ subclassResponsibility
|
|
|
196
200
|
self error: 'This method is a responsibility of a subclass'
|
|
197
201
|
!
|
|
198
202
|
|
|
203
|
+
throw: anObject
|
|
204
|
+
< throw anObject >
|
|
205
|
+
!
|
|
206
|
+
|
|
199
207
|
try: aBlock catch: anotherBlock
|
|
200
208
|
<try{result = aBlock()} catch(e) {result = anotherBlock(e)};
|
|
201
209
|
return result;>
|
|
@@ -752,6 +760,10 @@ identityHash
|
|
|
752
760
|
<return self % aNumber>
|
|
753
761
|
!
|
|
754
762
|
|
|
763
|
+
abs
|
|
764
|
+
^ <Math.abs(self);>
|
|
765
|
+
!
|
|
766
|
+
|
|
755
767
|
max: aNumber
|
|
756
768
|
<return Math.max(self, aNumber);>
|
|
757
769
|
!
|
|
@@ -1353,8 +1365,8 @@ It requires the `Compiler` package and the `js/parser.js` parser file in order t
|
|
|
1353
1365
|
|
|
1354
1366
|
!Smalltalk methodsFor: 'accessing'!
|
|
1355
1367
|
|
|
1356
|
-
at:
|
|
1357
|
-
<return self[
|
|
1368
|
+
at: aSymbol
|
|
1369
|
+
<return self[aSymbol._asString()]>
|
|
1358
1370
|
!
|
|
1359
1371
|
|
|
1360
1372
|
basicParse: aString
|
|
@@ -1383,7 +1395,7 @@ parseError: anException parsing: aString
|
|
|
1383
1395
|
code := String streamContents: [:s |
|
|
1384
1396
|
lines withIndexDo: [:l :i |
|
|
1385
1397
|
s nextPutAll: i asString, ': ', l, String lf]].
|
|
1386
|
-
^
|
|
1398
|
+
^ ParseError new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)
|
|
1387
1399
|
!
|
|
1388
1400
|
|
|
1389
1401
|
readJSObject: anObject
|
|
@@ -1398,18 +1410,26 @@ reservedWords
|
|
|
1398
1410
|
send: aSelector to: anObject arguments: aCollection
|
|
1399
1411
|
| selector |
|
|
1400
1412
|
selector := aSelector asString asSelector.
|
|
1401
|
-
<self.send(anObject, selector, aCollection)>
|
|
1413
|
+
<return self.send(anObject, selector, aCollection)>
|
|
1402
1414
|
! !
|
|
1403
1415
|
|
|
1404
1416
|
!Smalltalk methodsFor: 'classes'!
|
|
1405
1417
|
|
|
1406
1418
|
removeClass: aClass
|
|
1407
1419
|
aClass isMetaclass ifTrue: [self error: aClass asString, ' is a Metaclass and cannot be removed!!'].
|
|
1420
|
+
|
|
1408
1421
|
aClass methodDictionary values do: [:each |
|
|
1409
1422
|
aClass removeCompiledMethod: each].
|
|
1423
|
+
|
|
1410
1424
|
aClass class methodDictionary values do: [:each |
|
|
1411
1425
|
aClass class removeCompiledMethod: each].
|
|
1412
|
-
|
|
1426
|
+
|
|
1427
|
+
self basicDelete: aClass name.
|
|
1428
|
+
|
|
1429
|
+
SystemAnnouncer current
|
|
1430
|
+
announce: (ClassRemoved new
|
|
1431
|
+
theClass: aClass;
|
|
1432
|
+
yourself)
|
|
1413
1433
|
! !
|
|
1414
1434
|
|
|
1415
1435
|
!Smalltalk methodsFor: 'packages'!
|
|
@@ -1428,6 +1448,10 @@ packages
|
|
|
1428
1448
|
<return self.packages.all()>
|
|
1429
1449
|
!
|
|
1430
1450
|
|
|
1451
|
+
pseudoVariableNames
|
|
1452
|
+
^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')
|
|
1453
|
+
!
|
|
1454
|
+
|
|
1431
1455
|
removePackage: packageName
|
|
1432
1456
|
"Removes a package and all its classes."
|
|
1433
1457
|
|
data/amber/st/Kernel-Tests.st
CHANGED
|
@@ -1,29 +1,4 @@
|
|
|
1
1
|
Smalltalk current createPackage: 'Kernel-Tests' properties: #{}!
|
|
2
|
-
TestCase subclass: #ArrayTest
|
|
3
|
-
instanceVariableNames: ''
|
|
4
|
-
package: 'Kernel-Tests'!
|
|
5
|
-
|
|
6
|
-
!ArrayTest methodsFor: 'testing'!
|
|
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
|
-
|
|
19
|
-
testFirstN
|
|
20
|
-
self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).
|
|
21
|
-
!
|
|
22
|
-
|
|
23
|
-
testIfEmpty
|
|
24
|
-
self assert: 'zork' equals: ( '' ifEmpty: ['zork'] )
|
|
25
|
-
! !
|
|
26
|
-
|
|
27
2
|
TestCase subclass: #BlockClosureTest
|
|
28
3
|
instanceVariableNames: ''
|
|
29
4
|
package: 'Kernel-Tests'!
|
|
@@ -204,10 +179,169 @@ testInstanceVariableNames
|
|
|
204
179
|
self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')
|
|
205
180
|
! !
|
|
206
181
|
|
|
207
|
-
TestCase subclass: #
|
|
182
|
+
TestCase subclass: #CollectionTest
|
|
183
|
+
instanceVariableNames: ''
|
|
184
|
+
package: 'Kernel-Tests'!
|
|
185
|
+
|
|
186
|
+
!CollectionTest methodsFor: 'accessing'!
|
|
187
|
+
|
|
188
|
+
collection
|
|
189
|
+
^ self collectionClass withAll: self defaultValues
|
|
190
|
+
!
|
|
191
|
+
|
|
192
|
+
collectionClass
|
|
193
|
+
^ self class collectionClass
|
|
194
|
+
!
|
|
195
|
+
|
|
196
|
+
collectionWithDuplicates
|
|
197
|
+
^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')
|
|
198
|
+
!
|
|
199
|
+
|
|
200
|
+
defaultValues
|
|
201
|
+
^ #(1 2 3 -4)
|
|
202
|
+
! !
|
|
203
|
+
|
|
204
|
+
!CollectionTest methodsFor: 'convenience'!
|
|
205
|
+
|
|
206
|
+
assertSameContents: aCollection as: anotherCollection
|
|
207
|
+
self assert: aCollection size = anotherCollection size.
|
|
208
|
+
aCollection do: [ :each |
|
|
209
|
+
self assert: (aCollection occurrencesOf: each) = (anotherCollection occurrencesOf: each) ]
|
|
210
|
+
! !
|
|
211
|
+
|
|
212
|
+
!CollectionTest methodsFor: 'testing'!
|
|
213
|
+
|
|
214
|
+
isCollectionReadOnly
|
|
215
|
+
^ false
|
|
216
|
+
! !
|
|
217
|
+
|
|
218
|
+
!CollectionTest methodsFor: 'tests'!
|
|
219
|
+
|
|
220
|
+
testAsArray
|
|
221
|
+
self
|
|
222
|
+
assertSameContents: self collection
|
|
223
|
+
as: self collection asArray
|
|
224
|
+
!
|
|
225
|
+
|
|
226
|
+
testAsOrderedCollection
|
|
227
|
+
self
|
|
228
|
+
assertSameContents: self collection
|
|
229
|
+
as: self collection asOrderedCollection
|
|
230
|
+
!
|
|
231
|
+
|
|
232
|
+
testAsSet
|
|
233
|
+
| c set |
|
|
234
|
+
c := self collectionWithDuplicates.
|
|
235
|
+
set := c asSet.
|
|
236
|
+
self assert: set size = 5.
|
|
237
|
+
c do: [ :each |
|
|
238
|
+
self assert: (set includes: each) ]
|
|
239
|
+
!
|
|
240
|
+
|
|
241
|
+
testCollect
|
|
242
|
+
| newCollection |
|
|
243
|
+
newCollection := #(1 2 3 4).
|
|
244
|
+
self
|
|
245
|
+
assertSameContents: (self collection collect: [ :each |
|
|
246
|
+
each abs ])
|
|
247
|
+
as: newCollection
|
|
248
|
+
!
|
|
249
|
+
|
|
250
|
+
testDetect
|
|
251
|
+
self assert: (self collection detect: [ :each | each < 0 ]) = -4.
|
|
252
|
+
self
|
|
253
|
+
should: [ self collection detect: [ :each | each = 6 ] ]
|
|
254
|
+
raise: Error
|
|
255
|
+
!
|
|
256
|
+
|
|
257
|
+
testDo
|
|
258
|
+
| newCollection |
|
|
259
|
+
newCollection := OrderedCollection new.
|
|
260
|
+
self collection do: [ :each |
|
|
261
|
+
newCollection add: each ].
|
|
262
|
+
self
|
|
263
|
+
assertSameContents: self collection
|
|
264
|
+
as: newCollection
|
|
265
|
+
!
|
|
266
|
+
|
|
267
|
+
testIsEmpty
|
|
268
|
+
self assert: self collectionClass new isEmpty.
|
|
269
|
+
self deny: self collection isEmpty
|
|
270
|
+
!
|
|
271
|
+
|
|
272
|
+
testSelect
|
|
273
|
+
| newCollection |
|
|
274
|
+
newCollection := #(2 -4).
|
|
275
|
+
self
|
|
276
|
+
assertSameContents: (self collection select: [ :each |
|
|
277
|
+
each even ])
|
|
278
|
+
as: newCollection
|
|
279
|
+
!
|
|
280
|
+
|
|
281
|
+
testSize
|
|
282
|
+
self assert: self collectionClass new size = 0.
|
|
283
|
+
self assert: self collection size = 4
|
|
284
|
+
! !
|
|
285
|
+
|
|
286
|
+
!CollectionTest class methodsFor: 'accessing'!
|
|
287
|
+
|
|
288
|
+
collectionClass
|
|
289
|
+
^ nil
|
|
290
|
+
! !
|
|
291
|
+
|
|
292
|
+
!CollectionTest class methodsFor: 'testing'!
|
|
293
|
+
|
|
294
|
+
isAbstract
|
|
295
|
+
^ self collectionClass isNil
|
|
296
|
+
! !
|
|
297
|
+
|
|
298
|
+
CollectionTest subclass: #HashedCollectionTest
|
|
208
299
|
instanceVariableNames: ''
|
|
209
300
|
package: 'Kernel-Tests'!
|
|
210
301
|
|
|
302
|
+
!HashedCollectionTest methodsFor: 'accessing'!
|
|
303
|
+
|
|
304
|
+
collection
|
|
305
|
+
^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4 }
|
|
306
|
+
!
|
|
307
|
+
|
|
308
|
+
collectionWithDuplicates
|
|
309
|
+
^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4. 'e' -> 1. 'f' -> 2. 'g' -> 10 }
|
|
310
|
+
! !
|
|
311
|
+
|
|
312
|
+
!HashedCollectionTest class methodsFor: 'accessing'!
|
|
313
|
+
|
|
314
|
+
collectionClass
|
|
315
|
+
^ HashedCollection
|
|
316
|
+
! !
|
|
317
|
+
|
|
318
|
+
HashedCollectionTest subclass: #DictionaryTest
|
|
319
|
+
instanceVariableNames: ''
|
|
320
|
+
package: 'Kernel-Tests'!
|
|
321
|
+
|
|
322
|
+
!DictionaryTest methodsFor: 'accessing'!
|
|
323
|
+
|
|
324
|
+
collection
|
|
325
|
+
^ Dictionary new
|
|
326
|
+
at: 1 put: 1;
|
|
327
|
+
at: 'a' put: 2;
|
|
328
|
+
at: true put: 3;
|
|
329
|
+
at: 4 put: -4;
|
|
330
|
+
yourself
|
|
331
|
+
!
|
|
332
|
+
|
|
333
|
+
collectionWithDuplicates
|
|
334
|
+
^ Dictionary new
|
|
335
|
+
at: 1 put: 1;
|
|
336
|
+
at: 'a' put: 2;
|
|
337
|
+
at: true put: 3;
|
|
338
|
+
at: 4 put: -4;
|
|
339
|
+
at: 'b' put: 1;
|
|
340
|
+
at: 3 put: 3;
|
|
341
|
+
at: false put: 12;
|
|
342
|
+
yourself
|
|
343
|
+
! !
|
|
344
|
+
|
|
211
345
|
!DictionaryTest methodsFor: 'tests'!
|
|
212
346
|
|
|
213
347
|
testAccessing
|
|
@@ -250,6 +384,44 @@ testEquality
|
|
|
250
384
|
self deny: d1 = d2.
|
|
251
385
|
!
|
|
252
386
|
|
|
387
|
+
testIfAbsent
|
|
388
|
+
|
|
389
|
+
| d visited |
|
|
390
|
+
visited := false.
|
|
391
|
+
d := Dictionary new.
|
|
392
|
+
|
|
393
|
+
d at: 'hello' ifAbsent: [ visited := true ].
|
|
394
|
+
self assert: visited.
|
|
395
|
+
!
|
|
396
|
+
|
|
397
|
+
testIfPresent
|
|
398
|
+
|
|
399
|
+
| d visited absent |
|
|
400
|
+
visited := false.
|
|
401
|
+
d := Dictionary new.
|
|
402
|
+
d at: 'hello' put: 'world'.
|
|
403
|
+
|
|
404
|
+
d at: 'hello' ifPresent: [ :value | visited := value ].
|
|
405
|
+
self assert: visited = 'world'.
|
|
406
|
+
|
|
407
|
+
absent := d at: 'bye' ifPresent: [ :value | visited := value ].
|
|
408
|
+
self assert: absent isNil.
|
|
409
|
+
!
|
|
410
|
+
|
|
411
|
+
testIfPresentIfAbsent
|
|
412
|
+
|
|
413
|
+
| d visited |
|
|
414
|
+
visited := false.
|
|
415
|
+
d := Dictionary new.
|
|
416
|
+
d at: 'hello' put: 'world'.
|
|
417
|
+
|
|
418
|
+
d at: 'hello' ifPresent: [ :value | visited := value ] ifAbsent: [ visited := true ].
|
|
419
|
+
self assert: visited = 'world'.
|
|
420
|
+
|
|
421
|
+
d at: 'buy' ifPresent: [ :value | visited := value ] ifAbsent: [ visited := true ].
|
|
422
|
+
self assert: visited.
|
|
423
|
+
!
|
|
424
|
+
|
|
253
425
|
testKeys
|
|
254
426
|
| d |
|
|
255
427
|
|
|
@@ -263,7 +435,7 @@ testKeys
|
|
|
263
435
|
|
|
264
436
|
testPrintString
|
|
265
437
|
self
|
|
266
|
-
assert: 'a Dictionary(''firstname''
|
|
438
|
+
assert: 'a Dictionary(''firstname''->''James'' , ''lastname''->''Bond'')'
|
|
267
439
|
equals: (Dictionary new
|
|
268
440
|
at:'firstname' put: 'James';
|
|
269
441
|
at:'lastname' put: 'Bond';
|
|
@@ -330,6 +502,313 @@ testValues
|
|
|
330
502
|
self assert: d values = #(2 3 4)
|
|
331
503
|
! !
|
|
332
504
|
|
|
505
|
+
!DictionaryTest class methodsFor: 'accessing'!
|
|
506
|
+
|
|
507
|
+
collectionClass
|
|
508
|
+
^ Dictionary
|
|
509
|
+
! !
|
|
510
|
+
|
|
511
|
+
CollectionTest subclass: #SequenceableCollectionTest
|
|
512
|
+
instanceVariableNames: ''
|
|
513
|
+
package: 'Kernel-Tests'!
|
|
514
|
+
|
|
515
|
+
!SequenceableCollectionTest methodsFor: 'tests'!
|
|
516
|
+
|
|
517
|
+
testAt
|
|
518
|
+
self assert: (self collection at: 4) = -4.
|
|
519
|
+
self should: [ self collection at: 5 ] raise: Error
|
|
520
|
+
!
|
|
521
|
+
|
|
522
|
+
testAtIfAbsent
|
|
523
|
+
self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) = 'none'
|
|
524
|
+
! !
|
|
525
|
+
|
|
526
|
+
SequenceableCollectionTest subclass: #ArrayTest
|
|
527
|
+
instanceVariableNames: ''
|
|
528
|
+
package: 'Kernel-Tests'!
|
|
529
|
+
|
|
530
|
+
!ArrayTest methodsFor: 'testing'!
|
|
531
|
+
|
|
532
|
+
testAtIfAbsent
|
|
533
|
+
| array |
|
|
534
|
+
array := #('hello' 'world').
|
|
535
|
+
self assert: (array at: 1) equals: 'hello'.
|
|
536
|
+
self assert: (array at: 2) equals: 'world'.
|
|
537
|
+
self assert: (array at: 2 ifAbsent: ['not found']) equals: 'world'.
|
|
538
|
+
self assert: (array at: 0 ifAbsent: ['not found']) equals: 'not found'.
|
|
539
|
+
self assert: (array at: -10 ifAbsent: ['not found']) equals: 'not found'.
|
|
540
|
+
self assert: (array at: 3 ifAbsent: ['not found']) equals: 'not found'.
|
|
541
|
+
!
|
|
542
|
+
|
|
543
|
+
testFirstN
|
|
544
|
+
self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).
|
|
545
|
+
!
|
|
546
|
+
|
|
547
|
+
testIfEmpty
|
|
548
|
+
self assert: 'zork' equals: ( '' ifEmpty: ['zork'] )
|
|
549
|
+
!
|
|
550
|
+
|
|
551
|
+
testPrintString
|
|
552
|
+
| array |
|
|
553
|
+
array := Array new.
|
|
554
|
+
self assert: 'a Array ()' equals: ( array printString ).
|
|
555
|
+
array add: 1; add: 3.
|
|
556
|
+
self assert: 'a Array (1 3)' equals: ( array printString ).
|
|
557
|
+
array add: 'foo'.
|
|
558
|
+
self assert: 'a Array (1 3 ''foo'')' equals: ( array printString ).
|
|
559
|
+
array remove: 1; remove: 3.
|
|
560
|
+
self assert: 'a Array (''foo'')' equals: ( array printString ).
|
|
561
|
+
array addLast: 3.
|
|
562
|
+
self assert: 'a Array (''foo'' 3)' equals: ( array printString ).
|
|
563
|
+
array addLast: 3.
|
|
564
|
+
self assert: 'a Array (''foo'' 3 3)' equals: ( array printString ).
|
|
565
|
+
! !
|
|
566
|
+
|
|
567
|
+
!ArrayTest class methodsFor: 'accessing'!
|
|
568
|
+
|
|
569
|
+
collectionClass
|
|
570
|
+
^ Array
|
|
571
|
+
! !
|
|
572
|
+
|
|
573
|
+
SequenceableCollectionTest subclass: #StringTest
|
|
574
|
+
instanceVariableNames: ''
|
|
575
|
+
package: 'Kernel-Tests'!
|
|
576
|
+
|
|
577
|
+
!StringTest methodsFor: 'accessing'!
|
|
578
|
+
|
|
579
|
+
collection
|
|
580
|
+
^'hello'
|
|
581
|
+
!
|
|
582
|
+
|
|
583
|
+
collectionWithDuplicates
|
|
584
|
+
^ 'abbaerte'
|
|
585
|
+
! !
|
|
586
|
+
|
|
587
|
+
!StringTest methodsFor: 'tests'!
|
|
588
|
+
|
|
589
|
+
testAddRemove
|
|
590
|
+
self should: ['hello' add: 'a'] raise: Error.
|
|
591
|
+
self should: ['hello' remove: 'h'] raise: Error
|
|
592
|
+
!
|
|
593
|
+
|
|
594
|
+
testAsArray
|
|
595
|
+
self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').
|
|
596
|
+
!
|
|
597
|
+
|
|
598
|
+
testAt
|
|
599
|
+
self assert: ('hello' at: 1) = 'h'.
|
|
600
|
+
self assert: ('hello' at: 5) = 'o'.
|
|
601
|
+
self assert: ('hello' at: 6 ifAbsent: [nil]) = nil
|
|
602
|
+
!
|
|
603
|
+
|
|
604
|
+
testAtPut
|
|
605
|
+
"String instances are read-only"
|
|
606
|
+
self should: ['hello' at: 1 put: 'a'] raise: Error
|
|
607
|
+
!
|
|
608
|
+
|
|
609
|
+
testCollect
|
|
610
|
+
| newCollection |
|
|
611
|
+
newCollection := 'hheelllloo'.
|
|
612
|
+
self
|
|
613
|
+
assertSameContents: (self collection collect: [ :each |
|
|
614
|
+
each, each ])
|
|
615
|
+
as: newCollection
|
|
616
|
+
!
|
|
617
|
+
|
|
618
|
+
testCopyWithoutAll
|
|
619
|
+
self
|
|
620
|
+
assert: 'hello world'
|
|
621
|
+
equals: ('*hello* *world*' copyWithoutAll: '*')
|
|
622
|
+
!
|
|
623
|
+
|
|
624
|
+
testDetect
|
|
625
|
+
self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.
|
|
626
|
+
self
|
|
627
|
+
should: [ self collection detect: [ :each | each = 6 ] ]
|
|
628
|
+
raise: Error
|
|
629
|
+
!
|
|
630
|
+
|
|
631
|
+
testEquality
|
|
632
|
+
self assert: 'hello' = 'hello'.
|
|
633
|
+
self deny: 'hello' = 'world'.
|
|
634
|
+
|
|
635
|
+
self assert: 'hello' = 'hello' yourself.
|
|
636
|
+
self assert: 'hello' yourself = 'hello'.
|
|
637
|
+
|
|
638
|
+
"test JS falsy value"
|
|
639
|
+
self deny: '' = 0
|
|
640
|
+
!
|
|
641
|
+
|
|
642
|
+
testIdentity
|
|
643
|
+
self assert: 'hello' == 'hello'.
|
|
644
|
+
self deny: 'hello' == 'world'.
|
|
645
|
+
|
|
646
|
+
self assert: 'hello' == 'hello' yourself.
|
|
647
|
+
self assert: 'hello' yourself == 'hello'.
|
|
648
|
+
|
|
649
|
+
"test JS falsy value"
|
|
650
|
+
self deny: '' == 0
|
|
651
|
+
!
|
|
652
|
+
|
|
653
|
+
testIncludesSubString
|
|
654
|
+
self assert: ('amber' includesSubString: 'ber').
|
|
655
|
+
self deny: ('amber' includesSubString: 'zork').
|
|
656
|
+
!
|
|
657
|
+
|
|
658
|
+
testJoin
|
|
659
|
+
self assert: 'hello,world' equals: (',' join: #('hello' 'world'))
|
|
660
|
+
!
|
|
661
|
+
|
|
662
|
+
testSelect
|
|
663
|
+
| newCollection |
|
|
664
|
+
newCollection := 'o'.
|
|
665
|
+
self
|
|
666
|
+
assertSameContents: (self collection select: [ :each |
|
|
667
|
+
each = 'o' ])
|
|
668
|
+
as: newCollection
|
|
669
|
+
!
|
|
670
|
+
|
|
671
|
+
testSize
|
|
672
|
+
self assert: 'smalltalk' size equals: 9.
|
|
673
|
+
self assert: '' size equals: 0
|
|
674
|
+
!
|
|
675
|
+
|
|
676
|
+
testStreamContents
|
|
677
|
+
self
|
|
678
|
+
assert: 'hello world'
|
|
679
|
+
equals: (String streamContents: [ :aStream |
|
|
680
|
+
aStream
|
|
681
|
+
nextPutAll: 'hello'; space;
|
|
682
|
+
nextPutAll: 'world' ])
|
|
683
|
+
! !
|
|
684
|
+
|
|
685
|
+
!StringTest class methodsFor: 'accessing'!
|
|
686
|
+
|
|
687
|
+
collectionClass
|
|
688
|
+
^ String
|
|
689
|
+
! !
|
|
690
|
+
|
|
691
|
+
SequenceableCollectionTest subclass: #SymbolTest
|
|
692
|
+
instanceVariableNames: ''
|
|
693
|
+
package: 'Kernel-Tests'!
|
|
694
|
+
|
|
695
|
+
!SymbolTest methodsFor: 'accessing'!
|
|
696
|
+
|
|
697
|
+
collection
|
|
698
|
+
^ #hello
|
|
699
|
+
!
|
|
700
|
+
|
|
701
|
+
collectionWithDuplicates
|
|
702
|
+
^ #phhaaarorra
|
|
703
|
+
! !
|
|
704
|
+
|
|
705
|
+
!SymbolTest methodsFor: 'tests'!
|
|
706
|
+
|
|
707
|
+
testAsString
|
|
708
|
+
self assert: #hello asString equals: 'hello'
|
|
709
|
+
!
|
|
710
|
+
|
|
711
|
+
testAsSymbol
|
|
712
|
+
self assert: #hello == #hello asSymbol
|
|
713
|
+
!
|
|
714
|
+
|
|
715
|
+
testAt
|
|
716
|
+
self assert: (#hello at: 1) = 'h'.
|
|
717
|
+
self assert: (#hello at: 5) = 'o'.
|
|
718
|
+
self assert: (#hello at: 6 ifAbsent: [nil]) = nil
|
|
719
|
+
!
|
|
720
|
+
|
|
721
|
+
testAtPut
|
|
722
|
+
"Symbol instances are read-only"
|
|
723
|
+
self should: ['hello' at: 1 put: 'a'] raise: Error
|
|
724
|
+
!
|
|
725
|
+
|
|
726
|
+
testCollect
|
|
727
|
+
| newCollection |
|
|
728
|
+
newCollection := #hheelllloo.
|
|
729
|
+
self
|
|
730
|
+
assertSameContents: (self collection collect: [ :each |
|
|
731
|
+
each, each ])
|
|
732
|
+
as: newCollection
|
|
733
|
+
!
|
|
734
|
+
|
|
735
|
+
testComparing
|
|
736
|
+
self assert: #ab > #aa.
|
|
737
|
+
self deny: #ab > #ba.
|
|
738
|
+
|
|
739
|
+
self assert: #ab < #ba.
|
|
740
|
+
self deny: #bb < #ba.
|
|
741
|
+
|
|
742
|
+
self assert: #ab >= #aa.
|
|
743
|
+
self deny: #ab >= #ba.
|
|
744
|
+
|
|
745
|
+
self assert: #ab <= #ba.
|
|
746
|
+
self deny: #bb <= #ba
|
|
747
|
+
!
|
|
748
|
+
|
|
749
|
+
testCopying
|
|
750
|
+
self assert: #hello copy == #hello.
|
|
751
|
+
self assert: #hello deepCopy == #hello
|
|
752
|
+
!
|
|
753
|
+
|
|
754
|
+
testDetect
|
|
755
|
+
self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.
|
|
756
|
+
self
|
|
757
|
+
should: [ self collection detect: [ :each | each = 'z' ] ]
|
|
758
|
+
raise: Error
|
|
759
|
+
!
|
|
760
|
+
|
|
761
|
+
testEquality
|
|
762
|
+
self assert: #hello = #hello.
|
|
763
|
+
self deny: #hello = #world.
|
|
764
|
+
|
|
765
|
+
self assert: #hello = #hello yourself.
|
|
766
|
+
self assert: #hello yourself = #hello.
|
|
767
|
+
|
|
768
|
+
self deny: #hello = 'hello'.
|
|
769
|
+
self deny: 'hello' = #hello.
|
|
770
|
+
!
|
|
771
|
+
|
|
772
|
+
testIdentity
|
|
773
|
+
self assert: #hello == #hello.
|
|
774
|
+
self deny: #hello == #world.
|
|
775
|
+
|
|
776
|
+
self assert: #hello = #hello yourself.
|
|
777
|
+
self assert: #hello yourself = #hello asString asSymbol
|
|
778
|
+
!
|
|
779
|
+
|
|
780
|
+
testIsEmpty
|
|
781
|
+
self deny: self collection isEmpty.
|
|
782
|
+
self assert: '' asSymbol isEmpty
|
|
783
|
+
!
|
|
784
|
+
|
|
785
|
+
testIsSymbolIsString
|
|
786
|
+
self assert: #hello isSymbol.
|
|
787
|
+
self deny: 'hello' isSymbol.
|
|
788
|
+
self deny: #hello isString.
|
|
789
|
+
self assert: 'hello' isString
|
|
790
|
+
!
|
|
791
|
+
|
|
792
|
+
testSelect
|
|
793
|
+
| newCollection |
|
|
794
|
+
newCollection := 'o'.
|
|
795
|
+
self
|
|
796
|
+
assertSameContents: (self collection select: [ :each |
|
|
797
|
+
each = 'o' ])
|
|
798
|
+
as: newCollection
|
|
799
|
+
!
|
|
800
|
+
|
|
801
|
+
testSize
|
|
802
|
+
self assert: #a size equals: 1.
|
|
803
|
+
self assert: #aaaaa size equals: 5
|
|
804
|
+
! !
|
|
805
|
+
|
|
806
|
+
!SymbolTest class methodsFor: 'accessing'!
|
|
807
|
+
|
|
808
|
+
collectionClass
|
|
809
|
+
^ Symbol
|
|
810
|
+
! !
|
|
811
|
+
|
|
333
812
|
TestCase subclass: #JSObjectProxyTest
|
|
334
813
|
instanceVariableNames: ''
|
|
335
814
|
package: 'Kernel-Tests'!
|
|
@@ -337,7 +816,7 @@ TestCase subclass: #JSObjectProxyTest
|
|
|
337
816
|
!JSObjectProxyTest methodsFor: 'accessing'!
|
|
338
817
|
|
|
339
818
|
jsObject
|
|
340
|
-
<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}}>
|
|
819
|
+
<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: ''}>
|
|
341
820
|
! !
|
|
342
821
|
|
|
343
822
|
!JSObjectProxyTest methodsFor: 'tests'!
|
|
@@ -354,13 +833,7 @@ testMessageSend
|
|
|
354
833
|
!
|
|
355
834
|
|
|
356
835
|
testMethodWithArguments
|
|
357
|
-
self
|
|
358
|
-
|
|
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').
|
|
836
|
+
self assert: (self jsObject c: 1) equals: 1
|
|
364
837
|
!
|
|
365
838
|
|
|
366
839
|
testPrinting
|
|
@@ -368,23 +841,22 @@ testPrinting
|
|
|
368
841
|
!
|
|
369
842
|
|
|
370
843
|
testPropertyThatReturnsEmptyString
|
|
371
|
-
|
|
372
|
-
|
|
844
|
+
| object |
|
|
845
|
+
|
|
846
|
+
object := self jsObject.
|
|
847
|
+
self assert: '' equals: object d.
|
|
373
848
|
|
|
374
|
-
|
|
375
|
-
self assert: '
|
|
849
|
+
object d: 'hello'.
|
|
850
|
+
self assert: 'hello' equals: object d
|
|
376
851
|
!
|
|
377
852
|
|
|
378
853
|
testYourself
|
|
379
|
-
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
854
|
+
| object |
|
|
855
|
+
object := self jsObject
|
|
856
|
+
d: 'test';
|
|
857
|
+
yourself.
|
|
383
858
|
|
|
384
|
-
self assert:
|
|
385
|
-
|
|
386
|
-
body removeClass: 'amber'.
|
|
387
|
-
self deny: (body hasClass: 'amber').
|
|
859
|
+
self assert: object d equals: 'test'
|
|
388
860
|
! !
|
|
389
861
|
|
|
390
862
|
TestCase subclass: #NumberTest
|
|
@@ -393,6 +865,11 @@ TestCase subclass: #NumberTest
|
|
|
393
865
|
|
|
394
866
|
!NumberTest methodsFor: 'tests'!
|
|
395
867
|
|
|
868
|
+
testAbs
|
|
869
|
+
self assert: 4 abs = 4.
|
|
870
|
+
self assert: -4 abs = 4
|
|
871
|
+
!
|
|
872
|
+
|
|
396
873
|
testArithmetic
|
|
397
874
|
|
|
398
875
|
"We rely on JS here, so we won't test complex behavior, just check if
|
|
@@ -615,7 +1092,11 @@ testInstVars
|
|
|
615
1092
|
testNilUndefined
|
|
616
1093
|
"nil in Smalltalk is the undefined object in JS"
|
|
617
1094
|
|
|
618
|
-
|
|
1095
|
+
| notDefined |
|
|
1096
|
+
|
|
1097
|
+
<notDefined = undefined>.
|
|
1098
|
+
|
|
1099
|
+
self assert: nil = notDefined
|
|
619
1100
|
!
|
|
620
1101
|
|
|
621
1102
|
testYourself
|
|
@@ -795,6 +1276,22 @@ testAt
|
|
|
795
1276
|
self should: [Set new at: 1 put: 2] raise: Error
|
|
796
1277
|
!
|
|
797
1278
|
|
|
1279
|
+
testPrintString
|
|
1280
|
+
| set |
|
|
1281
|
+
set := Set new.
|
|
1282
|
+
self assert: 'a Set ()' equals: ( set printString ).
|
|
1283
|
+
set add: 1; add: 3.
|
|
1284
|
+
self assert: 'a Set (1 3)' equals: ( set printString ).
|
|
1285
|
+
set add: 'foo'.
|
|
1286
|
+
self assert: 'a Set (1 3 ''foo'')' equals: ( set printString ).
|
|
1287
|
+
set remove: 1; remove: 3.
|
|
1288
|
+
self assert: 'a Set (''foo'')' equals: ( set printString ).
|
|
1289
|
+
set add: 3.
|
|
1290
|
+
self assert: 'a Set (''foo'' 3)' equals: ( set printString ).
|
|
1291
|
+
set add: 3.
|
|
1292
|
+
self assert: 'a Set (''foo'' 3)' equals: ( set printString ).
|
|
1293
|
+
!
|
|
1294
|
+
|
|
798
1295
|
testSize
|
|
799
1296
|
self assert: Set new size equals: 0.
|
|
800
1297
|
self assert: (Set withAll: #(1 2 3 4)) size equals: 4.
|
|
@@ -816,157 +1313,6 @@ testUnicity
|
|
|
816
1313
|
self assert: set asArray equals: #(21 'hello')
|
|
817
1314
|
! !
|
|
818
1315
|
|
|
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').
|
|
832
|
-
!
|
|
833
|
-
|
|
834
|
-
testAt
|
|
835
|
-
self assert: ('hello' at: 1) = 'h'.
|
|
836
|
-
self assert: ('hello' at: 5) = 'o'.
|
|
837
|
-
self assert: ('hello' at: 6 ifAbsent: [nil]) = nil
|
|
838
|
-
!
|
|
839
|
-
|
|
840
|
-
testAtPut
|
|
841
|
-
"String instances are read-only"
|
|
842
|
-
self should: ['hello' at: 1 put: 'a'] raise: Error
|
|
843
|
-
!
|
|
844
|
-
|
|
845
|
-
testCopyWithoutAll
|
|
846
|
-
self
|
|
847
|
-
assert: 'hello world'
|
|
848
|
-
equals: ('*hello* *world*' copyWithoutAll: '*')
|
|
849
|
-
!
|
|
850
|
-
|
|
851
|
-
testEquality
|
|
852
|
-
self assert: 'hello' = 'hello'.
|
|
853
|
-
self deny: 'hello' = 'world'.
|
|
854
|
-
|
|
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'))
|
|
880
|
-
!
|
|
881
|
-
|
|
882
|
-
testSize
|
|
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'])
|
|
893
|
-
! !
|
|
894
|
-
|
|
895
|
-
TestCase subclass: #SymbolTest
|
|
896
|
-
instanceVariableNames: ''
|
|
897
|
-
package: 'Kernel-Tests'!
|
|
898
|
-
|
|
899
|
-
!SymbolTest methodsFor: 'tests'!
|
|
900
|
-
|
|
901
|
-
testAsString
|
|
902
|
-
self assert: #hello asString equals: 'hello'
|
|
903
|
-
!
|
|
904
|
-
|
|
905
|
-
testAsSymbol
|
|
906
|
-
self assert: #hello == #hello asSymbol
|
|
907
|
-
!
|
|
908
|
-
|
|
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
|
-
!
|
|
914
|
-
|
|
915
|
-
testAtPut
|
|
916
|
-
"Symbol instances are read-only"
|
|
917
|
-
self should: ['hello' at: 1 put: 'a'] raise: Error
|
|
918
|
-
!
|
|
919
|
-
|
|
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
|
|
932
|
-
!
|
|
933
|
-
|
|
934
|
-
testCopying
|
|
935
|
-
self assert: #hello copy == #hello.
|
|
936
|
-
self assert: #hello deepCopy == #hello
|
|
937
|
-
!
|
|
938
|
-
|
|
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
|
|
968
|
-
! !
|
|
969
|
-
|
|
970
1316
|
TestCase subclass: #UndefinedTest
|
|
971
1317
|
instanceVariableNames: ''
|
|
972
1318
|
package: 'Kernel-Tests'!
|