opal 0.9.4 → 0.10.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/.gitignore +2 -3
  4. data/.gitmodules +5 -2
  5. data/.jshintrc +1 -8
  6. data/.rspec +1 -1
  7. data/.travis.yml +15 -23
  8. data/CHANGELOG.md +511 -326
  9. data/CODE_OF_CONDUCT.md +13 -15
  10. data/CONTRIBUTING.md +26 -216
  11. data/Gemfile +20 -12
  12. data/Guardfile +2 -2
  13. data/HACKING.md +230 -0
  14. data/README.md +6 -7
  15. data/bin/opal-mspec +1 -1
  16. data/config.ru +2 -2
  17. data/docs/faq.md +1 -1
  18. data/docs/source_maps.md +1 -1
  19. data/lib/opal.rb +1 -0
  20. data/lib/opal/builder.rb +1 -1
  21. data/lib/opal/cli.rb +30 -28
  22. data/lib/opal/cli_options.rb +3 -0
  23. data/lib/opal/cli_runners.rb +14 -1
  24. data/lib/opal/cli_runners/{apple_script.rb → applescript.rb} +3 -3
  25. data/lib/opal/cli_runners/nashorn.rb +2 -2
  26. data/lib/opal/cli_runners/nodejs.rb +2 -2
  27. data/lib/opal/cli_runners/phantom.js +24 -0
  28. data/lib/opal/cli_runners/phantomjs.rb +10 -10
  29. data/lib/opal/cli_runners/server.rb +3 -3
  30. data/lib/opal/compiler.rb +43 -4
  31. data/lib/opal/config.rb +3 -1
  32. data/lib/opal/errors.rb +13 -0
  33. data/lib/opal/fragment.rb +0 -13
  34. data/lib/opal/nodes.rb +10 -0
  35. data/lib/opal/nodes/args/initialize_kwargs.rb +28 -0
  36. data/lib/opal/nodes/args/kwarg.rb +29 -0
  37. data/lib/opal/nodes/args/kwoptarg.rb +29 -0
  38. data/lib/opal/nodes/args/kwrestarg.rb +39 -0
  39. data/lib/opal/nodes/args/mlhsarg.rb +79 -0
  40. data/lib/opal/nodes/args/normarg.rb +26 -0
  41. data/lib/opal/nodes/args/optarg.rb +27 -0
  42. data/lib/opal/nodes/args/post_args.rb +200 -0
  43. data/lib/opal/nodes/args/post_kwargs.rb +31 -0
  44. data/lib/opal/nodes/args/restarg.rb +33 -0
  45. data/lib/opal/nodes/base.rb +12 -0
  46. data/lib/opal/nodes/call.rb +92 -33
  47. data/lib/opal/nodes/def.rb +26 -169
  48. data/lib/opal/nodes/hash.rb +10 -4
  49. data/lib/opal/nodes/helpers.rb +6 -3
  50. data/lib/opal/nodes/inline_args.rb +61 -0
  51. data/lib/opal/nodes/iter.rb +73 -82
  52. data/lib/opal/nodes/logic.rb +12 -2
  53. data/lib/opal/nodes/masgn.rb +1 -2
  54. data/lib/opal/nodes/node_with_args.rb +141 -0
  55. data/lib/opal/nodes/rescue.rb +121 -43
  56. data/lib/opal/nodes/scope.rb +24 -5
  57. data/lib/opal/nodes/super.rb +122 -54
  58. data/lib/opal/nodes/top.rb +0 -12
  59. data/lib/opal/nodes/yield.rb +2 -13
  60. data/lib/opal/parser.rb +67 -39
  61. data/lib/opal/parser/grammar.rb +3319 -2961
  62. data/lib/opal/parser/grammar.y +234 -46
  63. data/lib/opal/parser/lexer.rb +105 -17
  64. data/lib/opal/parser/sexp.rb +4 -0
  65. data/lib/opal/paths.rb +4 -0
  66. data/lib/opal/regexp_anchors.rb +19 -1
  67. data/lib/opal/sprockets.rb +21 -18
  68. data/lib/opal/sprockets/environment.rb +0 -8
  69. data/lib/opal/sprockets/processor.rb +13 -16
  70. data/lib/opal/sprockets/server.rb +6 -12
  71. data/lib/opal/version.rb +1 -1
  72. data/opal.gemspec +1 -0
  73. data/opal/corelib/array.rb +209 -131
  74. data/opal/corelib/basic_object.rb +7 -3
  75. data/opal/corelib/class.rb +11 -17
  76. data/opal/corelib/constants.rb +2 -2
  77. data/opal/corelib/enumerable.rb +178 -355
  78. data/opal/corelib/enumerator.rb +3 -46
  79. data/opal/corelib/error.rb +2 -2
  80. data/opal/corelib/file.rb +13 -1
  81. data/opal/corelib/hash.rb +26 -56
  82. data/opal/corelib/helpers.rb +10 -0
  83. data/opal/corelib/kernel.rb +6 -3
  84. data/opal/corelib/module.rb +62 -31
  85. data/opal/corelib/number.rb +7 -16
  86. data/opal/corelib/proc.rb +24 -9
  87. data/opal/corelib/range.rb +4 -13
  88. data/opal/corelib/runtime.js +515 -378
  89. data/opal/corelib/string.rb +21 -49
  90. data/opal/corelib/struct.rb +50 -35
  91. data/opal/corelib/unsupported.rb +18 -30
  92. data/opal/opal.rb +0 -1
  93. data/opal/opal/mini.rb +1 -0
  94. data/spec/README.md +6 -4
  95. data/spec/filters/bugs/array.rb +0 -42
  96. data/spec/filters/bugs/basicobject.rb +0 -2
  97. data/spec/filters/bugs/bigdecimal.rb +160 -0
  98. data/spec/filters/bugs/class.rb +0 -5
  99. data/spec/filters/bugs/date.rb +1 -48
  100. data/spec/filters/bugs/enumerable.rb +4 -12
  101. data/spec/filters/bugs/enumerator.rb +0 -1
  102. data/spec/filters/bugs/exception.rb +4 -3
  103. data/spec/filters/bugs/float.rb +4 -2
  104. data/spec/filters/bugs/kernel.rb +25 -10
  105. data/spec/filters/bugs/language.rb +119 -68
  106. data/spec/filters/bugs/method.rb +135 -0
  107. data/spec/filters/bugs/module.rb +13 -28
  108. data/spec/filters/bugs/proc.rb +18 -8
  109. data/spec/filters/bugs/range.rb +0 -3
  110. data/spec/filters/bugs/rational.rb +4 -0
  111. data/spec/filters/bugs/regexp.rb +68 -36
  112. data/spec/filters/bugs/string.rb +1 -1
  113. data/spec/filters/bugs/struct.rb +0 -12
  114. data/spec/filters/bugs/time.rb +1 -0
  115. data/spec/filters/bugs/unboundmethod.rb +2 -1
  116. data/spec/filters/unsupported/freeze.rb +3 -1
  117. data/spec/filters/unsupported/language.rb +0 -7
  118. data/spec/filters/unsupported/privacy.rb +7 -6
  119. data/spec/filters/unsupported/string.rb +10 -0
  120. data/spec/filters/unsupported/struct.rb +3 -0
  121. data/spec/filters/unsupported/symbol.rb +9 -0
  122. data/spec/filters/unsupported/taint.rb +0 -3
  123. data/spec/filters/unsupported/thread.rb +1 -0
  124. data/spec/lib/cli_runners/phantomjs_spec.rb +39 -0
  125. data/spec/lib/cli_spec.rb +42 -1
  126. data/spec/lib/compiler/call_spec.rb +700 -0
  127. data/spec/lib/compiler_spec.rb +46 -28
  128. data/spec/lib/config_spec.rb +13 -0
  129. data/spec/lib/parser/call_spec.rb +18 -0
  130. data/spec/lib/parser/def_spec.rb +29 -0
  131. data/spec/lib/parser/iter_spec.rb +15 -15
  132. data/spec/lib/parser/lambda_spec.rb +153 -12
  133. data/spec/lib/parser/string_spec.rb +5 -0
  134. data/spec/lib/parser/undef_spec.rb +1 -1
  135. data/spec/lib/parser/variables_spec.rb +24 -0
  136. data/spec/lib/paths_spec.rb +12 -5
  137. data/spec/lib/spec_helper.rb +5 -0
  138. data/spec/lib/sprockets/processor_spec.rb +6 -5
  139. data/spec/lib/sprockets_spec.rb +8 -0
  140. data/spec/mspec-opal/formatters.rb +188 -0
  141. data/spec/mspec-opal/runner.rb +193 -0
  142. data/spec/opal/core/enumerator/with_index_spec.rb +6 -0
  143. data/spec/opal/core/kernel/define_singleton_method_spec.rb +1 -1
  144. data/spec/opal/core/kernel/instance_variables_spec.rb +14 -0
  145. data/spec/opal/core/kernel/loop_spec.rb +1 -1
  146. data/spec/opal/core/kernel/raise_spec.rb +1 -1
  147. data/spec/opal/core/language/heredoc_spec.rb +42 -0
  148. data/spec/opal/core/language/rescue_spec.rb +18 -0
  149. data/spec/opal/core/language_spec.rb +22 -0
  150. data/spec/opal/core/module/const_defined_spec.rb +1 -2
  151. data/spec/opal/core/module/name_spec.rb +6 -0
  152. data/spec/opal/core/runtime/bridged_classes_spec.rb +14 -2
  153. data/spec/opal/core/runtime/rescue_spec.rb +12 -2
  154. data/spec/opal/core/runtime/super_spec.rb +1 -0
  155. data/spec/opal/core/string_spec.rb +21 -0
  156. data/spec/opal/stdlib/js_spec.rb +1 -1
  157. data/spec/opal/stdlib/native/hash_spec.rb +7 -0
  158. data/spec/opal/stdlib/promise/always_spec.rb +24 -5
  159. data/spec/opal/stdlib/promise/rescue_spec.rb +15 -6
  160. data/spec/opal/stdlib/promise/then_spec.rb +13 -5
  161. data/spec/opal/stdlib/promise/trace_spec.rb +5 -6
  162. data/spec/opal/stdlib/strscan/scan_spec.rb +1 -1
  163. data/spec/ruby_specs +122 -0
  164. data/spec/spec_helper.rb +3 -15
  165. data/stdlib/base64.rb +51 -121
  166. data/stdlib/bigdecimal.rb +231 -0
  167. data/stdlib/bigdecimal/bignumber.js.rb +11 -0
  168. data/stdlib/bigdecimal/kernel.rb +5 -0
  169. data/stdlib/date.rb +252 -10
  170. data/stdlib/native.rb +38 -38
  171. data/stdlib/nodejs/dir.rb +8 -6
  172. data/stdlib/nodejs/file.rb +28 -3
  173. data/stdlib/nodejs/node_modules/.bin/js-yaml +1 -0
  174. data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esparse +1 -0
  175. data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esvalidate +1 -0
  176. data/stdlib/nodejs/require.rb +1 -1
  177. data/stdlib/nodejs/yaml.rb +3 -2
  178. data/stdlib/opal-parser.rb +7 -2
  179. data/stdlib/pathname.rb +23 -1
  180. data/stdlib/phantomjs.rb +10 -0
  181. data/stdlib/promise.rb +38 -23
  182. data/tasks/building.rake +3 -3
  183. data/tasks/testing.rake +27 -14
  184. data/tasks/testing/mspec_special_calls.rb +1 -1
  185. data/tasks/testing/sprockets-phantomjs.js +4 -0
  186. data/test/opal/test_keyword.rb +110 -110
  187. data/test/opal/unsupported_and_bugs.rb +30 -0
  188. data/vendored-minitest/minitest/assertions.rb +1 -1
  189. metadata +65 -15
  190. data/.spectator +0 -2
  191. data/.spectator-mspec +0 -3
  192. data/opal/corelib/array/inheritance.rb +0 -127
  193. data/spec/rubyspecs +0 -139
@@ -0,0 +1,6 @@
1
+ describe "Enumerator#with_index" do
2
+ it "returns the result of the previously called method" do
3
+ [1, 2, 3].each.with_index { |item, index| item * 2 }.should == [1, 2, 3]
4
+ [1, 2, 3].map.with_index { |item, index| item * 2 }.should == [2, 4, 6]
5
+ end
6
+ end
@@ -18,4 +18,4 @@ describe "Kernel#define_singleton_method" do
18
18
  it "maintains the Proc's scope" do
19
19
  DefineMethodByProcScope.proc_test.should == true
20
20
  end
21
- end
21
+ end
@@ -15,6 +15,20 @@ describe "Kernel#instance_variables" do
15
15
  it 'returns blank array' do
16
16
  expect({}.instance_variables).to eq([])
17
17
  end
18
+
19
+ context 'for a hash with a default value' do
20
+ it 'returns a blank array' do
21
+ hash = Hash.new(0)
22
+ expect(hash.instance_variables).to eq([])
23
+ end
24
+ end
25
+
26
+ context 'for a hash with a default proc' do
27
+ it 'returns a blank array' do
28
+ hash = Hash.new { 0 }
29
+ expect(hash.instance_variables).to eq([])
30
+ end
31
+ end
18
32
  end
19
33
 
20
34
  context 'for object' do
@@ -20,4 +20,4 @@ describe "Kernel.loop" do
20
20
  break
21
21
  end.should == nil
22
22
  end
23
- end
23
+ end
@@ -1,5 +1,5 @@
1
1
  describe "Kernel#raise" do
2
- # rubyspecs test most of this, but rubyspecs won't differentiate between nil and undefined
2
+ # ruby-specs test most of this, but ruby-specs won't differentiate between nil and undefined
3
3
  it "raises messages without exceptions" do
4
4
  lambda { raise Exception }.should raise_error(Exception)
5
5
  ex = nil
@@ -0,0 +1,42 @@
1
+ describe "'Squiggly' heredoc" do
2
+ context "when heredoc is blank" do
3
+ it "returns a blank string" do
4
+ heredoc = <<~HERE
5
+ HERE
6
+
7
+ heredoc.should == ""
8
+ end
9
+ end
10
+
11
+ context "when heredoc contains multiple lines" do
12
+ it "selects a least-indented line and removes its indentation from all the lines" do
13
+ heredoc = <<~HERE
14
+ a
15
+ b
16
+ c
17
+ HERE
18
+
19
+ heredoc.should == "a\n b\n c\n"
20
+ end
21
+ end
22
+
23
+ it "supports escaped heredoc identifier" do
24
+ <<~"HERE".should == ""
25
+ HERE
26
+
27
+ <<~'HERE'.should == ""
28
+ HERE
29
+ end
30
+
31
+ it "doesn't allow <<-~ syntax" do
32
+ lambda {
33
+ eval("<<-~HERE\nHERE")
34
+ }.should raise_error
35
+ end
36
+
37
+ it "doesn't allow <<~- syntax" do
38
+ lambda {
39
+ eval("<<~-HERE\nHERE")
40
+ }.should raise_error
41
+ end
42
+ end
@@ -0,0 +1,18 @@
1
+ describe 'rescue' do
2
+ it 'wraps a try{}catch{} to a function when there is a method call on returning value' do
3
+ begin
4
+ 1 + 1
5
+ rescue
6
+ end.should == 2
7
+ end
8
+
9
+ it 'explicitely adds return to the rescue part when there is ensure statement' do
10
+ begin
11
+ 1 + 1
12
+ rescue
13
+ 3
14
+ ensure
15
+ 4
16
+ end.should == 2
17
+ end
18
+ end
@@ -21,3 +21,25 @@ describe "begin & rescue blocks" do
21
21
  result.should == "bar"
22
22
  end
23
23
  end
24
+
25
+ describe "generated method names" do
26
+ it "does not conflict with local Ruby variables" do
27
+ Class.new {
28
+ value = 123
29
+ def value
30
+ 456
31
+ end
32
+ value.should == 123
33
+ }
34
+ end
35
+
36
+ it "does not conflict with local JS variables" do
37
+ Class.new {
38
+ `var value = 123;`
39
+ def value
40
+ 456
41
+ end
42
+ `value`.should == 123
43
+ }
44
+ end
45
+ end
@@ -4,7 +4,7 @@ CD_CONST1 = :const1
4
4
 
5
5
  module ConstDefinedSpecs
6
6
  FOO = 100
7
-
7
+
8
8
  module Bar
9
9
  BAR = 200
10
10
 
@@ -46,7 +46,6 @@ describe "Module#const_defined?" do
46
46
  lambda { ConstantSpecs.const_defined? "__CONSTX__" }.should raise_error(NameError)
47
47
  lambda { ConstantSpecs.const_defined? "@Name" }.should raise_error(NameError)
48
48
  lambda { ConstantSpecs.const_defined? "!Name" }.should raise_error(NameError)
49
- lambda { ConstantSpecs.const_defined? "::Name" }.should raise_error(NameError)
50
49
  end
51
50
 
52
51
  it "raises a NameError if the name contains non-word characters" do
@@ -5,6 +5,8 @@ module ModuleNameSpec
5
5
  class B
6
6
  end
7
7
  end
8
+
9
+ Subclass = Class.new(Hash)
8
10
  end
9
11
 
10
12
  describe "Module#name" do
@@ -32,4 +34,8 @@ describe "Module#name" do
32
34
  ModuleNameSpec::A.name.should == "ModuleNameSpec::A"
33
35
  ModuleNameSpec::A::B.name.should == "ModuleNameSpec::A::B"
34
36
  end
37
+
38
+ it 'returns correct constant name when created using Const = Class.new(Superclass)' do
39
+ ModuleNameSpec::Subclass.name.should == "ModuleNameSpec::Subclass"
40
+ end
35
41
  end
@@ -8,6 +8,11 @@ class TopBridgedClassDemo < `bridge_class_demo`
8
8
  def some_bridged_method
9
9
  [1, 2, 3]
10
10
  end
11
+
12
+ def method_missing(name, *args, &block)
13
+ return :catched if name == :catched_by_method_missing
14
+ super
15
+ end
11
16
  end
12
17
 
13
18
  describe "Bridged Classes" do
@@ -60,6 +65,13 @@ describe "Bridged Classes" do
60
65
  Array.instance_methods(false).should_not include(:send)
61
66
  end
62
67
  end
68
+
69
+ describe '#method_missing' do
70
+ it 'works' do
71
+ lambda { @instance.not_catched_by_method_missing }.should raise_error(NoMethodError)
72
+ @instance.catched_by_method_missing.should == :catched
73
+ end
74
+ end
63
75
  end
64
76
 
65
77
  class ModularizedBridgeClass
@@ -86,11 +98,11 @@ describe 'Bridged classes in different modules' do
86
98
  @bridged = BridgeModule::ModularizedBridgeClass
87
99
  @instance = `new bridge_class_demo_module()`
88
100
  end
89
-
101
+
90
102
  it "should expose the given class not at the top level scope" do
91
103
  @bridged.should be_kind_of(Class)
92
104
  end
93
-
105
+
94
106
  it 'should not disturb an existing class at the top level scope' do
95
107
  ModularizedBridgeClass.new.something.should == 'different module'
96
108
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  class RescueReturningSpec
4
2
  def single
5
3
  begin
@@ -36,7 +34,19 @@ describe "The rescue keyword" do
36
34
  RescueReturningSpec.new.empty_rescue.should be_nil
37
35
  end
38
36
 
37
+ it "by default, catch StandardError, not all Exception" do
38
+ lambda { begin;raise Exception.new;rescue;end }.should raise_error
39
+ lambda { begin;raise "err";rescue;end }.should_not raise_error
40
+
41
+ # one line rescue
42
+ lambda { raise Exception rescue nil }.should raise_error(Exception)
43
+ lambda { raise "err" rescue nil }.should_not raise_error
44
+ (raise "err" rescue "foo").should == "foo"
45
+ ("err" rescue "foo").should == "err"
46
+ end
47
+
39
48
  it 'Fix using more than two "rescue" in sequence #1269' do
49
+ $ScratchPad = []
40
50
  # As a statement
41
51
  begin
42
52
  raise IOError, 'foo'
@@ -99,6 +99,7 @@ describe "The 'super' keyword" do
99
99
  @kls = SingletonMethodSuperSpec::A
100
100
  end
101
101
 
102
+ # TODO: This is not correct behavior (MRI returns true)
102
103
  it "does not pass the block to super" do
103
104
  @obj.super_args(1, 2, 3) { }.should be_false
104
105
  @kls.super_args() { }.should be_false
@@ -8,4 +8,25 @@ describe "String" do
8
8
  str2 = "d" "#{str}"
9
9
  str2.should == "dab"
10
10
  end
11
+
12
+ it 'parses complex heredoc (pr #1363)' do
13
+ str = <<'...end ruby23.y/module_eval...'
14
+
15
+ def version
16
+ 23
17
+ end
18
+
19
+ def default_encoding
20
+ Encoding::UTF_8
21
+ end
22
+ ...end ruby23.y/module_eval...
23
+
24
+ str.should == "\n def version\n 23\n end\n\n def default_encoding\n Encoding::UTF_8\n end\n"
25
+ end
26
+ end
27
+
28
+ describe "String#tr" do
29
+ it 'regression for: https://github.com/opal/opal/issues/1386' do
30
+ 'YWE/'.tr('+/', '-_').should == 'YWE_'
31
+ end
11
32
  end
@@ -22,7 +22,7 @@ describe 'javascript operations using JS module' do
22
22
  it 'JS.instanceof uses instanceof to check if value is an instance of a function' do
23
23
  f = `function(){}`
24
24
  JS.instanceof(JS.new(f), f).should == true
25
- JS.instanceof(JS.new(f), `function(){}`).should == false
25
+ JS.instanceof(JS.new(f), `function(){}`).should == false
26
26
  end
27
27
 
28
28
  it 'JS.delete uses delete to remove properties from objects' do
@@ -40,5 +40,12 @@ describe Hash do
40
40
  native = obj.to_n
41
41
  `#{native}.a_key.key`.should == 1
42
42
  end
43
+
44
+ it 'passes Ruby objects that cannot be converted' do
45
+ object = Object.new
46
+ hash = { foo: object }
47
+ native = hash.to_n
48
+ expect(`#{native}.foo`).to eq object
49
+ end
43
50
  end
44
51
  end
@@ -19,12 +19,31 @@ describe 'Promise#always' do
19
19
  x.should == 3
20
20
  end
21
21
 
22
- it 'raises an exception when the promise has already been chained' do
22
+ it 'can be called multiple times on resolved promises' do
23
23
  p = Promise.value(2)
24
- p.then {}
24
+ x = 1
25
+ p.then { x += 1 }
26
+ p.fail { x += 2 }
27
+ p.always { x += 3 }
25
28
 
26
- proc {
27
- p.always {}
28
- }.should raise_error(ArgumentError)
29
+ x.should == 5
30
+ end
31
+
32
+ it 'can be called multiple times on rejected promises' do
33
+ p = Promise.error(2)
34
+ x = 1
35
+ p.then { x += 1 }
36
+ p.fail { x += 2 }
37
+ p.always { x += 3 }
38
+
39
+ x.should == 6
40
+ end
41
+
42
+ it 'raises with always! if a promise has already been chained' do
43
+ p = Promise.new
44
+
45
+ p.then! {}
46
+
47
+ proc { p.always! {} }.should raise_error(ArgumentError)
29
48
  end
30
49
  end
@@ -33,12 +33,21 @@ describe 'Promise#rescue' do
33
33
  x.should == 23
34
34
  end
35
35
 
36
- it 'raises an exception when the promise has already been chained' do
37
- p = Promise.value(2)
38
- p.then {}
36
+ it 'can be called multiple times on the same promise' do
37
+ p = Promise.error(2)
38
+ x = 1
39
+ p.then { x += 1 }
40
+ p.rescue { x += 3 }
41
+ p.rescue { x += 3 }
42
+
43
+ x.should == 7
44
+ end
45
+
46
+ it 'raises with rescue! if a promise has already been chained' do
47
+ p = Promise.new
48
+
49
+ p.then! {}
39
50
 
40
- proc {
41
- p.rescue {}
42
- }.should raise_error(ArgumentError)
51
+ proc { p.rescue! {} }.should raise_error(ArgumentError)
43
52
  end
44
53
  end
@@ -52,13 +52,21 @@ describe 'Promise#then' do
52
52
  x.should be_kind_of(RuntimeError)
53
53
  end
54
54
 
55
- it 'raises an exception when the promise has already been chained' do
55
+ it 'allows then to be called multiple times' do
56
56
  p = Promise.value(2)
57
- p.then {}
57
+ x = 1
58
+ p.then { x += 1 }
59
+ p.then { x += 1 }
58
60
 
59
- proc {
60
- p.then {}
61
- }.should raise_error(ArgumentError)
61
+ x.should == 3
62
+ end
63
+
64
+ it 'raises with then! if a promise has already been chained' do
65
+ p = Promise.new
66
+
67
+ p.then! {}
68
+
69
+ proc { p.then! {} }.should raise_error(ArgumentError)
62
70
  end
63
71
 
64
72
  it 'should pass a delayed falsy value' do
@@ -41,12 +41,11 @@ describe 'Promise#trace' do
41
41
  x.should == 6
42
42
  end
43
43
 
44
- it 'raises an exception when the promise has already been chained' do
45
- p = Promise.value(2)
46
- p.then {}
44
+ it 'raises with trace! if a promise has already been chained' do
45
+ p = Promise.new
47
46
 
48
- proc {
49
- p.trace {}
50
- }.should raise_error(ArgumentError)
47
+ p.then! {}
48
+
49
+ proc { p.trace! {} }.should raise_error(ArgumentError)
51
50
  end
52
51
  end
@@ -8,4 +8,4 @@ describe "StringScanner#scan" do
8
8
  scanner.scan(/[\d_]+\.[\d_]+\b|[\d_]+(\.[\d_]+)?[eE][-+]?[\d_]+\b/).should be_nil
9
9
  end
10
10
  end
11
- end
11
+ end
data/spec/ruby_specs ADDED
@@ -0,0 +1,122 @@
1
+ ruby/core/array
2
+ ruby/core/basicobject
3
+ ruby/core/builtin_constants
4
+ ruby/core/class
5
+ ruby/core/comparable
6
+
7
+ ruby/core/complex
8
+ !ruby/core/complex/marshal_dump_spec
9
+
10
+ ruby/core/enumerable
11
+ ruby/core/enumerator
12
+
13
+ ruby/core/exception
14
+ !ruby/core/exception/load_error_spec
15
+
16
+ ruby/core/false
17
+ ruby/core/fixnum
18
+ ruby/core/file/extname_spec
19
+ ruby/core/float
20
+ ruby/core/hash
21
+
22
+ ruby/core/integer
23
+ !ruby/core/integer/times_spec
24
+
25
+ ruby/core/kernel
26
+ !ruby/core/kernel/abort_spec
27
+ !ruby/core/kernel/at_exit_spec
28
+ !ruby/core/kernel/autoload_spec
29
+ !ruby/core/kernel/backtick_spec
30
+ !ruby/core/kernel/binding_spec
31
+ !ruby/core/kernel/callcc_spec
32
+ !ruby/core/kernel/caller_locations_spec
33
+ !ruby/core/kernel/caller_spec
34
+ !ruby/core/kernel/catch_spec
35
+ !ruby/core/kernel/chomp_spec
36
+ !ruby/core/kernel/chop_spec
37
+ !ruby/core/kernel/exec_spec
38
+ !ruby/core/kernel/exit_spec
39
+ !ruby/core/kernel/fork_spec
40
+ !ruby/core/kernel/gets_spec
41
+ !ruby/core/kernel/load_spec
42
+ !ruby/core/kernel/open_spec
43
+ !ruby/core/kernel/putc_spec
44
+ !ruby/core/kernel/readlines_spec
45
+ !ruby/core/kernel/readline_spec
46
+ !ruby/core/kernel/require_relative_spec
47
+ !ruby/core/kernel/require_spec
48
+ !ruby/core/kernel/select_spec
49
+ !ruby/core/kernel/set_trace_func_spec
50
+ !ruby/core/kernel/spawn_spec
51
+ !ruby/core/kernel/syscall_spec
52
+ !ruby/core/kernel/system_spec
53
+ !ruby/core/kernel/tainted_spec
54
+ !ruby/core/kernel/taint_spec
55
+ !ruby/core/kernel/test_spec
56
+ !ruby/core/kernel/throw_spec
57
+ !ruby/core/kernel/trace_var_spec
58
+ !ruby/core/kernel/trap_spec
59
+ !ruby/core/kernel/trust_spec
60
+ !ruby/core/kernel/untaint_spec
61
+ !ruby/core/kernel/untrace_var_spec
62
+ !ruby/core/kernel/untrusted_spec
63
+ !ruby/core/kernel/untrust_spec
64
+
65
+ ruby/core/matchdata
66
+ ruby/core/math
67
+
68
+ ruby/core/method
69
+
70
+ ruby/core/module
71
+
72
+ ruby/core/nil
73
+ ruby/core/numeric
74
+
75
+ ruby/core/proc
76
+
77
+ ruby/core/range
78
+ ruby/core/rational
79
+ ruby/core/regexp
80
+
81
+ ruby/core/string
82
+ !ruby/core/string/crypt_spec
83
+ !ruby/core/string/scrub_spec
84
+
85
+ ruby/core/struct
86
+ ruby/core/symbol/to_proc_spec
87
+
88
+ ruby/core/time
89
+ !ruby/core/time/_dump_spec
90
+ !ruby/core/time/_load_spec
91
+
92
+ ruby/core/true
93
+ ruby/core/unboundmethod
94
+
95
+ ruby/language
96
+ !ruby/language/constants_spec
97
+ !ruby/language/def_spec
98
+ !ruby/language/execution_spec
99
+ !ruby/language/hash_spec
100
+ !ruby/language/next_spec
101
+ !ruby/language/return_spec
102
+ !ruby/language/send_spec
103
+ !ruby/language/yield_spec
104
+
105
+ ruby/library/base64
106
+ ruby/library/bigdecimal
107
+ ruby/library/date
108
+ ruby/library/delegate/delegator/send_spec
109
+ ruby/library/erb/util/h_spec
110
+ ruby/library/erb/util/html_escape_spec
111
+ ruby/library/observer
112
+
113
+ ruby/library/openstruct
114
+ !ruby/library/openstruct/frozen_spec
115
+ !ruby/library/openstruct/marshal_load_spec
116
+ !ruby/library/openstruct/marshal_dump_spec
117
+
118
+ ruby/library/pathname
119
+ ruby/library/pp
120
+ ruby/library/set
121
+ ruby/library/singleton
122
+ ruby/library/stringscanner