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
@@ -14,11 +14,25 @@ result: aTestResult
14
14
  ! !
15
15
 
16
16
  Object subclass: #TestCase
17
- instanceVariableNames: 'testSelector'
17
+ instanceVariableNames: 'testSelector asyncTimeout context'
18
18
  package: 'SUnit'!
19
+ !TestCase commentStamp!
20
+ A TestCase is an implementation of the command pattern to run a test.
21
+
22
+ `TestCase` instances are created with the class method `#selector:`,
23
+ passing the symbol that names the method to be executed when the test case runs.
24
+
25
+ When you discover a new fixture, subclass `TestCase` and create a `#test...` method for the first test.
26
+ As that method develops and more `#test...` methods are added, you will find yourself refactoring temps
27
+ into instance variables for the objects in the fixture and overriding `#setUp` to initialize these variables.
28
+ As required, override `#tearDown` to nil references, release objects and deallocate.!
19
29
 
20
30
  !TestCase methodsFor: 'accessing'!
21
31
 
32
+ context: aRunningTestContext
33
+ context := aRunningTestContext
34
+ !
35
+
22
36
  selector
23
37
  ^testSelector
24
38
  !
@@ -27,6 +41,40 @@ setTestSelector: aSelector
27
41
  testSelector := aSelector
28
42
  ! !
29
43
 
44
+ !TestCase methodsFor: 'async'!
45
+
46
+ async: aBlock
47
+ | c |
48
+ self errorIfNotAsync: '#async'.
49
+ c := context.
50
+ ^ [ self isAsync ifTrue: [ c execute: aBlock ] ]
51
+ !
52
+
53
+ finished
54
+ self errorIfNotAsync: '#finished'.
55
+ asyncTimeout := nil
56
+ !
57
+
58
+ timeout: aNumber
59
+ "Set a grace time timeout in milliseconds to run the test asynchronously"
60
+
61
+ asyncTimeout ifNotNil: [ asyncTimeout clearTimeout ].
62
+
63
+ "to allow #async: message send without throwing an error"
64
+ asyncTimeout := 0.
65
+
66
+ asyncTimeout := (self async: [
67
+ self assert: false description: 'SUnit grace time exhausted' ])
68
+ valueWithTimeout: aNumber
69
+ ! !
70
+
71
+ !TestCase methodsFor: 'error handling'!
72
+
73
+ errorIfNotAsync: aString
74
+ self isAsync ifFalse: [
75
+ self error: aString, ' used without prior #timeout:' ]
76
+ ! !
77
+
30
78
  !TestCase methodsFor: 'private'!
31
79
 
32
80
  signalFailure: aString
@@ -38,14 +86,14 @@ signalFailure: aString
38
86
  !TestCase methodsFor: 'running'!
39
87
 
40
88
  performTest
89
+ asyncTimeout := nil.
41
90
  self perform: self selector
42
91
  !
43
92
 
44
93
  runCase
45
- [ self setUp.
46
- self performTest ] ensure: [
47
- self tearDown.
48
- "self cleanUpInstanceVariables" ]
94
+ "Runs a test case in isolated context, leaking all errors."
95
+
96
+ (TestContext testCase: self) start
49
97
  !
50
98
 
51
99
  setUp
@@ -72,6 +120,10 @@ deny: aBoolean
72
120
  self assert: aBoolean not
73
121
  !
74
122
 
123
+ isAsync
124
+ ^asyncTimeout notNil
125
+ !
126
+
75
127
  should: aBlock
76
128
  self assert: aBlock value
77
129
  !
@@ -126,13 +178,127 @@ shouldInheritSelectors
126
178
  ^self ~= self lookupHierarchyRoot
127
179
  ! !
128
180
 
181
+ Object subclass: #TestContext
182
+ instanceVariableNames: 'testCase'
183
+ package: 'SUnit'!
184
+ !TestContext commentStamp!
185
+ TestContext governs running a particular test case.
186
+
187
+ It's main added value is `#execute:` method which runs a block
188
+ as a part of test case (restores context, nilling it afterwards,
189
+ cleaning/calling tearDown as appropriate for sync/async scenario).!
190
+
191
+ !TestContext methodsFor: 'accessing'!
192
+
193
+ testCase: aTestCase
194
+ testCase := aTestCase
195
+ ! !
196
+
197
+ !TestContext methodsFor: 'running'!
198
+
199
+ execute: aBlock
200
+ | failed |
201
+
202
+ testCase context: self.
203
+ [
204
+ failed := true.
205
+ aBlock value.
206
+ failed := false
207
+ ]
208
+ ensure: [
209
+ testCase context: nil.
210
+
211
+ (failed and: [ testCase isAsync ]) ifTrue: [
212
+ testCase finished ].
213
+ testCase isAsync ifFalse: [
214
+ testCase tearDown ] ]
215
+ !
216
+
217
+ start
218
+ self execute: [
219
+ testCase setUp.
220
+ testCase performTest ]
221
+ ! !
222
+
223
+ !TestContext class methodsFor: 'instance creation'!
224
+
225
+ testCase: aTestCase
226
+ ^self new
227
+ testCase: aTestCase;
228
+ yourself
229
+ ! !
230
+
231
+ TestContext subclass: #ReportingTestContext
232
+ instanceVariableNames: 'finished result'
233
+ package: 'SUnit'!
234
+ !ReportingTestContext commentStamp!
235
+ ReportingTestContext adds `TestResult` reporting
236
+ to `TestContext`.
237
+
238
+ Errors are caught and save into a `TestResult`,
239
+ When test case is finished (which can be later for async tests),
240
+ a callback block is executed; this is used by a `TestSuiteRunner`.!
241
+
242
+ !ReportingTestContext methodsFor: 'accessing'!
243
+
244
+ finished: aBlock
245
+ finished := aBlock
246
+ !
247
+
248
+ result: aTestResult
249
+ result := aTestResult
250
+ ! !
251
+
252
+ !ReportingTestContext methodsFor: 'private'!
253
+
254
+ withErrorReporting: aBlock
255
+ [ aBlock
256
+ on: TestFailure
257
+ do: [ :ex | result addFailure: testCase ]
258
+ ]
259
+ on: Error
260
+ do: [ :ex | result addError: testCase ]
261
+ ! !
262
+
263
+ !ReportingTestContext methodsFor: 'running'!
264
+
265
+ execute: aBlock
266
+ [
267
+ self withErrorReporting: [ super execute: aBlock ]
268
+ ]
269
+ ensure: [
270
+ testCase isAsync ifFalse: [
271
+ result increaseRuns. finished value ] ]
272
+ ! !
273
+
274
+ !ReportingTestContext class methodsFor: 'instance creation'!
275
+
276
+ testCase: aTestCase result: aTestResult finished: aBlock
277
+ ^(super testCase: aTestCase)
278
+ result: aTestResult;
279
+ finished: aBlock;
280
+ yourself
281
+ ! !
282
+
129
283
  Error subclass: #TestFailure
130
284
  instanceVariableNames: ''
131
285
  package: 'SUnit'!
286
+ !TestFailure commentStamp!
287
+ The test framework distinguishes between failures and errors.
288
+ A failure is an event whose possibiity is explicitly anticipated and checked for in an assertion,
289
+ whereas an error is an unanticipated problem like a division by 0 or an index out of bounds.
290
+
291
+ TestFailure is raised when the boolean parameter of an #`assert:` or `#deny:` call is the opposite of what the assertion claims.!
132
292
 
133
293
  Object subclass: #TestResult
134
294
  instanceVariableNames: 'timestamp runs errors failures total'
135
295
  package: 'SUnit'!
296
+ !TestResult commentStamp!
297
+ A TestResult implements the collecting parameter pattern for running a bunch of tests.
298
+
299
+ A TestResult holds tests that have run, sorted into the result categories of passed, failures and errors.
300
+
301
+ TestResult is an interesting object to subclass or substitute. `#runCase:` is the external protocol you need to reproduce!
136
302
 
137
303
  !TestResult methodsFor: 'accessing'!
138
304
 
@@ -209,7 +375,7 @@ runCase: aTestCase
209
375
  ! !
210
376
 
211
377
  Object subclass: #TestSuiteRunner
212
- instanceVariableNames: 'suite result announcer'
378
+ instanceVariableNames: 'suite result announcer runNextTest'
213
379
  package: 'SUnit'!
214
380
 
215
381
  !TestSuiteRunner methodsFor: 'accessing'!
@@ -228,15 +394,14 @@ suite: aCollection
228
394
 
229
395
  !TestSuiteRunner methodsFor: 'actions'!
230
396
 
397
+ resume
398
+ runNextTest fork.
399
+ announcer announce: (ResultAnnouncement new result: result)
400
+ !
401
+
231
402
  run
232
- | worker |
233
403
  result total: suite size.
234
- announcer announce: (ResultAnnouncement new result: result).
235
- worker := [ result nextRunDo: [ :index |
236
- [ result runCase: (suite at: index) ]
237
- ensure: [ worker fork.
238
- announcer announce: (ResultAnnouncement new result: result) ]]].
239
- worker fork
404
+ self resume
240
405
  ! !
241
406
 
242
407
  !TestSuiteRunner methodsFor: 'initialization'!
@@ -244,7 +409,14 @@ run
244
409
  initialize
245
410
  super initialize.
246
411
  announcer := Announcer new.
247
- result := TestResult new
412
+ result := TestResult new.
413
+ runNextTest := [ | runs | runs := result runs. runs < result total ifTrue: [ (self contextOf: runs + 1) start ]].
414
+ ! !
415
+
416
+ !TestSuiteRunner methodsFor: 'private'!
417
+
418
+ contextOf: anInteger
419
+ ^ReportingTestContext testCase: (suite at: anInteger) result: result finished: [ self resume ]
248
420
  ! !
249
421
 
250
422
  !TestSuiteRunner class methodsFor: 'instance creation'!
@@ -0,0 +1,6 @@
1
+ #!/usr/env/bin ruby
2
+
3
+ require 'rubygems'
4
+ require 'resin/cli'
5
+
6
+ Resin::CLI.start
@@ -0,0 +1,19 @@
1
+ require 'thor'
2
+
3
+ module Resin
4
+ class CLI < Thor
5
+ desc 'start', 'Run the current Resin application'
6
+ def start
7
+ require 'sinatra/base'
8
+ require 'sinatra/resin'
9
+ Sinatra::Application.run!
10
+ end
11
+
12
+
13
+ desc 'compile', 'Compile all the Amber and JavaScripts together'
14
+ def compile
15
+ require 'resin/compiler'
16
+ Resin::Compiler.run
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-29 00:00:00.000000000 Z
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &10777680 !ruby/object:Gem::Requirement
16
+ requirement: &12090640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *10777680
24
+ version_requirements: *12090640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &10776980 !ruby/object:Gem::Requirement
27
+ requirement: &12090020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *10776980
35
+ version_requirements: *12090020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shotgun
38
- requirement: &10776180 !ruby/object:Gem::Requirement
38
+ requirement: &12088380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *10776180
46
+ version_requirements: *12088380
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &10775220 !ruby/object:Gem::Requirement
49
+ requirement: &12087040 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *10775220
57
+ version_requirements: *12087040
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rack-test
60
- requirement: &10774040 !ruby/object:Gem::Requirement
60
+ requirement: &12086040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *10774040
68
+ version_requirements: *12086040
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: haml
71
- requirement: &10789120 !ruby/object:Gem::Requirement
71
+ requirement: &12085480 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *10789120
79
+ version_requirements: *12085480
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sinatra
82
- requirement: &10787700 !ruby/object:Gem::Requirement
82
+ requirement: &12102380 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *10787700
90
+ version_requirements: *12102380
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: json
93
- requirement: &10786400 !ruby/object:Gem::Requirement
93
+ requirement: &12101680 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,21 +98,31 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *10786400
101
+ version_requirements: *12101680
102
+ - !ruby/object:Gem::Dependency
103
+ name: thor
104
+ requirement: &12100420 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: *12100420
102
113
  description:
103
114
  email: tyler@linux.com
104
115
  executables:
105
- - runresin
106
- - resin-compile
116
+ - resin
107
117
  extensions: []
108
118
  extra_rdoc_files:
109
119
  - README.markdown
110
120
  files:
111
- - bin/runresin
112
- - bin/resin-compile
121
+ - bin/resin
113
122
  - lib/sinatra/resin/helpers.rb
114
123
  - lib/sinatra/resin.rb
115
124
  - lib/resin/helpers.rb
125
+ - lib/resin/cli.rb
116
126
  - lib/resin/compiler.rb
117
127
  - lib/resin.rb
118
128
  - lib/resin/views/index.haml
@@ -164,7 +174,7 @@ files:
164
174
  - amber/js/lib/es5-shim-2.0.2/CONTRIBUTORS.md
165
175
  - amber/js/lib/es5-shim-2.0.2/README.md
166
176
  - amber/js/lib/es5-shim-2.0.2/LICENSE
167
- - amber/js/lib/peg-0.6.2.min.js
177
+ - amber/js/lib/peg-0.7.0.min.js
168
178
  - amber/js/lib/CodeMirror/smalltalk.js
169
179
  - amber/js/lib/CodeMirror/codemirror.css
170
180
  - amber/js/lib/CodeMirror/amber.css
@@ -202,10 +212,13 @@ files:
202
212
  - amber/js/Helios-Environments.deploy.js
203
213
  - amber/js/Helios-Layout.js
204
214
  - amber/js/Kernel-Methods.deploy.js
215
+ - amber/js/SUnit-Tests.js
205
216
  - amber/js/Compiler-Inlining.deploy.js
206
217
  - amber/js/Spaces.deploy.js
218
+ - amber/js/Compiler-Interpreter.deploy.js
207
219
  - amber/js/Helios-Browser.js
208
220
  - amber/js/Canvas.js
221
+ - amber/js/SUnit-Tests.deploy.js
209
222
  - amber/js/Benchfib.js
210
223
  - amber/js/Compiler.deploy.js
211
224
  - amber/js/boot.js
@@ -229,6 +242,7 @@ files:
229
242
  - amber/js/IDE.js
230
243
  - amber/js/Compiler-AST.deploy.js
231
244
  - amber/js/Compiler-Tests.js
245
+ - amber/js/Compiler-Interpreter.js
232
246
  - amber/js/Examples.deploy.js
233
247
  - amber/js/Documentation.deploy.js
234
248
  - amber/js/Kernel-Exceptions.js
@@ -244,10 +258,12 @@ files:
244
258
  - amber/st/Examples.st
245
259
  - amber/st/Documentation.st
246
260
  - amber/st/Compiler-Semantic.st
261
+ - amber/st/Compiler-Interpreter.st
247
262
  - amber/st/Compiler-Exceptions.st
248
263
  - amber/st/SUnit.st
249
264
  - amber/st/Helios-Browser.st
250
265
  - amber/st/Compiler-Core.st
266
+ - amber/st/SUnit-Tests.st
251
267
  - amber/st/Canvas.st
252
268
  - amber/st/Kernel-Tests.st
253
269
  - amber/st/Helios-Core.st
@@ -303,7 +319,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
303
319
  version: '0'
304
320
  segments:
305
321
  - 0
306
- hash: -4232258665751550036
322
+ hash: 541069464667052529
307
323
  required_rubygems_version: !ruby/object:Gem::Requirement
308
324
  none: false
309
325
  requirements:
@@ -312,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
328
  version: '0'
313
329
  segments:
314
330
  - 0
315
- hash: -4232258665751550036
331
+ hash: 541069464667052529
316
332
  requirements: []
317
333
  rubyforge_project:
318
334
  rubygems_version: 1.8.10