resin 0.3.1 → 0.4.0
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/bin/amberc +10 -350
- data/amber/js/Benchfib.deploy.js +80 -89
- data/amber/js/Benchfib.js +80 -89
- data/amber/js/Canvas.deploy.js +558 -545
- data/amber/js/Canvas.js +563 -545
- data/amber/js/Compiler-AST.deploy.js +431 -243
- data/amber/js/Compiler-AST.js +487 -244
- data/amber/js/Compiler-Core.deploy.js +201 -1045
- data/amber/js/Compiler-Core.js +208 -1207
- data/amber/js/Compiler-Exceptions.deploy.js +37 -18
- data/amber/js/Compiler-Exceptions.js +42 -18
- data/amber/js/Compiler-IR.deploy.js +1071 -774
- data/amber/js/Compiler-IR.js +1194 -848
- data/amber/js/Compiler-Inlining.deploy.js +395 -373
- data/amber/js/Compiler-Inlining.js +395 -373
- data/amber/js/Compiler-Interpreter.deploy.js +1202 -0
- data/amber/js/Compiler-Interpreter.js +1631 -0
- data/amber/js/Compiler-Semantic.deploy.js +695 -600
- data/amber/js/Compiler-Semantic.js +721 -611
- data/amber/js/Compiler-Tests.deploy.js +699 -376
- data/amber/js/Compiler-Tests.js +834 -381
- data/amber/js/Compiler.deploy.js +8563 -1805
- data/amber/js/Compiler.js +11476 -2633
- data/amber/js/Examples.deploy.js +29 -29
- data/amber/js/Examples.js +29 -29
- data/amber/js/IDE.deploy.js +3292 -2649
- data/amber/js/IDE.js +3318 -2710
- data/amber/js/Importer-Exporter.deploy.js +393 -349
- data/amber/js/Importer-Exporter.js +398 -354
- data/amber/js/Kernel-Announcements.deploy.js +53 -44
- data/amber/js/Kernel-Announcements.js +55 -44
- data/amber/js/Kernel-Classes.deploy.js +566 -368
- data/amber/js/Kernel-Classes.js +660 -402
- data/amber/js/Kernel-Collections.deploy.js +1149 -1098
- data/amber/js/Kernel-Collections.js +1183 -1116
- data/amber/js/Kernel-Exceptions.deploy.js +173 -75
- data/amber/js/Kernel-Exceptions.js +215 -77
- data/amber/js/Kernel-Methods.deploy.js +530 -313
- data/amber/js/Kernel-Methods.js +632 -338
- data/amber/js/Kernel-Objects.deploy.js +1734 -1577
- data/amber/js/Kernel-Objects.js +1867 -1654
- data/amber/js/Kernel-Tests.deploy.js +1416 -973
- data/amber/js/Kernel-Tests.js +1495 -981
- data/amber/js/Kernel-Transcript.deploy.js +23 -24
- data/amber/js/Kernel-Transcript.js +25 -26
- data/amber/js/SUnit-Tests.deploy.js +402 -0
- data/amber/js/SUnit-Tests.js +518 -0
- data/amber/js/SUnit.deploy.js +535 -237
- data/amber/js/SUnit.js +634 -246
- data/amber/js/amber.js +90 -53
- data/amber/js/boot.js +441 -255
- data/amber/js/init.js +1 -3
- data/amber/js/lib/CodeMirror/codemirror.css +3 -0
- data/amber/js/lib/CodeMirror/codemirror.js +104 -55
- data/amber/js/lib/peg-0.7.0.min.js +9 -0
- data/amber/js/parser.js +1504 -802
- data/amber/js/parser.pegjs +170 -165
- data/amber/st/Canvas.st +6 -0
- data/amber/st/Compiler-AST.st +54 -3
- data/amber/st/Compiler-Core.st +6 -551
- data/amber/st/Compiler-Exceptions.st +4 -0
- data/amber/st/Compiler-IR.st +205 -87
- data/amber/st/Compiler-Interpreter.st +597 -0
- data/amber/st/Compiler-Semantic.st +46 -21
- data/amber/st/Compiler-Tests.st +254 -7
- data/amber/st/Compiler.st +3172 -1541
- data/amber/st/IDE.st +57 -93
- data/amber/st/Importer-Exporter.st +4 -7
- data/amber/st/Kernel-Announcements.st +8 -0
- data/amber/st/Kernel-Classes.st +149 -40
- data/amber/st/Kernel-Collections.st +43 -32
- data/amber/st/Kernel-Exceptions.st +70 -1
- data/amber/st/Kernel-Methods.st +165 -27
- data/amber/st/Kernel-Objects.st +215 -140
- data/amber/st/Kernel-Tests.st +195 -10
- data/amber/st/Kernel-Transcript.st +1 -3
- data/amber/st/SUnit-Tests.st +186 -0
- data/amber/st/SUnit.st +186 -14
- data/bin/resin +6 -0
- data/lib/resin/cli.rb +19 -0
- metadata +41 -25
- data/amber/js/lib/peg-0.6.2.min.js +0 -2
- data/bin/resin-compile +0 -6
- data/bin/runresin +0 -12
data/amber/st/Kernel-Tests.st
CHANGED
@@ -5,18 +5,41 @@ TestCase subclass: #BlockClosureTest
|
|
5
5
|
|
6
6
|
!BlockClosureTest methodsFor: 'tests'!
|
7
7
|
|
8
|
+
testCanClearInterval
|
9
|
+
self shouldnt: [([Error new signal] valueWithInterval: 0) clearInterval] raise: Error
|
10
|
+
!
|
11
|
+
|
12
|
+
testCanClearTimeout
|
13
|
+
self shouldnt: [([Error new signal] valueWithTimeout: 0) clearTimeout] raise: Error
|
14
|
+
!
|
15
|
+
|
8
16
|
testCompiledSource
|
9
17
|
self assert: ([1+1] compiledSource includesSubString: 'function')
|
10
18
|
!
|
11
19
|
|
12
20
|
testEnsure
|
13
|
-
self assert: ([
|
21
|
+
self assert: 3 equals: ([3] ensure: [4])
|
14
22
|
!
|
15
23
|
|
16
24
|
testEnsureRaises
|
17
25
|
self should: [[Error new signal] ensure: [true]] raise: Error
|
18
26
|
!
|
19
27
|
|
28
|
+
testExceptionSemantics
|
29
|
+
"See https://github.com/NicolasPetton/amber/issues/314"
|
30
|
+
self timeout: 100.
|
31
|
+
|
32
|
+
(self async: [
|
33
|
+
[
|
34
|
+
self assert: true.
|
35
|
+
Error signal.
|
36
|
+
"The following should *not* be run"
|
37
|
+
self deny: true.
|
38
|
+
self finished.
|
39
|
+
] on: Error do: [ :ex | self finished ]
|
40
|
+
]) valueWithTimeout: 0
|
41
|
+
!
|
42
|
+
|
20
43
|
testNumArgs
|
21
44
|
self assert: [] numArgs equals: 0.
|
22
45
|
self assert: [:a :b | ] numArgs equals: 2
|
@@ -121,6 +144,21 @@ testIfTrueIfFalse
|
|
121
144
|
self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.
|
122
145
|
!
|
123
146
|
|
147
|
+
testIfTrueIfFalseWithBoxing
|
148
|
+
|
149
|
+
self assert: (true yourself ifTrue: ['alternative block']) = 'alternative block'.
|
150
|
+
self assert: (true yourself ifFalse: ['alternative block']) = nil.
|
151
|
+
|
152
|
+
self assert: (false yourself ifTrue: ['alternative block']) = nil.
|
153
|
+
self assert: (false yourself ifFalse: ['alternative block']) = 'alternative block'.
|
154
|
+
|
155
|
+
self assert: (false yourself ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.
|
156
|
+
self assert: (false yourself ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.
|
157
|
+
|
158
|
+
self assert: (true yourself ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.
|
159
|
+
self assert: (true yourself ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.
|
160
|
+
!
|
161
|
+
|
124
162
|
testLogic
|
125
163
|
|
126
164
|
"Trivial logic table"
|
@@ -157,9 +195,7 @@ testLogicKeywords
|
|
157
195
|
!
|
158
196
|
|
159
197
|
testNonBooleanError
|
160
|
-
|
161
|
-
b := < '' >.
|
162
|
-
self should: [nonBoolean ifTrue: [] ifFalse: []] raise: NonBooleanReceiver
|
198
|
+
self should: [ '' ifTrue: [] ifFalse: [] ] raise: NonBooleanReceiver
|
163
199
|
! !
|
164
200
|
|
165
201
|
TestCase subclass: #ClassBuilderTest
|
@@ -185,6 +221,66 @@ testClassCopy
|
|
185
221
|
self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys
|
186
222
|
!
|
187
223
|
|
224
|
+
testClassMigration
|
225
|
+
| instance oldClass |
|
226
|
+
|
227
|
+
oldClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
|
228
|
+
instance := (Smalltalk current at: 'ObjectMock2') new.
|
229
|
+
|
230
|
+
"Change the superclass of ObjectMock2"
|
231
|
+
ObjectMock subclass: (Smalltalk current at: 'ObjectMock2')
|
232
|
+
instanceVariableNames: ''
|
233
|
+
package: 'Kernel-Tests'.
|
234
|
+
|
235
|
+
self deny: oldClass == ObjectMock2.
|
236
|
+
|
237
|
+
self assert: ObjectMock2 superclass == ObjectMock.
|
238
|
+
self assert: ObjectMock2 instanceVariableNames isEmpty.
|
239
|
+
self assert: ObjectMock2 selectors equals: oldClass selectors.
|
240
|
+
self assert: ObjectMock2 comment equals: oldClass comment.
|
241
|
+
self assert: ObjectMock2 package name equals: 'Kernel-Tests'.
|
242
|
+
|
243
|
+
self deny: instance class == ObjectMock2.
|
244
|
+
self assert: instance class name equals: 'OldObjectMock2'.
|
245
|
+
|
246
|
+
self assert: (Smalltalk current at: 'OldObjectMock2') isNil.
|
247
|
+
|
248
|
+
Smalltalk current removeClass: ObjectMock2
|
249
|
+
!
|
250
|
+
|
251
|
+
testClassMigrationWithClassInstanceVariables
|
252
|
+
|
253
|
+
builder copyClass: ObjectMock named: 'ObjectMock2'.
|
254
|
+
ObjectMock2 class instanceVariableNames: 'foo bar'.
|
255
|
+
|
256
|
+
"Change the superclass of ObjectMock2"
|
257
|
+
ObjectMock subclass: (Smalltalk current at: 'ObjectMock2')
|
258
|
+
instanceVariableNames: ''
|
259
|
+
package: 'Kernel-Tests'.
|
260
|
+
|
261
|
+
self assert: ObjectMock2 class instanceVariableNames equals: #('foo' 'bar').
|
262
|
+
|
263
|
+
Smalltalk current removeClass: ObjectMock2
|
264
|
+
!
|
265
|
+
|
266
|
+
testClassMigrationWithSubclasses
|
267
|
+
|
268
|
+
builder copyClass: ObjectMock named: 'ObjectMock2'.
|
269
|
+
ObjectMock2 subclass: 'ObjectMock3' instanceVariableNames: '' package: 'Kernel-Tests'.
|
270
|
+
ObjectMock3 subclass: 'ObjectMock4' instanceVariableNames: '' package: 'Kernel-Tests'.
|
271
|
+
|
272
|
+
"Change the superclass of ObjectMock2"
|
273
|
+
ObjectMock subclass: (Smalltalk current at: 'ObjectMock2')
|
274
|
+
instanceVariableNames: ''
|
275
|
+
package: 'Kernel-Tests'.
|
276
|
+
|
277
|
+
self assert: (ObjectMock subclasses includes: ObjectMock2).
|
278
|
+
self assert: (ObjectMock2 subclasses includes: ObjectMock3).
|
279
|
+
self assert: (ObjectMock3 subclasses includes: ObjectMock4).
|
280
|
+
|
281
|
+
ObjectMock allSubclasses do: [ :each | Smalltalk current removeClass: each ]
|
282
|
+
!
|
283
|
+
|
188
284
|
testInstanceVariableNames
|
189
285
|
self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')
|
190
286
|
! !
|
@@ -826,7 +922,7 @@ TestCase subclass: #JSObjectProxyTest
|
|
826
922
|
!JSObjectProxyTest methodsFor: 'accessing'!
|
827
923
|
|
828
924
|
jsObject
|
829
|
-
<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: ''}>
|
925
|
+
<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null}>
|
830
926
|
! !
|
831
927
|
|
832
928
|
!JSObjectProxyTest methodsFor: 'tests'!
|
@@ -860,6 +956,14 @@ testPropertyThatReturnsEmptyString
|
|
860
956
|
self assert: 'hello' equals: object d
|
861
957
|
!
|
862
958
|
|
959
|
+
testPropertyThatReturnsUndefined
|
960
|
+
| object |
|
961
|
+
|
962
|
+
object := self jsObject.
|
963
|
+
self shouldnt: [ object e ] raise: MessageNotUnderstood.
|
964
|
+
self assert: object e isNil
|
965
|
+
!
|
966
|
+
|
863
967
|
testYourself
|
864
968
|
| object |
|
865
969
|
object := self jsObject
|
@@ -869,6 +973,29 @@ testYourself
|
|
869
973
|
self assert: object d equals: 'test'
|
870
974
|
! !
|
871
975
|
|
976
|
+
TestCase subclass: #JavaScriptExceptionTest
|
977
|
+
instanceVariableNames: ''
|
978
|
+
package: 'Kernel-Tests'!
|
979
|
+
|
980
|
+
!JavaScriptExceptionTest methodsFor: 'helpers'!
|
981
|
+
|
982
|
+
throwException
|
983
|
+
<throw 'test'>
|
984
|
+
! !
|
985
|
+
|
986
|
+
!JavaScriptExceptionTest methodsFor: 'testing'!
|
987
|
+
|
988
|
+
testCatchingException
|
989
|
+
[ self throwException ]
|
990
|
+
on: Error
|
991
|
+
do: [ :error |
|
992
|
+
self assert: error exception = 'test' ]
|
993
|
+
!
|
994
|
+
|
995
|
+
testRaisingException
|
996
|
+
self should: [ self throwException ] raise: JavaScriptException
|
997
|
+
! !
|
998
|
+
|
872
999
|
TestCase subclass: #NumberTest
|
873
1000
|
instanceVariableNames: ''
|
874
1001
|
package: 'Kernel-Tests'!
|
@@ -931,6 +1058,17 @@ testEquality
|
|
931
1058
|
self deny: 0 = ''
|
932
1059
|
!
|
933
1060
|
|
1061
|
+
testHexNumbers
|
1062
|
+
|
1063
|
+
self assert: 16r9 = 9.
|
1064
|
+
self assert: 16rA truncated = 10.
|
1065
|
+
self assert: 16rB truncated = 11.
|
1066
|
+
self assert: 16rC truncated = 12.
|
1067
|
+
self assert: 16rD truncated = 13.
|
1068
|
+
self assert: 16rE truncated = 14.
|
1069
|
+
self assert: 16rF truncated = 15
|
1070
|
+
!
|
1071
|
+
|
934
1072
|
testIdentity
|
935
1073
|
self assert: 1 == 1.
|
936
1074
|
self assert: 0 == 0.
|
@@ -943,6 +1081,51 @@ testIdentity
|
|
943
1081
|
self deny: 1 == 2
|
944
1082
|
!
|
945
1083
|
|
1084
|
+
testInvalidHexNumbers
|
1085
|
+
|
1086
|
+
self should: [16rG] raise: MessageNotUnderstood.
|
1087
|
+
self should: [16rg] raise: MessageNotUnderstood.
|
1088
|
+
self should: [16rH] raise: MessageNotUnderstood.
|
1089
|
+
self should: [16rh] raise: MessageNotUnderstood.
|
1090
|
+
self should: [16rI] raise: MessageNotUnderstood.
|
1091
|
+
self should: [16ri] raise: MessageNotUnderstood.
|
1092
|
+
self should: [16rJ] raise: MessageNotUnderstood.
|
1093
|
+
self should: [16rj] raise: MessageNotUnderstood.
|
1094
|
+
self should: [16rK] raise: MessageNotUnderstood.
|
1095
|
+
self should: [16rk] raise: MessageNotUnderstood.
|
1096
|
+
self should: [16rL] raise: MessageNotUnderstood.
|
1097
|
+
self should: [16rl] raise: MessageNotUnderstood.
|
1098
|
+
self should: [16rM] raise: MessageNotUnderstood.
|
1099
|
+
self should: [16rm] raise: MessageNotUnderstood.
|
1100
|
+
self should: [16rN] raise: MessageNotUnderstood.
|
1101
|
+
self should: [16rn] raise: MessageNotUnderstood.
|
1102
|
+
self should: [16rO] raise: MessageNotUnderstood.
|
1103
|
+
self should: [16ro] raise: MessageNotUnderstood.
|
1104
|
+
self should: [16rP] raise: MessageNotUnderstood.
|
1105
|
+
self should: [16rp] raise: MessageNotUnderstood.
|
1106
|
+
self should: [16rQ] raise: MessageNotUnderstood.
|
1107
|
+
self should: [16rq] raise: MessageNotUnderstood.
|
1108
|
+
self should: [16rR] raise: MessageNotUnderstood.
|
1109
|
+
self should: [16rr] raise: MessageNotUnderstood.
|
1110
|
+
self should: [16rS] raise: MessageNotUnderstood.
|
1111
|
+
self should: [16rs] raise: MessageNotUnderstood.
|
1112
|
+
self should: [16rT] raise: MessageNotUnderstood.
|
1113
|
+
self should: [16rt] raise: MessageNotUnderstood.
|
1114
|
+
self should: [16rU] raise: MessageNotUnderstood.
|
1115
|
+
self should: [16ru] raise: MessageNotUnderstood.
|
1116
|
+
self should: [16rV] raise: MessageNotUnderstood.
|
1117
|
+
self should: [16rv] raise: MessageNotUnderstood.
|
1118
|
+
self should: [16rW] raise: MessageNotUnderstood.
|
1119
|
+
self should: [16rw] raise: MessageNotUnderstood.
|
1120
|
+
self should: [16rX] raise: MessageNotUnderstood.
|
1121
|
+
self should: [16rx] raise: MessageNotUnderstood.
|
1122
|
+
self should: [16rY] raise: MessageNotUnderstood.
|
1123
|
+
self should: [16ry] raise: MessageNotUnderstood.
|
1124
|
+
self should: [16rZ] raise: MessageNotUnderstood.
|
1125
|
+
self should: [16rz] raise: MessageNotUnderstood.
|
1126
|
+
self should: [16rABcdEfZ] raise: MessageNotUnderstood.
|
1127
|
+
!
|
1128
|
+
|
946
1129
|
testMinMax
|
947
1130
|
|
948
1131
|
self assert: (2 max: 5) equals: 5.
|
@@ -1019,6 +1202,8 @@ testTruncated
|
|
1019
1202
|
Object subclass: #ObjectMock
|
1020
1203
|
instanceVariableNames: 'foo bar'
|
1021
1204
|
package: 'Kernel-Tests'!
|
1205
|
+
!ObjectMock commentStamp!
|
1206
|
+
ObjectMock is there only to perform tests on classes.!
|
1022
1207
|
|
1023
1208
|
!ObjectMock methodsFor: 'not yet classified'!
|
1024
1209
|
|
@@ -1036,6 +1221,10 @@ TestCase subclass: #ObjectTest
|
|
1036
1221
|
|
1037
1222
|
!ObjectTest methodsFor: 'tests'!
|
1038
1223
|
|
1224
|
+
notDefined
|
1225
|
+
<return undefined;>
|
1226
|
+
!
|
1227
|
+
|
1039
1228
|
testBasicAccess
|
1040
1229
|
| o |
|
1041
1230
|
o := Object new.
|
@@ -1102,11 +1291,7 @@ testInstVars
|
|
1102
1291
|
testNilUndefined
|
1103
1292
|
"nil in Smalltalk is the undefined object in JS"
|
1104
1293
|
|
1105
|
-
|
1106
|
-
|
1107
|
-
<notDefined = undefined>.
|
1108
|
-
|
1109
|
-
self assert: nil = notDefined
|
1294
|
+
self assert: nil = self notDefined
|
1110
1295
|
!
|
1111
1296
|
|
1112
1297
|
testYourself
|
@@ -0,0 +1,186 @@
|
|
1
|
+
Smalltalk current createPackage: 'SUnit-Tests' properties: #{}!
|
2
|
+
TestCase subclass: #ExampleSetTest
|
3
|
+
instanceVariableNames: 'empty full'
|
4
|
+
package: 'SUnit-Tests'!
|
5
|
+
!ExampleSetTest commentStamp!
|
6
|
+
ExampleSetTest is taken from Pharo 1.4.
|
7
|
+
|
8
|
+
THe purpose of this class is to demonstrate a simple use case of the test framework.!
|
9
|
+
|
10
|
+
!ExampleSetTest methodsFor: 'running'!
|
11
|
+
|
12
|
+
setUp
|
13
|
+
empty := Set new.
|
14
|
+
full := Set with: 5 with: #abc
|
15
|
+
! !
|
16
|
+
|
17
|
+
!ExampleSetTest methodsFor: 'tests'!
|
18
|
+
|
19
|
+
testAdd
|
20
|
+
empty add: 5.
|
21
|
+
self assert: (empty includes: 5)
|
22
|
+
!
|
23
|
+
|
24
|
+
testGrow
|
25
|
+
empty addAll: (1 to: 100).
|
26
|
+
self assert: empty size = 100
|
27
|
+
!
|
28
|
+
|
29
|
+
testIllegal
|
30
|
+
self
|
31
|
+
should: [empty at: 5]
|
32
|
+
raise: Error.
|
33
|
+
self
|
34
|
+
should: [empty at: 5 put: #abc]
|
35
|
+
raise: Error
|
36
|
+
!
|
37
|
+
|
38
|
+
testIncludes
|
39
|
+
self assert: (full includes: 5).
|
40
|
+
self assert: (full includes: #abc)
|
41
|
+
!
|
42
|
+
|
43
|
+
testOccurrences
|
44
|
+
self assert: (empty occurrencesOf: 0) = 0.
|
45
|
+
self assert: (full occurrencesOf: 5) = 1.
|
46
|
+
full add: 5.
|
47
|
+
self assert: (full occurrencesOf: 5) = 1
|
48
|
+
!
|
49
|
+
|
50
|
+
testRemove
|
51
|
+
full remove: 5.
|
52
|
+
self assert: (full includes: #abc).
|
53
|
+
self deny: (full includes: 5)
|
54
|
+
! !
|
55
|
+
|
56
|
+
TestCase subclass: #SUnitAsyncTest
|
57
|
+
instanceVariableNames: 'flag'
|
58
|
+
package: 'SUnit-Tests'!
|
59
|
+
|
60
|
+
!SUnitAsyncTest methodsFor: 'helpers'!
|
61
|
+
|
62
|
+
fakeError
|
63
|
+
flag := 'bad'.
|
64
|
+
self timeout: 10.
|
65
|
+
flag := (self async: [ flag := 'ok'. self error: 'Intentional' ]) valueWithTimeout: 5
|
66
|
+
!
|
67
|
+
|
68
|
+
fakeErrorFailingInTearDown
|
69
|
+
flag := 'bad'.
|
70
|
+
self timeout: 10.
|
71
|
+
flag := (self async: [ self error: 'Intentional' ]) valueWithTimeout: 5
|
72
|
+
!
|
73
|
+
|
74
|
+
fakeFailure
|
75
|
+
flag := 'bad'.
|
76
|
+
self timeout: 10.
|
77
|
+
flag := (self async: [ flag := 'ok'. self assert: false ]) valueWithTimeout: 5
|
78
|
+
!
|
79
|
+
|
80
|
+
fakeMultipleTimeoutFailing
|
81
|
+
self timeout: 100.
|
82
|
+
(self async: [
|
83
|
+
self timeout: 5.
|
84
|
+
(self async: [ self finished ]) valueWithTimeout: 10
|
85
|
+
]) valueWithTimeout: 5
|
86
|
+
!
|
87
|
+
|
88
|
+
fakeMultipleTimeoutPassing
|
89
|
+
self timeout: 10.
|
90
|
+
(self async: [
|
91
|
+
self timeout: 20.
|
92
|
+
(self async: [ self finished ]) valueWithTimeout: 10
|
93
|
+
]) valueWithTimeout: 5
|
94
|
+
!
|
95
|
+
|
96
|
+
fakeTimeout
|
97
|
+
self timeout: 4.
|
98
|
+
(self async: [ self finished ]) valueWithTimeout: 5
|
99
|
+
! !
|
100
|
+
|
101
|
+
!SUnitAsyncTest methodsFor: 'private'!
|
102
|
+
|
103
|
+
sortedSelectors: aCollection
|
104
|
+
^(aCollection collect: [:each | each selector]) sorted
|
105
|
+
! !
|
106
|
+
|
107
|
+
!SUnitAsyncTest methodsFor: 'running'!
|
108
|
+
|
109
|
+
setUp
|
110
|
+
flag := 'ok'
|
111
|
+
!
|
112
|
+
|
113
|
+
tearDown
|
114
|
+
self assert: 'ok' equals: flag
|
115
|
+
! !
|
116
|
+
|
117
|
+
!SUnitAsyncTest methodsFor: 'tests'!
|
118
|
+
|
119
|
+
testAsyncErrorsAndFailures
|
120
|
+
| suite runner result assertBlock |
|
121
|
+
suite := #('fakeError' 'fakeErrorFailingInTearDown' 'fakeFailure' 'testPass') collect: [ :each | self class selector: each ].
|
122
|
+
runner := TestSuiteRunner on: suite.
|
123
|
+
self timeout: 200.
|
124
|
+
result := runner result.
|
125
|
+
assertBlock := self async: [
|
126
|
+
self assert: #('fakeError') equals: (self sortedSelectors: result errors).
|
127
|
+
self assert: #('fakeErrorFailingInTearDown' 'fakeFailure') equals: (self sortedSelectors: result failures).
|
128
|
+
self finished
|
129
|
+
].
|
130
|
+
runner announcer on: ResultAnnouncement do: [:ann |
|
131
|
+
ann result == result ifTrue: [ result runs = result total ifTrue: assertBlock ]].
|
132
|
+
runner run
|
133
|
+
!
|
134
|
+
|
135
|
+
testAsyncNeedsTimeout
|
136
|
+
self should: [ self async: [ ] ] raise: Error.
|
137
|
+
self timeout: 0.
|
138
|
+
self shouldnt: [ self async: [ ] ] raise: Error.
|
139
|
+
self finished
|
140
|
+
!
|
141
|
+
|
142
|
+
testFinishedNeedsTimeout
|
143
|
+
self should: [ self finished ] raise: Error.
|
144
|
+
self timeout: 0.
|
145
|
+
self shouldnt: [ self finished ] raise: Error.
|
146
|
+
!
|
147
|
+
|
148
|
+
testIsAsyncReturnsCorrectValues
|
149
|
+
self deny: self isAsync.
|
150
|
+
self timeout: 0.
|
151
|
+
self assert: self isAsync.
|
152
|
+
self finished.
|
153
|
+
self deny: self isAsync
|
154
|
+
!
|
155
|
+
|
156
|
+
testPass
|
157
|
+
flag := 'bad'.
|
158
|
+
self timeout: 10.
|
159
|
+
flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5
|
160
|
+
!
|
161
|
+
|
162
|
+
testTimeouts
|
163
|
+
| suite runner result assertBlock |
|
164
|
+
suite := #('fakeTimeout' 'fakeMultipleTimeoutFailing' 'fakeMultipleTimeoutPassing' 'testPass') collect: [ :each | self class selector: each ].
|
165
|
+
runner := TestSuiteRunner on: suite.
|
166
|
+
self timeout: 200.
|
167
|
+
result := runner result.
|
168
|
+
assertBlock := self async: [
|
169
|
+
self assert: result errors isEmpty.
|
170
|
+
self assert: #('fakeMultipleTimeoutFailing' 'fakeTimeout') equals: (self sortedSelectors: result failures).
|
171
|
+
self finished
|
172
|
+
].
|
173
|
+
runner announcer on: ResultAnnouncement do: [:ann |
|
174
|
+
ann result == result ifTrue: [ result runs = result total ifTrue: assertBlock ]].
|
175
|
+
runner run
|
176
|
+
!
|
177
|
+
|
178
|
+
testTwoAsyncPassesWithFinishedOnlyOneIsRun
|
179
|
+
| x |
|
180
|
+
flag := 'bad'.
|
181
|
+
self timeout: 10.
|
182
|
+
x := 0.
|
183
|
+
flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.
|
184
|
+
flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: 1 equals: x ]) valueWithTimeout: 0.
|
185
|
+
! !
|
186
|
+
|