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.
Files changed (84) hide show
  1. data/amber/bin/amberc +10 -350
  2. data/amber/js/Benchfib.deploy.js +80 -89
  3. data/amber/js/Benchfib.js +80 -89
  4. data/amber/js/Canvas.deploy.js +558 -545
  5. data/amber/js/Canvas.js +563 -545
  6. data/amber/js/Compiler-AST.deploy.js +431 -243
  7. data/amber/js/Compiler-AST.js +487 -244
  8. data/amber/js/Compiler-Core.deploy.js +201 -1045
  9. data/amber/js/Compiler-Core.js +208 -1207
  10. data/amber/js/Compiler-Exceptions.deploy.js +37 -18
  11. data/amber/js/Compiler-Exceptions.js +42 -18
  12. data/amber/js/Compiler-IR.deploy.js +1071 -774
  13. data/amber/js/Compiler-IR.js +1194 -848
  14. data/amber/js/Compiler-Inlining.deploy.js +395 -373
  15. data/amber/js/Compiler-Inlining.js +395 -373
  16. data/amber/js/Compiler-Interpreter.deploy.js +1202 -0
  17. data/amber/js/Compiler-Interpreter.js +1631 -0
  18. data/amber/js/Compiler-Semantic.deploy.js +695 -600
  19. data/amber/js/Compiler-Semantic.js +721 -611
  20. data/amber/js/Compiler-Tests.deploy.js +699 -376
  21. data/amber/js/Compiler-Tests.js +834 -381
  22. data/amber/js/Compiler.deploy.js +8563 -1805
  23. data/amber/js/Compiler.js +11476 -2633
  24. data/amber/js/Examples.deploy.js +29 -29
  25. data/amber/js/Examples.js +29 -29
  26. data/amber/js/IDE.deploy.js +3292 -2649
  27. data/amber/js/IDE.js +3318 -2710
  28. data/amber/js/Importer-Exporter.deploy.js +393 -349
  29. data/amber/js/Importer-Exporter.js +398 -354
  30. data/amber/js/Kernel-Announcements.deploy.js +53 -44
  31. data/amber/js/Kernel-Announcements.js +55 -44
  32. data/amber/js/Kernel-Classes.deploy.js +566 -368
  33. data/amber/js/Kernel-Classes.js +660 -402
  34. data/amber/js/Kernel-Collections.deploy.js +1149 -1098
  35. data/amber/js/Kernel-Collections.js +1183 -1116
  36. data/amber/js/Kernel-Exceptions.deploy.js +173 -75
  37. data/amber/js/Kernel-Exceptions.js +215 -77
  38. data/amber/js/Kernel-Methods.deploy.js +530 -313
  39. data/amber/js/Kernel-Methods.js +632 -338
  40. data/amber/js/Kernel-Objects.deploy.js +1734 -1577
  41. data/amber/js/Kernel-Objects.js +1867 -1654
  42. data/amber/js/Kernel-Tests.deploy.js +1416 -973
  43. data/amber/js/Kernel-Tests.js +1495 -981
  44. data/amber/js/Kernel-Transcript.deploy.js +23 -24
  45. data/amber/js/Kernel-Transcript.js +25 -26
  46. data/amber/js/SUnit-Tests.deploy.js +402 -0
  47. data/amber/js/SUnit-Tests.js +518 -0
  48. data/amber/js/SUnit.deploy.js +535 -237
  49. data/amber/js/SUnit.js +634 -246
  50. data/amber/js/amber.js +90 -53
  51. data/amber/js/boot.js +441 -255
  52. data/amber/js/init.js +1 -3
  53. data/amber/js/lib/CodeMirror/codemirror.css +3 -0
  54. data/amber/js/lib/CodeMirror/codemirror.js +104 -55
  55. data/amber/js/lib/peg-0.7.0.min.js +9 -0
  56. data/amber/js/parser.js +1504 -802
  57. data/amber/js/parser.pegjs +170 -165
  58. data/amber/st/Canvas.st +6 -0
  59. data/amber/st/Compiler-AST.st +54 -3
  60. data/amber/st/Compiler-Core.st +6 -551
  61. data/amber/st/Compiler-Exceptions.st +4 -0
  62. data/amber/st/Compiler-IR.st +205 -87
  63. data/amber/st/Compiler-Interpreter.st +597 -0
  64. data/amber/st/Compiler-Semantic.st +46 -21
  65. data/amber/st/Compiler-Tests.st +254 -7
  66. data/amber/st/Compiler.st +3172 -1541
  67. data/amber/st/IDE.st +57 -93
  68. data/amber/st/Importer-Exporter.st +4 -7
  69. data/amber/st/Kernel-Announcements.st +8 -0
  70. data/amber/st/Kernel-Classes.st +149 -40
  71. data/amber/st/Kernel-Collections.st +43 -32
  72. data/amber/st/Kernel-Exceptions.st +70 -1
  73. data/amber/st/Kernel-Methods.st +165 -27
  74. data/amber/st/Kernel-Objects.st +215 -140
  75. data/amber/st/Kernel-Tests.st +195 -10
  76. data/amber/st/Kernel-Transcript.st +1 -3
  77. data/amber/st/SUnit-Tests.st +186 -0
  78. data/amber/st/SUnit.st +186 -14
  79. data/bin/resin +6 -0
  80. data/lib/resin/cli.rb +19 -0
  81. metadata +41 -25
  82. data/amber/js/lib/peg-0.6.2.min.js +0 -2
  83. data/bin/resin-compile +0 -6
  84. data/bin/runresin +0 -12
@@ -7,8 +7,10 @@ selector: "result",
7
7
  category: 'accessing',
8
8
  fn: function (){
9
9
  var self=this;
10
- return self["@result"];
11
- },
10
+ return smalltalk.withContext(function($ctx1) {
11
+ $1=self["@result"];
12
+ return $1;
13
+ }, function($ctx1) {$ctx1.fill(self,"result",{}, smalltalk.ResultAnnouncement)})},
12
14
  args: [],
13
15
  source: "result\x0a\x09^result",
14
16
  messageSends: [],
@@ -23,8 +25,8 @@ selector: "result:",
23
25
  category: 'accessing',
24
26
  fn: function (aTestResult){
25
27
  var self=this;
26
- self["@result"]=aTestResult;
27
- return self},
28
+ return smalltalk.withContext(function($ctx1) {
29
+ return self}, function($ctx1) {$ctx1.fill(self,"result:",{aTestResult:aTestResult}, smalltalk.ResultAnnouncement)})},
28
30
  args: ["aTestResult"],
29
31
  source: "result: aTestResult\x0a\x09result := aTestResult",
30
32
  messageSends: [],
@@ -34,17 +36,17 @@ smalltalk.ResultAnnouncement);
34
36
 
35
37
 
36
38
 
37
- smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector'], 'SUnit');
39
+ smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector', 'asyncTimeout', 'context'], 'SUnit');
40
+ smalltalk.TestCase.comment="A TestCase is an implementation of the command pattern to run a test. \x0a\x0a`TestCase` instances are created with the class method `#selector:`, \x0apassing the symbol that names the method to be executed when the test case runs.\x0a\x0aWhen you discover a new fixture, subclass `TestCase` and create a `#test...` method for the first test. \x0aAs that method develops and more `#test...` methods are added, you will find yourself refactoring temps \x0ainto instance variables for the objects in the fixture and overriding `#setUp` to initialize these variables. \x0aAs required, override `#tearDown` to nil references, release objects and deallocate."
38
41
  smalltalk.addMethod(
39
42
  "_assert_",
40
43
  smalltalk.method({
41
44
  selector: "assert:",
42
45
  category: 'testing',
43
- fn: function (aBoolean) {
44
- var self = this;
45
- smalltalk.send(self, "_assert_description_", [aBoolean, "Assertion failed"]);
46
- return self;
47
- },
46
+ fn: function (aBoolean){
47
+ var self=this;
48
+ return smalltalk.withContext(function($ctx1) {
49
+ return self}, function($ctx1) {$ctx1.fill(self,"assert:",{aBoolean:aBoolean}, smalltalk.TestCase)})},
48
50
  args: ["aBoolean"],
49
51
  source: "assert: aBoolean\x0a\x09self assert: aBoolean description: 'Assertion failed'",
50
52
  messageSends: ["assert:description:"],
@@ -57,13 +59,14 @@ smalltalk.addMethod(
57
59
  smalltalk.method({
58
60
  selector: "assert:description:",
59
61
  category: 'testing',
60
- fn: function (aBoolean, aString) {
61
- var self = this;
62
- if (!smalltalk.assert(aBoolean)) {
63
- smalltalk.send(self, "_signalFailure_", [aString]);
64
- }
65
- return self;
66
- },
62
+ fn: function (aBoolean,aString){
63
+ var self=this;
64
+ return smalltalk.withContext(function($ctx1) {
65
+ $1=aBoolean;
66
+ if(! smalltalk.assert($1)){
67
+ _st(self)._signalFailure_(aString);
68
+ };
69
+ return self}, function($ctx1) {$ctx1.fill(self,"assert:description:",{aBoolean:aBoolean,aString:aString}, smalltalk.TestCase)})},
67
70
  args: ["aBoolean", "aString"],
68
71
  source: "assert: aBoolean description: aString\x0a\x09aBoolean ifFalse: [self signalFailure: aString]",
69
72
  messageSends: ["ifFalse:", "signalFailure:"],
@@ -76,12 +79,12 @@ smalltalk.addMethod(
76
79
  smalltalk.method({
77
80
  selector: "assert:equals:",
78
81
  category: 'testing',
79
- fn: function (expected, actual) {
80
- var self = this;
81
- var $1;
82
- $1 = smalltalk.send(self, "_assert_description_", [smalltalk.send(expected, "__eq", [actual]), smalltalk.send(smalltalk.send(smalltalk.send("Expected: ", "__comma", [smalltalk.send(expected, "_asString", [])]), "__comma", [" but was: "]), "__comma", [smalltalk.send(actual, "_asString", [])])]);
83
- return $1;
84
- },
82
+ fn: function (expected,actual){
83
+ var self=this;
84
+ return smalltalk.withContext(function($ctx1) {
85
+ $1=_st(self)._assert_description_(_st(expected).__eq(actual),_st(_st(_st("Expected: ").__comma(_st(expected)._asString())).__comma(" but was: ")).__comma(_st(actual)._asString()));
86
+ return $1;
87
+ }, function($ctx1) {$ctx1.fill(self,"assert:equals:",{expected:expected,actual:actual}, smalltalk.TestCase)})},
85
88
  args: ["expected", "actual"],
86
89
  source: "assert: expected equals: actual\x0a\x09^ self assert: (expected = actual) description: 'Expected: ', expected asString, ' but was: ', actual asString",
87
90
  messageSends: ["assert:description:", "=", ",", "asString"],
@@ -89,16 +92,57 @@ referencedClasses: []
89
92
  }),
90
93
  smalltalk.TestCase);
91
94
 
95
+ smalltalk.addMethod(
96
+ "_async_",
97
+ smalltalk.method({
98
+ selector: "async:",
99
+ category: 'async',
100
+ fn: function (aBlock){
101
+ var self=this;
102
+ var c;
103
+ return smalltalk.withContext(function($ctx1) {
104
+ _st(self)._errorIfNotAsync_("#async");
105
+ c=self["@context"];
106
+ $1=(function(){
107
+ return smalltalk.withContext(function($ctx2) {
108
+ if(smalltalk.assert($2)){
109
+ return _st(c)._execute_(aBlock);
110
+ };
111
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
112
+ return $1;
113
+ }, function($ctx1) {$ctx1.fill(self,"async:",{aBlock:aBlock,c:c}, smalltalk.TestCase)})},
114
+ args: ["aBlock"],
115
+ source: "async: aBlock\x0a\x09| c |\x0a\x09self errorIfNotAsync: '#async'.\x0a c := context.\x0a ^ [ self isAsync ifTrue: [ c execute: aBlock ] ]",
116
+ messageSends: ["errorIfNotAsync:", "ifTrue:", "execute:", "isAsync"],
117
+ referencedClasses: []
118
+ }),
119
+ smalltalk.TestCase);
120
+
121
+ smalltalk.addMethod(
122
+ "_context_",
123
+ smalltalk.method({
124
+ selector: "context:",
125
+ category: 'accessing',
126
+ fn: function (aRunningTestContext){
127
+ var self=this;
128
+ return smalltalk.withContext(function($ctx1) {
129
+ return self}, function($ctx1) {$ctx1.fill(self,"context:",{aRunningTestContext:aRunningTestContext}, smalltalk.TestCase)})},
130
+ args: ["aRunningTestContext"],
131
+ source: "context: aRunningTestContext\x0a\x09context := aRunningTestContext",
132
+ messageSends: [],
133
+ referencedClasses: []
134
+ }),
135
+ smalltalk.TestCase);
136
+
92
137
  smalltalk.addMethod(
93
138
  "_deny_",
94
139
  smalltalk.method({
95
140
  selector: "deny:",
96
141
  category: 'testing',
97
- fn: function (aBoolean) {
98
- var self = this;
99
- smalltalk.send(self, "_assert_", [smalltalk.send(aBoolean, "_not", [])]);
100
- return self;
101
- },
142
+ fn: function (aBoolean){
143
+ var self=this;
144
+ return smalltalk.withContext(function($ctx1) {
145
+ return self}, function($ctx1) {$ctx1.fill(self,"deny:",{aBoolean:aBoolean}, smalltalk.TestCase)})},
102
146
  args: ["aBoolean"],
103
147
  source: "deny: aBoolean\x0a\x09self assert: aBoolean not",
104
148
  messageSends: ["assert:", "not"],
@@ -106,6 +150,61 @@ referencedClasses: []
106
150
  }),
107
151
  smalltalk.TestCase);
108
152
 
153
+ smalltalk.addMethod(
154
+ "_errorIfNotAsync_",
155
+ smalltalk.method({
156
+ selector: "errorIfNotAsync:",
157
+ category: 'error handling',
158
+ fn: function (aString){
159
+ var self=this;
160
+ return smalltalk.withContext(function($ctx1) {
161
+ $1=_st(self)._isAsync();
162
+ if(! smalltalk.assert($1)){
163
+ _st(self)._error_(_st(aString).__comma(" used without prior #timeout:"));
164
+ };
165
+ return self}, function($ctx1) {$ctx1.fill(self,"errorIfNotAsync:",{aString:aString}, smalltalk.TestCase)})},
166
+ args: ["aString"],
167
+ source: "errorIfNotAsync: aString\x0a\x09self isAsync ifFalse: [ \x0a \x09self error: aString, ' used without prior #timeout:' ]",
168
+ messageSends: ["ifFalse:", "error:", ",", "isAsync"],
169
+ referencedClasses: []
170
+ }),
171
+ smalltalk.TestCase);
172
+
173
+ smalltalk.addMethod(
174
+ "_finished",
175
+ smalltalk.method({
176
+ selector: "finished",
177
+ category: 'async',
178
+ fn: function (){
179
+ var self=this;
180
+ return smalltalk.withContext(function($ctx1) {
181
+ self["@asyncTimeout"]=nil;
182
+ return self}, function($ctx1) {$ctx1.fill(self,"finished",{}, smalltalk.TestCase)})},
183
+ args: [],
184
+ source: "finished\x0a\x09self errorIfNotAsync: '#finished'.\x0a\x09asyncTimeout := nil",
185
+ messageSends: ["errorIfNotAsync:"],
186
+ referencedClasses: []
187
+ }),
188
+ smalltalk.TestCase);
189
+
190
+ smalltalk.addMethod(
191
+ "_isAsync",
192
+ smalltalk.method({
193
+ selector: "isAsync",
194
+ category: 'testing',
195
+ fn: function (){
196
+ var self=this;
197
+ return smalltalk.withContext(function($ctx1) {
198
+ $1=_st(self["@asyncTimeout"])._notNil();
199
+ return $1;
200
+ }, function($ctx1) {$ctx1.fill(self,"isAsync",{}, smalltalk.TestCase)})},
201
+ args: [],
202
+ source: "isAsync\x0a\x09^asyncTimeout notNil",
203
+ messageSends: ["notNil"],
204
+ referencedClasses: []
205
+ }),
206
+ smalltalk.TestCase);
207
+
109
208
  smalltalk.addMethod(
110
209
  "_performTest",
111
210
  smalltalk.method({
@@ -113,10 +212,11 @@ selector: "performTest",
113
212
  category: 'running',
114
213
  fn: function (){
115
214
  var self=this;
116
- smalltalk.send(self,"_perform_",[smalltalk.send(self,"_selector",[])]);
117
- return self},
215
+ return smalltalk.withContext(function($ctx1) {
216
+ _st(self)._perform_(_st(self)._selector());
217
+ return self}, function($ctx1) {$ctx1.fill(self,"performTest",{}, smalltalk.TestCase)})},
118
218
  args: [],
119
- source: "performTest\x0a\x09self perform: self selector\x0a",
219
+ source: "performTest\x0a\x09asyncTimeout := nil.\x0a\x09self perform: self selector",
120
220
  messageSends: ["perform:", "selector"],
121
221
  referencedClasses: []
122
222
  }),
@@ -129,17 +229,12 @@ selector: "runCase",
129
229
  category: 'running',
130
230
  fn: function (){
131
231
  var self=this;
132
- smalltalk.send((function(){
133
- smalltalk.send(self,"_setUp",[]);
134
- return smalltalk.send(self,"_performTest",[]);
135
- }),"_ensure_",[(function(){
136
- return smalltalk.send(self,"_tearDown",[]);
137
- })]);
138
- return self},
232
+ return smalltalk.withContext(function($ctx1) {
233
+ return self}, function($ctx1) {$ctx1.fill(self,"runCase",{}, smalltalk.TestCase)})},
139
234
  args: [],
140
- source: "runCase\x0a\x09[\x09self setUp.\x0a\x09\x09self performTest ] ensure: [\x0a\x09\x09self tearDown.\x0a\x09\x09\x22self cleanUpInstanceVariables\x22 ]\x0a",
141
- messageSends: ["ensure:", "tearDown", "setUp", "performTest"],
142
- referencedClasses: []
235
+ source: "runCase\x0a\x09\x22Runs a test case in isolated context, leaking all errors.\x22\x0a\x0a\x09(TestContext testCase: self) start",
236
+ messageSends: ["start", "testCase:"],
237
+ referencedClasses: ["TestContext"]
143
238
  }),
144
239
  smalltalk.TestCase);
145
240
 
@@ -148,10 +243,12 @@ smalltalk.addMethod(
148
243
  smalltalk.method({
149
244
  selector: "selector",
150
245
  category: 'accessing',
151
- fn: function () {
152
- var self = this;
153
- return self['@testSelector'];
154
- },
246
+ fn: function (){
247
+ var self=this;
248
+ return smalltalk.withContext(function($ctx1) {
249
+ $1=self["@testSelector"];
250
+ return $1;
251
+ }, function($ctx1) {$ctx1.fill(self,"selector",{}, smalltalk.TestCase)})},
155
252
  args: [],
156
253
  source: "selector\x0a\x09^testSelector",
157
254
  messageSends: [],
@@ -164,11 +261,10 @@ smalltalk.addMethod(
164
261
  smalltalk.method({
165
262
  selector: "setTestSelector:",
166
263
  category: 'accessing',
167
- fn: function (aSelector) {
168
- var self = this;
169
- self['@testSelector'] = aSelector;
170
- return self;
171
- },
264
+ fn: function (aSelector){
265
+ var self=this;
266
+ return smalltalk.withContext(function($ctx1) {
267
+ return self}, function($ctx1) {$ctx1.fill(self,"setTestSelector:",{aSelector:aSelector}, smalltalk.TestCase)})},
172
268
  args: ["aSelector"],
173
269
  source: "setTestSelector: aSelector\x0a\x09testSelector := aSelector",
174
270
  messageSends: [],
@@ -181,10 +277,9 @@ smalltalk.addMethod(
181
277
  smalltalk.method({
182
278
  selector: "setUp",
183
279
  category: 'running',
184
- fn: function () {
185
- var self = this;
186
- return self;
187
- },
280
+ fn: function (){
281
+ var self=this;
282
+ return smalltalk.withContext(function($ctx1) {
188
283
  args: [],
189
284
  source: "setUp",
190
285
  messageSends: [],
@@ -197,11 +292,10 @@ smalltalk.addMethod(
197
292
  smalltalk.method({
198
293
  selector: "should:",
199
294
  category: 'testing',
200
- fn: function (aBlock) {
201
- var self = this;
202
- smalltalk.send(self, "_assert_", [smalltalk.send(aBlock, "_value", [])]);
203
- return self;
204
- },
295
+ fn: function (aBlock){
296
+ var self=this;
297
+ return smalltalk.withContext(function($ctx1) {
298
+ return self}, function($ctx1) {$ctx1.fill(self,"should:",{aBlock:aBlock}, smalltalk.TestCase)})},
205
299
  args: ["aBlock"],
206
300
  source: "should: aBlock\x0a\x09self assert: aBlock value",
207
301
  messageSends: ["assert:", "value"],
@@ -214,11 +308,15 @@ smalltalk.addMethod(
214
308
  smalltalk.method({
215
309
  selector: "should:raise:",
216
310
  category: 'testing',
217
- fn: function (aBlock, anExceptionClass) {
218
- var self = this;
219
- smalltalk.send(self, "_assert_", [smalltalk.send(function () {smalltalk.send(aBlock, "_value", []);return false;}, "_on_do_", [anExceptionClass, function (ex) {return true;}])]);
220
- return self;
221
- },
311
+ fn: function (aBlock,anExceptionClass){
312
+ var self=this;
313
+ return smalltalk.withContext(function($ctx1) {
314
+ return smalltalk.withContext(function($ctx2) {
315
+ return false;
316
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_(anExceptionClass,(function(ex){
317
+ return smalltalk.withContext(function($ctx2) {
318
+ }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})})));
319
+ return self}, function($ctx1) {$ctx1.fill(self,"should:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass}, smalltalk.TestCase)})},
222
320
  args: ["aBlock", "anExceptionClass"],
223
321
  source: "should: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. false] \x0a\x09\x09on: anExceptionClass \x0a\x09\x09do: [:ex | true])",
224
322
  messageSends: ["assert:", "on:do:", "value"],
@@ -231,11 +329,15 @@ smalltalk.addMethod(
231
329
  smalltalk.method({
232
330
  selector: "shouldnt:raise:",
233
331
  category: 'testing',
234
- fn: function (aBlock, anExceptionClass) {
235
- var self = this;
236
- smalltalk.send(self, "_assert_", [smalltalk.send(function () {smalltalk.send(aBlock, "_value", []);return true;}, "_on_do_", [anExceptionClass, function (ex) {return false;}])]);
237
- return self;
238
- },
332
+ fn: function (aBlock,anExceptionClass){
333
+ var self=this;
334
+ return smalltalk.withContext(function($ctx1) {
335
+ return smalltalk.withContext(function($ctx2) {
336
+ return true;
337
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_(anExceptionClass,(function(ex){
338
+ return smalltalk.withContext(function($ctx2) {
339
+ }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})})));
340
+ return self}, function($ctx1) {$ctx1.fill(self,"shouldnt:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass}, smalltalk.TestCase)})},
239
341
  args: ["aBlock", "anExceptionClass"],
240
342
  source: "shouldnt: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. true] \x0a\x09\x09on: anExceptionClass \x0a\x09\x09do: [:ex | false])",
241
343
  messageSends: ["assert:", "on:do:", "value"],
@@ -248,14 +350,13 @@ smalltalk.addMethod(
248
350
  smalltalk.method({
249
351
  selector: "signalFailure:",
250
352
  category: 'private',
251
- fn: function (aString) {
252
- var self = this;
253
- var $1, $2;
254
- $1 = smalltalk.send(smalltalk.TestFailure || TestFailure, "_new", []);
255
- smalltalk.send($1, "_messageText_", [aString]);
256
- $2 = smalltalk.send($1, "_signal", []);
257
- return self;
258
- },
353
+ fn: function (aString){
354
+ var self=this;
355
+ return smalltalk.withContext(function($ctx1) {
356
+ $1=_st((smalltalk.TestFailure || TestFailure))._new();
357
+ _st($1)._messageText_(aString);
358
+ $2=_st($1)._signal();
359
+ return self}, function($ctx1) {$ctx1.fill(self,"signalFailure:",{aString:aString}, smalltalk.TestCase)})},
259
360
  args: ["aString"],
260
361
  source: "signalFailure: aString\x0a\x09TestFailure new\x0a\x09\x09messageText: aString;\x0a\x09\x09signal",
261
362
  messageSends: ["messageText:", "new", "signal"],
@@ -268,10 +369,9 @@ smalltalk.addMethod(
268
369
  smalltalk.method({
269
370
  selector: "tearDown",
270
371
  category: 'running',
271
- fn: function () {
272
- var self = this;
273
- return self;
274
- },
372
+ fn: function (){
373
+ var self=this;
374
+ return smalltalk.withContext(function($ctx1) {
275
375
  args: [],
276
376
  source: "tearDown",
277
377
  messageSends: [],
@@ -279,23 +379,50 @@ referencedClasses: []
279
379
  }),
280
380
  smalltalk.TestCase);
281
381
 
382
+ smalltalk.addMethod(
383
+ "_timeout_",
384
+ smalltalk.method({
385
+ selector: "timeout:",
386
+ category: 'async',
387
+ fn: function (aNumber){
388
+ var self=this;
389
+ return smalltalk.withContext(function($ctx1) {
390
+ $1=self["@asyncTimeout"];
391
+ if(($receiver = $1) == nil || $receiver == undefined){
392
+ $1;
393
+ } else {
394
+ _st(self["@asyncTimeout"])._clearTimeout();
395
+ };
396
+ self["@asyncTimeout"]=(0);
397
+ self["@asyncTimeout"]=_st(_st(self)._async_((function(){
398
+ return smalltalk.withContext(function($ctx2) {
399
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_(aNumber);
400
+ return self}, function($ctx1) {$ctx1.fill(self,"timeout:",{aNumber:aNumber}, smalltalk.TestCase)})},
401
+ args: ["aNumber"],
402
+ source: "timeout: aNumber\x0a\x09\x22Set a grace time timeout in milliseconds to run the test asynchronously\x22\x0a \x0a\x09asyncTimeout ifNotNil: [ asyncTimeout clearTimeout ].\x0a \x0a \x22to allow #async: message send without throwing an error\x22\x0a\x09asyncTimeout := 0.\x0a \x0a\x09asyncTimeout := (self async: [ \x0a \x09self assert: false description: 'SUnit grace time exhausted' ])\x0a \x09valueWithTimeout: aNumber",
403
+ messageSends: ["ifNotNil:", "clearTimeout", "valueWithTimeout:", "async:", "assert:description:"],
404
+ referencedClasses: []
405
+ }),
406
+ smalltalk.TestCase);
407
+
282
408
 
283
409
  smalltalk.addMethod(
284
410
  "_allTestSelectors",
285
411
  smalltalk.method({
286
412
  selector: "allTestSelectors",
287
413
  category: 'accessing',
288
- fn: function () {
289
- var self = this;
290
- var $1;
291
- var selectors;
292
- selectors = smalltalk.send(self, "_testSelectors", []);
293
- $1 = smalltalk.send(self, "_shouldInheritSelectors", []);
294
- if (smalltalk.assert($1)) {
295
- smalltalk.send(selectors, "_addAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_allTestSelectors", [])]);
296
- }
297
- return selectors;
298
- },
414
+ fn: function (){
415
+ var self=this;
416
+ var selectors;
417
+ return smalltalk.withContext(function($ctx1) {
418
+ selectors=_st(self)._testSelectors();
419
+ $1=_st(self)._shouldInheritSelectors();
420
+ if(smalltalk.assert($1)){
421
+ _st(selectors)._addAll_(_st(_st(self)._superclass())._allTestSelectors());
422
+ };
423
+ $2=selectors;
424
+ return $2;
425
+ }, function($ctx1) {$ctx1.fill(self,"allTestSelectors",{selectors:selectors}, smalltalk.TestCase.klass)})},
299
426
  args: [],
300
427
  source: "allTestSelectors\x0a\x09| selectors |\x0a\x09selectors := self testSelectors.\x0a\x09self shouldInheritSelectors ifTrue: [\x0a\x09\x09selectors addAll: self superclass allTestSelectors].\x0a\x09^selectors",
301
428
  messageSends: ["testSelectors", "ifTrue:", "addAll:", "allTestSelectors", "superclass", "shouldInheritSelectors"],
@@ -308,12 +435,14 @@ smalltalk.addMethod(
308
435
  smalltalk.method({
309
436
  selector: "buildSuite",
310
437
  category: 'accessing',
311
- fn: function () {
312
- var self = this;
313
- var $1;
314
- $1 = smalltalk.send(smalltalk.send(self, "_allTestSelectors", []), "_collect_", [function (each) {return smalltalk.send(self, "_selector_", [each]);}]);
315
- return $1;
316
- },
438
+ fn: function (){
439
+ var self=this;
440
+ return smalltalk.withContext(function($ctx1) {
441
+ $1=_st(_st(self)._allTestSelectors())._collect_((function(each){
442
+ return smalltalk.withContext(function($ctx2) {
443
+ }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
444
+ return $1;
445
+ }, function($ctx1) {$ctx1.fill(self,"buildSuite",{}, smalltalk.TestCase.klass)})},
317
446
  args: [],
318
447
  source: "buildSuite\x0a\x09^self allTestSelectors collect: [:each | self selector: each]",
319
448
  messageSends: ["collect:", "selector:", "allTestSelectors"],
@@ -326,12 +455,12 @@ smalltalk.addMethod(
326
455
  smalltalk.method({
327
456
  selector: "isAbstract",
328
457
  category: 'testing',
329
- fn: function () {
330
- var self = this;
331
- var $1;
332
- $1 = smalltalk.send(smalltalk.send(self, "_name", []), "__eq", ["TestCase"]);
333
- return $1;
334
- },
458
+ fn: function (){
459
+ var self=this;
460
+ return smalltalk.withContext(function($ctx1) {
461
+ $1=_st(_st(self)._name()).__eq("TestCase");
462
+ return $1;
463
+ }, function($ctx1) {$ctx1.fill(self,"isAbstract",{}, smalltalk.TestCase.klass)})},
335
464
  args: [],
336
465
  source: "isAbstract\x0a\x09^ self name = 'TestCase'",
337
466
  messageSends: ["=", "name"],
@@ -344,10 +473,12 @@ smalltalk.addMethod(
344
473
  smalltalk.method({
345
474
  selector: "lookupHierarchyRoot",
346
475
  category: 'accessing',
347
- fn: function () {
348
- var self = this;
349
- return smalltalk.TestCase || TestCase;
350
- },
476
+ fn: function (){
477
+ var self=this;
478
+ return smalltalk.withContext(function($ctx1) {
479
+ $1=(smalltalk.TestCase || TestCase);
480
+ return $1;
481
+ }, function($ctx1) {$ctx1.fill(self,"lookupHierarchyRoot",{}, smalltalk.TestCase.klass)})},
351
482
  args: [],
352
483
  source: "lookupHierarchyRoot\x0a\x09^TestCase",
353
484
  messageSends: [],
@@ -360,15 +491,15 @@ smalltalk.addMethod(
360
491
  smalltalk.method({
361
492
  selector: "selector:",
362
493
  category: 'accessing',
363
- fn: function (aSelector) {
364
- var self = this;
365
- var $2, $3, $1;
366
- $2 = smalltalk.send(self, "_new", []);
367
- smalltalk.send($2, "_setTestSelector_", [aSelector]);
368
- $3 = smalltalk.send($2, "_yourself", []);
369
- $1 = $3;
370
- return $1;
371
- },
494
+ fn: function (aSelector){
495
+ var self=this;
496
+ return smalltalk.withContext(function($ctx1) {
497
+ $2=_st(self)._new();
498
+ _st($2)._setTestSelector_(aSelector);
499
+ $3=_st($2)._yourself();
500
+ $1=$3;
501
+ return $1;
502
+ }, function($ctx1) {$ctx1.fill(self,"selector:",{aSelector:aSelector}, smalltalk.TestCase.klass)})},
372
503
  args: ["aSelector"],
373
504
  source: "selector: aSelector\x0a\x09^self new\x0a\x09\x09setTestSelector: aSelector;\x0a\x09\x09yourself",
374
505
  messageSends: ["setTestSelector:", "new", "yourself"],
@@ -381,12 +512,12 @@ smalltalk.addMethod(
381
512
  smalltalk.method({
382
513
  selector: "shouldInheritSelectors",
383
514
  category: 'testing',
384
- fn: function () {
385
- var self = this;
386
- var $1;
387
- $1 = smalltalk.send(self, "_~_eq", [smalltalk.send(self, "_lookupHierarchyRoot", [])]);
388
- return $1;
389
- },
515
+ fn: function (){
516
+ var self=this;
517
+ return smalltalk.withContext(function($ctx1) {
518
+ $1=_st(self).__tild_eq(_st(self)._lookupHierarchyRoot());
519
+ return $1;
520
+ }, function($ctx1) {$ctx1.fill(self,"shouldInheritSelectors",{}, smalltalk.TestCase.klass)})},
390
521
  args: [],
391
522
  source: "shouldInheritSelectors\x0a\x09^self ~= self lookupHierarchyRoot",
392
523
  messageSends: ["~=", "lookupHierarchyRoot"],
@@ -399,12 +530,14 @@ smalltalk.addMethod(
399
530
  smalltalk.method({
400
531
  selector: "testSelectors",
401
532
  category: 'accessing',
402
- fn: function () {
403
- var self = this;
404
- var $1;
405
- $1 = smalltalk.send(smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_keys", []), "_select_", [function (each) {return smalltalk.send(each, "_match_", ["^test"]);}]);
406
- return $1;
407
- },
533
+ fn: function (){
534
+ var self=this;
535
+ return smalltalk.withContext(function($ctx1) {
536
+ $1=_st(_st(_st(self)._methodDictionary())._keys())._select_((function(each){
537
+ return smalltalk.withContext(function($ctx2) {
538
+ }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
539
+ return $1;
540
+ }, function($ctx1) {$ctx1.fill(self,"testSelectors",{}, smalltalk.TestCase.klass)})},
408
541
  args: [],
409
542
  source: "testSelectors\x0a\x09^self methodDictionary keys select: [:each | each match: '^test']",
410
543
  messageSends: ["select:", "match:", "keys", "methodDictionary"],
@@ -413,20 +546,229 @@ referencedClasses: []
413
546
  smalltalk.TestCase.klass);
414
547
 
415
548
 
549
+ smalltalk.addClass('TestContext', smalltalk.Object, ['testCase'], 'SUnit');
550
+ smalltalk.TestContext.comment="TestContext governs running a particular test case.\x0a\x0aIt's main added value is `#execute:` method which runs a block\x0aas a part of test case (restores context, nilling it afterwards,\x0acleaning/calling tearDown as appropriate for sync/async scenario)."
551
+ smalltalk.addMethod(
552
+ "_execute_",
553
+ smalltalk.method({
554
+ selector: "execute:",
555
+ category: 'running',
556
+ fn: function (aBlock){
557
+ var self=this;
558
+ var failed;
559
+ return smalltalk.withContext(function($ctx1) {
560
+ _st(self["@testCase"])._context_(self);
561
+ $1=(function(){
562
+ return smalltalk.withContext(function($ctx2) {
563
+ failed;
564
+ _st(aBlock)._value();
565
+ failed=false;
566
+ return failed;
567
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
568
+ $2=(function(){
569
+ return smalltalk.withContext(function($ctx2) {
570
+ $3=_st(failed)._and_((function(){
571
+ return smalltalk.withContext(function($ctx3) {
572
+ }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
573
+ if(smalltalk.assert($3)){
574
+ _st(self["@testCase"])._finished();
575
+ };
576
+ $4=_st(self["@testCase"])._isAsync();
577
+ if(! smalltalk.assert($4)){
578
+ return _st(self["@testCase"])._tearDown();
579
+ };
580
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
581
+ _st($1)._ensure_($2);
582
+ return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock,failed:failed}, smalltalk.TestContext)})},
583
+ args: ["aBlock"],
584
+ source: "execute: aBlock\x0a\x09| failed |\x0a \x0a testCase context: self.\x0a [ \x0a \x09failed := true. \x0a aBlock value. \x0a failed := false \x0a\x09] \x0a \x09ensure: [\x0a \x09testCase context: nil.\x0a \x0a \x09(failed and: [ testCase isAsync ]) ifTrue: [ \x0a \x09testCase finished ].\x0a \x09testCase isAsync ifFalse: [ \x0a \x09\x09testCase tearDown ] ]",
585
+ messageSends: ["context:", "ensure:", "ifTrue:", "finished", "and:", "isAsync", "ifFalse:", "tearDown", "value"],
586
+ referencedClasses: []
587
+ }),
588
+ smalltalk.TestContext);
589
+
590
+ smalltalk.addMethod(
591
+ "_start",
592
+ smalltalk.method({
593
+ selector: "start",
594
+ category: 'running',
595
+ fn: function (){
596
+ var self=this;
597
+ return smalltalk.withContext(function($ctx1) {
598
+ return smalltalk.withContext(function($ctx2) {
599
+ return _st(self["@testCase"])._performTest();
600
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
601
+ return self}, function($ctx1) {$ctx1.fill(self,"start",{}, smalltalk.TestContext)})},
602
+ args: [],
603
+ source: "start\x0a\x09self execute: [ \x0a \x09testCase setUp. \x0a testCase performTest ]",
604
+ messageSends: ["execute:", "setUp", "performTest"],
605
+ referencedClasses: []
606
+ }),
607
+ smalltalk.TestContext);
608
+
609
+ smalltalk.addMethod(
610
+ "_testCase_",
611
+ smalltalk.method({
612
+ selector: "testCase:",
613
+ category: 'accessing',
614
+ fn: function (aTestCase){
615
+ var self=this;
616
+ return smalltalk.withContext(function($ctx1) {
617
+ return self}, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase}, smalltalk.TestContext)})},
618
+ args: ["aTestCase"],
619
+ source: "testCase: aTestCase\x0a\x09testCase := aTestCase",
620
+ messageSends: [],
621
+ referencedClasses: []
622
+ }),
623
+ smalltalk.TestContext);
624
+
625
+
626
+ smalltalk.addMethod(
627
+ "_testCase_",
628
+ smalltalk.method({
629
+ selector: "testCase:",
630
+ category: 'instance creation',
631
+ fn: function (aTestCase){
632
+ var self=this;
633
+ return smalltalk.withContext(function($ctx1) {
634
+ $2=_st(self)._new();
635
+ _st($2)._testCase_(aTestCase);
636
+ $3=_st($2)._yourself();
637
+ $1=$3;
638
+ return $1;
639
+ }, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase}, smalltalk.TestContext.klass)})},
640
+ args: ["aTestCase"],
641
+ source: "testCase: aTestCase\x0a\x09^self new\x0a testCase: aTestCase;\x0a yourself",
642
+ messageSends: ["testCase:", "new", "yourself"],
643
+ referencedClasses: []
644
+ }),
645
+ smalltalk.TestContext.klass);
646
+
647
+
648
+ smalltalk.addClass('ReportingTestContext', smalltalk.TestContext, ['finished', 'result'], 'SUnit');
649
+ smalltalk.ReportingTestContext.comment="ReportingTestContext adds `TestResult` reporting\x0ato `TestContext`.\x0a\x0aErrors are caught and save into a `TestResult`,\x0aWhen test case is finished (which can be later for async tests),\x0aa callback block is executed; this is used by a `TestSuiteRunner`."
650
+ smalltalk.addMethod(
651
+ "_execute_",
652
+ smalltalk.method({
653
+ selector: "execute:",
654
+ category: 'running',
655
+ fn: function (aBlock){
656
+ var self=this;
657
+ return smalltalk.withContext(function($ctx1) {
658
+ $1=(function(){
659
+ return smalltalk.withContext(function($ctx2) {
660
+ return smalltalk.withContext(function($ctx3) {
661
+ }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
662
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
663
+ $2=(function(){
664
+ return smalltalk.withContext(function($ctx2) {
665
+ if(! smalltalk.assert($3)){
666
+ _st(self["@result"])._increaseRuns();
667
+ return _st(self["@finished"])._value();
668
+ };
669
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
670
+ _st($1)._ensure_($2);
671
+ return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
672
+ args: ["aBlock"],
673
+ source: "execute: aBlock\x0a [ \x0a \x09self withErrorReporting: [ super execute: aBlock ] \x0a\x09]\x0a \x09ensure: [ \x0a \x09testCase isAsync ifFalse: [ \x0a \x09result increaseRuns. finished value ] ]",
674
+ messageSends: ["ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "withErrorReporting:", "execute:"],
675
+ referencedClasses: []
676
+ }),
677
+ smalltalk.ReportingTestContext);
678
+
679
+ smalltalk.addMethod(
680
+ "_finished_",
681
+ smalltalk.method({
682
+ selector: "finished:",
683
+ category: 'accessing',
684
+ fn: function (aBlock){
685
+ var self=this;
686
+ return smalltalk.withContext(function($ctx1) {
687
+ return self}, function($ctx1) {$ctx1.fill(self,"finished:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
688
+ args: ["aBlock"],
689
+ source: "finished: aBlock\x0a\x09finished := aBlock",
690
+ messageSends: [],
691
+ referencedClasses: []
692
+ }),
693
+ smalltalk.ReportingTestContext);
694
+
695
+ smalltalk.addMethod(
696
+ "_result_",
697
+ smalltalk.method({
698
+ selector: "result:",
699
+ category: 'accessing',
700
+ fn: function (aTestResult){
701
+ var self=this;
702
+ return smalltalk.withContext(function($ctx1) {
703
+ return self}, function($ctx1) {$ctx1.fill(self,"result:",{aTestResult:aTestResult}, smalltalk.ReportingTestContext)})},
704
+ args: ["aTestResult"],
705
+ source: "result: aTestResult\x0a\x09result := aTestResult",
706
+ messageSends: [],
707
+ referencedClasses: []
708
+ }),
709
+ smalltalk.ReportingTestContext);
710
+
711
+ smalltalk.addMethod(
712
+ "_withErrorReporting_",
713
+ smalltalk.method({
714
+ selector: "withErrorReporting:",
715
+ category: 'private',
716
+ fn: function (aBlock){
717
+ var self=this;
718
+ return smalltalk.withContext(function($ctx1) {
719
+ return smalltalk.withContext(function($ctx2) {
720
+ return smalltalk.withContext(function($ctx3) {
721
+ }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
722
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
723
+ return smalltalk.withContext(function($ctx2) {
724
+ }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
725
+ return self}, function($ctx1) {$ctx1.fill(self,"withErrorReporting:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
726
+ args: ["aBlock"],
727
+ source: "withErrorReporting: aBlock\x0a \x09[ aBlock\x0a\x09\x09on: TestFailure \x0a\x09\x09do: [ :ex | result addFailure: testCase ] \x0a\x09]\x0a \x09on: Error \x0a do: [ :ex | result addError: testCase ]",
728
+ messageSends: ["on:do:", "addError:", "addFailure:"],
729
+ referencedClasses: ["Error", "TestFailure"]
730
+ }),
731
+ smalltalk.ReportingTestContext);
732
+
733
+
734
+ smalltalk.addMethod(
735
+ "_testCase_result_finished_",
736
+ smalltalk.method({
737
+ selector: "testCase:result:finished:",
738
+ category: 'instance creation',
739
+ fn: function (aTestCase,aTestResult,aBlock){
740
+ var self=this;
741
+ return smalltalk.withContext(function($ctx1) {
742
+ $2=smalltalk.TestContext.klass.fn.prototype._testCase_.apply(_st(self), [aTestCase]);
743
+ _st($2)._result_(aTestResult);
744
+ _st($2)._finished_(aBlock);
745
+ $3=_st($2)._yourself();
746
+ $1=$3;
747
+ return $1;
748
+ }, function($ctx1) {$ctx1.fill(self,"testCase:result:finished:",{aTestCase:aTestCase,aTestResult:aTestResult,aBlock:aBlock}, smalltalk.ReportingTestContext.klass)})},
749
+ args: ["aTestCase", "aTestResult", "aBlock"],
750
+ source: "testCase: aTestCase result: aTestResult finished: aBlock\x0a\x09^(super testCase: aTestCase)\x0a result: aTestResult;\x0a finished: aBlock;\x0a yourself",
751
+ messageSends: ["result:", "testCase:", "finished:", "yourself"],
752
+ referencedClasses: []
753
+ }),
754
+ smalltalk.ReportingTestContext.klass);
755
+
756
+
416
757
  smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
758
+ smalltalk.TestFailure.comment="The test framework distinguishes between failures and errors. \x0aA failure is an event whose possibiity is explicitly anticipated and checked for in an assertion, \x0awhereas an error is an unanticipated problem like a division by 0 or an index out of bounds. \x0a\x0aTestFailure is raised when the boolean parameter of an #`assert:` or `#deny:` call is the opposite of what the assertion claims."
417
759
 
418
760
 
419
761
  smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
762
+ smalltalk.TestResult.comment="A TestResult implements the collecting parameter pattern for running a bunch of tests. \x0a\x0aA TestResult holds tests that have run, sorted into the result categories of passed, failures and errors.\x0a\x0aTestResult is an interesting object to subclass or substitute. `#runCase:` is the external protocol you need to reproduce"
420
763
  smalltalk.addMethod(
421
764
  "_addError_",
422
765
  smalltalk.method({
423
766
  selector: "addError:",
424
767
  category: 'accessing',
425
- fn: function (anError) {
426
- var self = this;
427
- smalltalk.send(smalltalk.send(self, "_errors", []), "_add_", [anError]);
428
- return self;
429
- },
768
+ fn: function (anError){
769
+ var self=this;
770
+ return smalltalk.withContext(function($ctx1) {
771
+ return self}, function($ctx1) {$ctx1.fill(self,"addError:",{anError:anError}, smalltalk.TestResult)})},
430
772
  args: ["anError"],
431
773
  source: "addError: anError\x0a\x09self errors add: anError",
432
774
  messageSends: ["add:", "errors"],
@@ -439,11 +781,10 @@ smalltalk.addMethod(
439
781
  smalltalk.method({
440
782
  selector: "addFailure:",
441
783
  category: 'accessing',
442
- fn: function (aFailure) {
443
- var self = this;
444
- smalltalk.send(smalltalk.send(self, "_failures", []), "_add_", [aFailure]);
445
- return self;
446
- },
784
+ fn: function (aFailure){
785
+ var self=this;
786
+ return smalltalk.withContext(function($ctx1) {
787
+ return self}, function($ctx1) {$ctx1.fill(self,"addFailure:",{aFailure:aFailure}, smalltalk.TestResult)})},
447
788
  args: ["aFailure"],
448
789
  source: "addFailure: aFailure\x0a\x09self failures add: aFailure",
449
790
  messageSends: ["add:", "failures"],
@@ -456,10 +797,12 @@ smalltalk.addMethod(
456
797
  smalltalk.method({
457
798
  selector: "errors",
458
799
  category: 'accessing',
459
- fn: function () {
460
- var self = this;
461
- return self['@errors'];
462
- },
800
+ fn: function (){
801
+ var self=this;
802
+ return smalltalk.withContext(function($ctx1) {
803
+ $1=self["@errors"];
804
+ return $1;
805
+ }, function($ctx1) {$ctx1.fill(self,"errors",{}, smalltalk.TestResult)})},
463
806
  args: [],
464
807
  source: "errors\x0a\x09^errors",
465
808
  messageSends: [],
@@ -472,10 +815,12 @@ smalltalk.addMethod(
472
815
  smalltalk.method({
473
816
  selector: "failures",
474
817
  category: 'accessing',
475
- fn: function () {
476
- var self = this;
477
- return self['@failures'];
478
- },
818
+ fn: function (){
819
+ var self=this;
820
+ return smalltalk.withContext(function($ctx1) {
821
+ $1=self["@failures"];
822
+ return $1;
823
+ }, function($ctx1) {$ctx1.fill(self,"failures",{}, smalltalk.TestResult)})},
479
824
  args: [],
480
825
  source: "failures\x0a\x09^failures",
481
826
  messageSends: [],
@@ -488,11 +833,10 @@ smalltalk.addMethod(
488
833
  smalltalk.method({
489
834
  selector: "increaseRuns",
490
835
  category: 'accessing',
491
- fn: function () {
492
- var self = this;
493
- self['@runs'] = smalltalk.send(self['@runs'], "__plus", [1]);
494
- return self;
495
- },
836
+ fn: function (){
837
+ var self=this;
838
+ return smalltalk.withContext(function($ctx1) {
839
+ return self}, function($ctx1) {$ctx1.fill(self,"increaseRuns",{}, smalltalk.TestResult)})},
496
840
  args: [],
497
841
  source: "increaseRuns\x0a\x09runs := runs + 1",
498
842
  messageSends: ["+"],
@@ -505,16 +849,15 @@ smalltalk.addMethod(
505
849
  smalltalk.method({
506
850
  selector: "initialize",
507
851
  category: 'initialization',
508
- fn: function () {
509
- var self = this;
510
- smalltalk.send(self, "_initialize", [], smalltalk.Object);
511
- self['@timestamp'] = smalltalk.send(smalltalk.Date || Date, "_now", []);
512
- self['@runs'] = 0;
513
- self['@errors'] = smalltalk.send(smalltalk.Array || Array, "_new", []);
514
- self['@failures'] = smalltalk.send(smalltalk.Array || Array, "_new", []);
515
- self['@total'] = 0;
516
- return self;
517
- },
852
+ fn: function (){
853
+ var self=this;
854
+ return smalltalk.withContext(function($ctx1) {
855
+ self["@timestamp"]=_st((smalltalk.Date || Date))._now();
856
+ self["@runs"]=(0);
857
+ self["@errors"]=_st((smalltalk.Array || Array))._new();
858
+ self["@failures"]=_st((smalltalk.Array || Array))._new();
859
+ self["@total"]=(0);
860
+ return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TestResult)})},
518
861
  args: [],
519
862
  source: "initialize\x0a\x09super initialize.\x0a\x09timestamp := Date now.\x0a\x09runs := 0.\x0a\x09errors := Array new.\x0a\x09failures := Array new.\x0a\x09total := 0",
520
863
  messageSends: ["initialize", "now", "new"],
@@ -529,13 +872,13 @@ selector: "nextRunDo:",
529
872
  category: 'running',
530
873
  fn: function (aBlock){
531
874
  var self=this;
532
- var $2,$1;
533
- $2=smalltalk.send(smalltalk.send(self,"_runs",[]),"__eq_eq",[smalltalk.send(self,"_total",[])]);
875
+ return smalltalk.withContext(function($ctx1) {
876
+ $2=_st(_st(self)._runs()).__eq_eq(_st(self)._total());
534
877
  if(! smalltalk.assert($2)){
535
- $1=smalltalk.send(aBlock,"_value_",[smalltalk.send(smalltalk.send(self,"_runs",[]),"__plus",[(1)])]);
878
+ $1=_st(aBlock)._value_(_st(_st(self)._runs()).__plus((1)));
536
879
  };
537
880
  return $1;
538
- },
881
+ }, function($ctx1) {$ctx1.fill(self,"nextRunDo:",{aBlock:aBlock}, smalltalk.TestResult)})},
539
882
  args: ["aBlock"],
540
883
  source: "nextRunDo: aBlock\x0a\x22Runs aBlock with index of next run\x0aor does nothing if no more runs\x22\x0a^self runs == self total\x0a\x09ifFalse: [ aBlock value: self runs + 1 ]",
541
884
  messageSends: ["ifFalse:", "value:", "+", "runs", "==", "total"],
@@ -550,17 +893,17 @@ selector: "runCase:",
550
893
  category: 'running',
551
894
  fn: function (aTestCase){
552
895
  var self=this;
553
- smalltalk.send((function(){
554
- return smalltalk.send((function(){
555
- smalltalk.send(self,"_increaseRuns",[]);
556
- return smalltalk.send(aTestCase,"_runCase",[]);
557
- }),"_on_do_",[(smalltalk.TestFailure || TestFailure),(function(ex){
558
- return smalltalk.send(self,"_addFailure_",[aTestCase]);
559
- })]);
560
- }),"_on_do_",[(smalltalk.Error || Error),(function(ex){
561
- return smalltalk.send(self,"_addError_",[aTestCase]);
562
- })]);
563
- return self},
896
+ return smalltalk.withContext(function($ctx1) {
897
+ return smalltalk.withContext(function($ctx2) {
898
+ return smalltalk.withContext(function($ctx3) {
899
+ return _st(aTestCase)._runCase();
900
+ }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_((smalltalk.TestFailure || TestFailure),(function(ex){
901
+ return smalltalk.withContext(function($ctx3) {
902
+ }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
903
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
904
+ return smalltalk.withContext(function($ctx2) {
905
+ }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
906
+ return self}, function($ctx1) {$ctx1.fill(self,"runCase:",{aTestCase:aTestCase}, smalltalk.TestResult)})},
564
907
  args: ["aTestCase"],
565
908
  source: "runCase: aTestCase\x0a\x09[[\x09self increaseRuns.\x0a \x09aTestCase runCase]\x0a\x09on: TestFailure do: [:ex | self addFailure: aTestCase]]\x0a\x09on: Error do: [:ex | self addError: aTestCase]\x0a",
566
909
  messageSends: ["on:do:", "addError:", "addFailure:", "increaseRuns", "runCase"],
@@ -573,10 +916,12 @@ smalltalk.addMethod(
573
916
  smalltalk.method({
574
917
  selector: "runs",
575
918
  category: 'accessing',
576
- fn: function () {
577
- var self = this;
578
- return self['@runs'];
579
- },
919
+ fn: function (){
920
+ var self=this;
921
+ return smalltalk.withContext(function($ctx1) {
922
+ $1=self["@runs"];
923
+ return $1;
924
+ }, function($ctx1) {$ctx1.fill(self,"runs",{}, smalltalk.TestResult)})},
580
925
  args: [],
581
926
  source: "runs\x0a\x09^runs",
582
927
  messageSends: [],
@@ -589,22 +934,23 @@ smalltalk.addMethod(
589
934
  smalltalk.method({
590
935
  selector: "status",
591
936
  category: 'accessing',
592
- fn: function () {
593
- var self = this;
594
- var $2, $3, $1;
595
- $2 = smalltalk.send(smalltalk.send(self, "_errors", []), "_isEmpty", []);
596
- if (smalltalk.assert($2)) {
597
- $3 = smalltalk.send(smalltalk.send(self, "_failures", []), "_isEmpty", []);
598
- if (smalltalk.assert($3)) {
599
- $1 = "success";
600
- } else {
601
- $1 = "failure";
602
- }
603
- } else {
604
- $1 = "error";
605
- }
606
- return $1;
607
- },
937
+ fn: function (){
938
+ var self=this;
939
+ return smalltalk.withContext(function($ctx1) {
940
+ $2=_st(_st(self)._errors())._isEmpty();
941
+ $3=(function(){
942
+ return smalltalk.withContext(function($ctx2) {
943
+ if(smalltalk.assert($4)){
944
+ return "success";
945
+ } else {
946
+ return "failure";
947
+ };
948
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
949
+ $1=_st($2)._ifTrue_ifFalse_($3,(function(){
950
+ return smalltalk.withContext(function($ctx2) {
951
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
952
+ return $1;
953
+ }, function($ctx1) {$ctx1.fill(self,"status",{}, smalltalk.TestResult)})},
608
954
  args: [],
609
955
  source: "status\x0a\x09^self errors isEmpty \x0a\x09\x09ifTrue: [\x0a\x09\x09\x09self failures isEmpty \x0a\x09\x09\x09\x09ifTrue: ['success']\x0a\x09\x09\x09\x09ifFalse: ['failure']]\x0a\x09\x09ifFalse: ['error']",
610
956
  messageSends: ["ifTrue:ifFalse:", "isEmpty", "failures", "errors"],
@@ -617,10 +963,12 @@ smalltalk.addMethod(
617
963
  smalltalk.method({
618
964
  selector: "timestamp",
619
965
  category: 'accessing',
620
- fn: function () {
621
- var self = this;
622
- return self['@timestamp'];
623
- },
966
+ fn: function (){
967
+ var self=this;
968
+ return smalltalk.withContext(function($ctx1) {
969
+ $1=self["@timestamp"];
970
+ return $1;
971
+ }, function($ctx1) {$ctx1.fill(self,"timestamp",{}, smalltalk.TestResult)})},
624
972
  args: [],
625
973
  source: "timestamp\x0a\x09^timestamp",
626
974
  messageSends: [],
@@ -633,10 +981,12 @@ smalltalk.addMethod(
633
981
  smalltalk.method({
634
982
  selector: "total",
635
983
  category: 'accessing',
636
- fn: function () {
637
- var self = this;
638
- return self['@total'];
639
- },
984
+ fn: function (){
985
+ var self=this;
986
+ return smalltalk.withContext(function($ctx1) {
987
+ $1=self["@total"];
988
+ return $1;
989
+ }, function($ctx1) {$ctx1.fill(self,"total",{}, smalltalk.TestResult)})},
640
990
  args: [],
641
991
  source: "total\x0a\x09^total",
642
992
  messageSends: [],
@@ -649,11 +999,10 @@ smalltalk.addMethod(
649
999
  smalltalk.method({
650
1000
  selector: "total:",
651
1001
  category: 'accessing',
652
- fn: function (aNumber) {
653
- var self = this;
654
- self['@total'] = aNumber;
655
- return self;
656
- },
1002
+ fn: function (aNumber){
1003
+ var self=this;
1004
+ return smalltalk.withContext(function($ctx1) {
1005
+ return self}, function($ctx1) {$ctx1.fill(self,"total:",{aNumber:aNumber}, smalltalk.TestResult)})},
657
1006
  args: ["aNumber"],
658
1007
  source: "total: aNumber\x0a\x09total := aNumber",
659
1008
  messageSends: [],
@@ -663,7 +1012,7 @@ smalltalk.TestResult);
663
1012
 
664
1013
 
665
1014
 
666
- smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer'], 'SUnit');
1015
+ smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer', 'runNextTest'], 'SUnit');
667
1016
  smalltalk.addMethod(
668
1017
  "_announcer",
669
1018
  smalltalk.method({
@@ -671,8 +1020,10 @@ selector: "announcer",
671
1020
  category: 'accessing',
672
1021
  fn: function (){
673
1022
  var self=this;
674
- return self["@announcer"];
675
- },
1023
+ return smalltalk.withContext(function($ctx1) {
1024
+ $1=self["@announcer"];
1025
+ return $1;
1026
+ }, function($ctx1) {$ctx1.fill(self,"announcer",{}, smalltalk.TestSuiteRunner)})},
676
1027
  args: [],
677
1028
  source: "announcer\x0a\x09^announcer",
678
1029
  messageSends: [],
@@ -680,6 +1031,26 @@ referencedClasses: []
680
1031
  }),
681
1032
  smalltalk.TestSuiteRunner);
682
1033
 
1034
+ smalltalk.addMethod(
1035
+ "_contextOf_",
1036
+ smalltalk.method({
1037
+ selector: "contextOf:",
1038
+ category: 'private',
1039
+ fn: function (anInteger){
1040
+ var self=this;
1041
+ return smalltalk.withContext(function($ctx1) {
1042
+ $1=_st((smalltalk.ReportingTestContext || ReportingTestContext))._testCase_result_finished_(_st(self["@suite"])._at_(anInteger),self["@result"],(function(){
1043
+ return smalltalk.withContext(function($ctx2) {
1044
+ }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
1045
+ return $1;
1046
+ }, function($ctx1) {$ctx1.fill(self,"contextOf:",{anInteger:anInteger}, smalltalk.TestSuiteRunner)})},
1047
+ args: ["anInteger"],
1048
+ source: "contextOf: anInteger\x0a \x09^ReportingTestContext testCase: (suite at: anInteger) result: result finished: [ self resume ]",
1049
+ messageSends: ["testCase:result:finished:", "at:", "resume"],
1050
+ referencedClasses: ["ReportingTestContext"]
1051
+ }),
1052
+ smalltalk.TestSuiteRunner);
1053
+
683
1054
  smalltalk.addMethod(
684
1055
  "_initialize",
685
1056
  smalltalk.method({
@@ -687,13 +1058,23 @@ selector: "initialize",
687
1058
  category: 'initialization',
688
1059
  fn: function (){
689
1060
  var self=this;
690
- smalltalk.send(self,"_initialize",[],smalltalk.Object);
691
- self["@announcer"]=smalltalk.send((smalltalk.Announcer || Announcer),"_new",[]);
692
- self["@result"]=smalltalk.send((smalltalk.TestResult || TestResult),"_new",[]);
693
- return self},
1061
+ return smalltalk.withContext(function($ctx1) {
1062
+ smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
1063
+ self["@announcer"]=_st((smalltalk.Announcer || Announcer))._new();
1064
+ self["@result"]=_st((smalltalk.TestResult || TestResult))._new();
1065
+ self["@runNextTest"]=(function(){
1066
+ var runs;
1067
+ return smalltalk.withContext(function($ctx2) {
1068
+ runs;
1069
+ $1=_st(runs).__lt(_st(self["@result"])._total());
1070
+ if(smalltalk.assert($1)){
1071
+ return _st(_st(self)._contextOf_(_st(runs).__plus((1))))._start();
1072
+ };
1073
+ }, function($ctx2) {$ctx2.fillBlock({runs:runs},$ctx1)})});
1074
+ return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TestSuiteRunner)})},
694
1075
  args: [],
695
- source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new.\x0a result := TestResult new",
696
- messageSends: ["initialize", "new"],
1076
+ source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new.\x0a result := TestResult new.\x0a runNextTest := [ | runs | runs := result runs. runs < result total ifTrue: [ (self contextOf: runs + 1) start ]].",
1077
+ messageSends: ["initialize", "new", "runs", "ifTrue:", "start", "contextOf:", "+", "<", "total"],
697
1078
  referencedClasses: ["Announcer", "TestResult"]
698
1079
  }),
699
1080
  smalltalk.TestSuiteRunner);
@@ -705,8 +1086,10 @@ selector: "result",
705
1086
  category: 'accessing',
706
1087
  fn: function (){
707
1088
  var self=this;
708
- return self["@result"];
709
- },
1089
+ return smalltalk.withContext(function($ctx1) {
1090
+ $1=self["@result"];
1091
+ return $1;
1092
+ }, function($ctx1) {$ctx1.fill(self,"result",{}, smalltalk.TestSuiteRunner)})},
710
1093
  args: [],
711
1094
  source: "result\x0a\x09^result",
712
1095
  messageSends: [],
@@ -714,6 +1097,23 @@ referencedClasses: []
714
1097
  }),
715
1098
  smalltalk.TestSuiteRunner);
716
1099
 
1100
+ smalltalk.addMethod(
1101
+ "_resume",
1102
+ smalltalk.method({
1103
+ selector: "resume",
1104
+ category: 'actions',
1105
+ fn: function (){
1106
+ var self=this;
1107
+ return smalltalk.withContext(function($ctx1) {
1108
+ _st(self["@announcer"])._announce_(_st(_st((smalltalk.ResultAnnouncement || ResultAnnouncement))._new())._result_(self["@result"]));
1109
+ return self}, function($ctx1) {$ctx1.fill(self,"resume",{}, smalltalk.TestSuiteRunner)})},
1110
+ args: [],
1111
+ source: "resume\x0a\x09runNextTest fork.\x0a announcer announce: (ResultAnnouncement new result: result)",
1112
+ messageSends: ["fork", "announce:", "result:", "new"],
1113
+ referencedClasses: ["ResultAnnouncement"]
1114
+ }),
1115
+ smalltalk.TestSuiteRunner);
1116
+
717
1117
  smalltalk.addMethod(
718
1118
  "_run",
719
1119
  smalltalk.method({
@@ -721,25 +1121,13 @@ selector: "run",
721
1121
  category: 'actions',
722
1122
  fn: function (){
723
1123
  var self=this;
724
- var worker;
725
- smalltalk.send(self["@result"],"_total_",[smalltalk.send(self["@suite"],"_size",[])]);
726
- smalltalk.send(self["@announcer"],"_announce_",[smalltalk.send(smalltalk.send((smalltalk.ResultAnnouncement || ResultAnnouncement),"_new",[]),"_result_",[self["@result"]])]);
727
- worker=(function(){
728
- return smalltalk.send(self["@result"],"_nextRunDo_",[(function(index){
729
- return smalltalk.send((function(){
730
- return smalltalk.send(self["@result"],"_runCase_",[smalltalk.send(self["@suite"],"_at_",[index])]);
731
- }),"_ensure_",[(function(){
732
- smalltalk.send(worker,"_fork",[]);
733
- return smalltalk.send(self["@announcer"],"_announce_",[smalltalk.send(smalltalk.send((smalltalk.ResultAnnouncement || ResultAnnouncement),"_new",[]),"_result_",[self["@result"]])]);
734
- })]);
735
- })]);
736
- });
737
- smalltalk.send(worker,"_fork",[]);
738
- return self},
1124
+ return smalltalk.withContext(function($ctx1) {
1125
+ _st(self)._resume();
1126
+ return self}, function($ctx1) {$ctx1.fill(self,"run",{}, smalltalk.TestSuiteRunner)})},
739
1127
  args: [],
740
- source: "run\x0a\x09| worker |\x0a\x09result total: suite size.\x0a announcer announce: (ResultAnnouncement new result: result).\x0a worker := [ result nextRunDo: [ :index |\x0a\x09\x09[ result runCase: (suite at: index) ]\x0a\x09\x09ensure: [ worker fork.\x0a \x09announcer announce: (ResultAnnouncement new result: result) ]]].\x0a\x09worker fork",
741
- messageSends: ["total:", "size", "announce:", "result:", "new", "nextRunDo:", "ensure:", "fork", "runCase:", "at:"],
742
- referencedClasses: ["ResultAnnouncement"]
1128
+ source: "run\x0a\x09result total: suite size.\x0a\x09self resume",
1129
+ messageSends: ["total:", "size", "resume"],
1130
+ referencedClasses: []
743
1131
  }),
744
1132
  smalltalk.TestSuiteRunner);
745
1133
 
@@ -750,8 +1138,8 @@ selector: "suite:",
750
1138
  category: 'accessing',
751
1139
  fn: function (aCollection){
752
1140
  var self=this;
753
- self["@suite"]=aCollection;
754
- return self},
1141
+ return smalltalk.withContext(function($ctx1) {
1142
+ return self}, function($ctx1) {$ctx1.fill(self,"suite:",{aCollection:aCollection}, smalltalk.TestSuiteRunner)})},
755
1143
  args: ["aCollection"],
756
1144
  source: "suite: aCollection\x0a\x09suite := aCollection",
757
1145
  messageSends: [],
@@ -767,8 +1155,8 @@ selector: "new",
767
1155
  category: 'instance creation',
768
1156
  fn: function (){
769
1157
  var self=this;
770
- smalltalk.send(self,"_shouldNotImplement",[]);
771
- return self},
1158
+ return smalltalk.withContext(function($ctx1) {
1159
+ return self}, function($ctx1) {$ctx1.fill(self,"new",{}, smalltalk.TestSuiteRunner.klass)})},
772
1160
  args: [],
773
1161
  source: "new\x0a\x09self shouldNotImplement",
774
1162
  messageSends: ["shouldNotImplement"],
@@ -783,10 +1171,10 @@ selector: "on:",
783
1171
  category: 'instance creation',
784
1172
  fn: function (aCollection){
785
1173
  var self=this;
786
- var $1;
787
- $1=smalltalk.send(smalltalk.send(self,"_new",[],smalltalk.Object.klass),"_suite_",[aCollection]);
1174
+ return smalltalk.withContext(function($ctx1) {
1175
+ $1=_st(smalltalk.Object.klass.fn.prototype._new.apply(_st(self), []))._suite_(aCollection);
788
1176
  return $1;
789
- },
1177
+ }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection}, smalltalk.TestSuiteRunner.klass)})},
790
1178
  args: ["aCollection"],
791
1179
  source: "on: aCollection\x0a\x09^super new suite: aCollection",
792
1180
  messageSends: ["suite:", "new"],