opal 1.5.1 → 1.6.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +4 -1
  3. data/HACKING.md +23 -0
  4. data/UNRELEASED.md +42 -0
  5. data/benchmark/run.rb +1 -0
  6. data/docs/compiled_ruby.md +8 -0
  7. data/docs/compiler.md +1 -1
  8. data/docs/compiler_directives.md +1 -1
  9. data/docs/getting_started.md +17 -0
  10. data/docs/headless_chrome.md +1 -1
  11. data/docs/index.md +123 -0
  12. data/docs/templates.md +37 -37
  13. data/docs/unsupported_features.md +0 -4
  14. data/lib/opal/builder.rb +59 -39
  15. data/lib/opal/builder_scheduler/prefork.rb +259 -0
  16. data/lib/opal/builder_scheduler/sequential.rb +13 -0
  17. data/lib/opal/builder_scheduler.rb +29 -0
  18. data/lib/opal/cache/file_cache.rb +5 -0
  19. data/lib/opal/cli.rb +22 -18
  20. data/lib/opal/cli_options.rb +4 -0
  21. data/lib/opal/cli_runners/chrome.rb +13 -9
  22. data/lib/opal/cli_runners/chrome_cdp_interface.rb +19 -2
  23. data/lib/opal/cli_runners/compiler.rb +1 -1
  24. data/lib/opal/cli_runners/gjs.rb +3 -1
  25. data/lib/opal/cli_runners/mini_racer.rb +5 -3
  26. data/lib/opal/cli_runners/nodejs.rb +3 -3
  27. data/lib/opal/cli_runners/server.rb +13 -28
  28. data/lib/opal/cli_runners/system_runner.rb +5 -3
  29. data/lib/opal/cli_runners.rb +7 -6
  30. data/lib/opal/compiler.rb +25 -2
  31. data/lib/opal/config.rb +10 -0
  32. data/lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb +2 -6
  33. data/lib/opal/nodes/args/extract_kwarg.rb +3 -4
  34. data/lib/opal/nodes/args/extract_kwargs.rb +3 -1
  35. data/lib/opal/nodes/args/extract_kwoptarg.rb +1 -1
  36. data/lib/opal/nodes/args/extract_kwrestarg.rb +4 -1
  37. data/lib/opal/nodes/args/extract_optarg.rb +1 -1
  38. data/lib/opal/nodes/args/extract_post_arg.rb +1 -1
  39. data/lib/opal/nodes/args/extract_post_optarg.rb +1 -1
  40. data/lib/opal/nodes/args/extract_restarg.rb +2 -2
  41. data/lib/opal/nodes/args/initialize_iterarg.rb +1 -1
  42. data/lib/opal/nodes/args/initialize_shadowarg.rb +1 -1
  43. data/lib/opal/nodes/args/prepare_post_args.rb +4 -2
  44. data/lib/opal/nodes/base.rb +14 -3
  45. data/lib/opal/nodes/call.rb +10 -14
  46. data/lib/opal/nodes/class.rb +3 -1
  47. data/lib/opal/nodes/closure.rb +250 -0
  48. data/lib/opal/nodes/def.rb +7 -11
  49. data/lib/opal/nodes/definitions.rb +4 -2
  50. data/lib/opal/nodes/if.rb +12 -2
  51. data/lib/opal/nodes/iter.rb +11 -17
  52. data/lib/opal/nodes/logic.rb +15 -63
  53. data/lib/opal/nodes/module.rb +3 -1
  54. data/lib/opal/nodes/rescue.rb +23 -15
  55. data/lib/opal/nodes/scope.rb +7 -1
  56. data/lib/opal/nodes/top.rb +27 -4
  57. data/lib/opal/nodes/while.rb +42 -26
  58. data/lib/opal/nodes.rb +1 -0
  59. data/lib/opal/os.rb +59 -0
  60. data/lib/opal/rewriter.rb +2 -0
  61. data/lib/opal/rewriters/returnable_logic.rb +14 -0
  62. data/lib/opal/rewriters/thrower_finder.rb +90 -0
  63. data/lib/opal/simple_server.rb +12 -6
  64. data/lib/opal/source_map/file.rb +1 -1
  65. data/lib/opal/source_map/map.rb +9 -1
  66. data/lib/opal/util.rb +1 -1
  67. data/lib/opal/version.rb +1 -1
  68. data/opal/corelib/array.rb +68 -3
  69. data/opal/corelib/basic_object.rb +1 -0
  70. data/opal/corelib/comparable.rb +1 -1
  71. data/opal/corelib/complex.rb +1 -0
  72. data/opal/corelib/constants.rb +2 -2
  73. data/opal/corelib/enumerable.rb +4 -2
  74. data/opal/corelib/enumerator/chain.rb +4 -0
  75. data/opal/corelib/enumerator/generator.rb +5 -3
  76. data/opal/corelib/enumerator/lazy.rb +3 -1
  77. data/opal/corelib/enumerator/yielder.rb +2 -4
  78. data/opal/corelib/enumerator.rb +3 -1
  79. data/opal/corelib/error/errno.rb +2 -1
  80. data/opal/corelib/error.rb +13 -2
  81. data/opal/corelib/hash.rb +39 -1
  82. data/opal/corelib/kernel.rb +56 -5
  83. data/opal/corelib/module.rb +60 -4
  84. data/opal/corelib/proc.rb +8 -5
  85. data/opal/corelib/rational.rb +1 -0
  86. data/opal/corelib/regexp.rb +15 -1
  87. data/opal/corelib/runtime.js +307 -238
  88. data/opal/corelib/string/encoding.rb +0 -6
  89. data/opal/corelib/string.rb +28 -7
  90. data/opal/corelib/time.rb +5 -2
  91. data/opal/corelib/unsupported.rb +2 -14
  92. data/spec/filters/bugs/delegate.rb +11 -0
  93. data/spec/filters/bugs/kernel.rb +1 -3
  94. data/spec/filters/bugs/language.rb +3 -23
  95. data/spec/filters/bugs/method.rb +0 -1
  96. data/spec/filters/bugs/module.rb +0 -3
  97. data/spec/filters/bugs/proc.rb +0 -3
  98. data/spec/filters/bugs/set.rb +4 -16
  99. data/spec/filters/bugs/unboundmethod.rb +0 -2
  100. data/spec/filters/unsupported/array.rb +0 -58
  101. data/spec/filters/unsupported/freeze.rb +8 -192
  102. data/spec/filters/unsupported/hash.rb +0 -25
  103. data/spec/filters/unsupported/kernel.rb +0 -1
  104. data/spec/filters/unsupported/privacy.rb +17 -0
  105. data/spec/lib/builder_spec.rb +14 -0
  106. data/spec/lib/cli_runners/server_spec.rb +2 -3
  107. data/spec/lib/cli_spec.rb +1 -1
  108. data/spec/lib/compiler_spec.rb +1 -1
  109. data/spec/opal/core/language/if_spec.rb +13 -0
  110. data/spec/opal/core/module_spec.rb +8 -0
  111. data/spec/ruby_specs +2 -1
  112. data/stdlib/await.rb +44 -7
  113. data/stdlib/delegate.rb +427 -6
  114. data/stdlib/headless_chrome.rb +6 -2
  115. data/stdlib/nodejs/file.rb +2 -1
  116. data/stdlib/opal-parser.rb +1 -1
  117. data/stdlib/opal-platform.rb +1 -1
  118. data/stdlib/opal-replutils.rb +5 -3
  119. data/stdlib/promise.rb +3 -0
  120. data/stdlib/rbconfig.rb +4 -1
  121. data/stdlib/ruby2_keywords.rb +60 -0
  122. data/stdlib/set.rb +21 -0
  123. data/tasks/performance.rake +41 -35
  124. data/tasks/releasing.rake +1 -0
  125. data/tasks/testing/mspec_special_calls.rb +1 -0
  126. data/tasks/testing.rake +5 -5
  127. data/test/nodejs/test_await.rb +39 -1
  128. metadata +27 -14
  129. data/docs/faq.md +0 -17
  130. data/lib/opal/rewriters/break_finder.rb +0 -36
  131. data/spec/opal/core/kernel/freeze_spec.rb +0 -15
@@ -1,177 +1,22 @@
1
1
  # NOTE: run bin/format-filters after changing this file
2
2
  opal_unsupported_filter "freezing" do
3
- fails "A method definition inside a metaclass scope raises FrozenError if frozen" # Expected FrozenError but no exception was raised ("foo" was returned)
4
- fails "A method definition inside a metaclass scope raises RuntimeError if frozen"
5
- fails "A singleton method definition raises FrozenError if frozen" # Expected FrozenError but no exception was raised ("foo" was returned)
6
- fails "A singleton method definition raises RuntimeError if frozen"
7
- fails "Array#<< raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3, 5] was returned)
8
- fails "Array#[]= raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([] was returned)
9
- fails "Array#append raises a FrozenError on a frozen array" # NoMethodError: undefined method `append' for [1, 2, 3]:Array
10
- fails "Array#clear raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([] was returned)
11
- fails "Array#collect! when frozen raises a FrozenError when calling #each on the returned Enumerator when empty" # Expected FrozenError but no exception was raised ([] was returned)
12
- fails "Array#collect! when frozen raises a FrozenError when calling #each on the returned Enumerator" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
13
- fails "Array#collect! when frozen raises a FrozenError when empty" # Expected FrozenError but no exception was raised ([] was returned)
14
- fails "Array#collect! when frozen raises a FrozenError" # Expected FrozenError but no exception was raised ([nil, nil, nil] was returned)
15
- fails "Array#compact! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised (nil was returned)
16
- fails "Array#concat raises a FrozenError when Array is frozen and modification occurs" # Expected FrozenError but no exception was raised ([1, 2, 3, 1] was returned)
17
- fails "Array#concat raises a FrozenError when Array is frozen and no modification occurs" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
18
- fails "Array#delete raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised (1 was returned)
19
- fails "Array#delete returns nil on a frozen array if a modification does not take place"
20
- fails "Array#delete_at raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised (1 was returned)
21
- fails "Array#delete_if raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
22
- fails "Array#delete_if raises a FrozenError on an empty frozen array" # Expected FrozenError but no exception was raised ([] was returned)
23
- fails "Array#dup does not copy frozen status from the original"
24
- fails "Array#fill raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised (["x", "x", "x"] was returned)
25
- fails "Array#fill raises a FrozenError on an empty frozen array" # Expected FrozenError but no exception was raised ([] was returned)
26
- fails "Array#filter! on frozen objects returns an Enumerator if no block is given" # NoMethodError: undefined method `filter!' for [true, false]
27
- fails "Array#filter! on frozen objects with falsy block keeps elements after any exception" # Expected Exception but no exception was raised ([] was returned)
28
- fails "Array#filter! on frozen objects with falsy block raises a FrozenError" # Expected FrozenError but got: NoMethodError (undefined method `filter!' for [true, false])
29
- fails "Array#filter! on frozen objects with truthy block keeps elements after any exception" # Expected Exception but no exception was raised (nil was returned)
30
- fails "Array#filter! on frozen objects with truthy block raises a FrozenError" # Expected FrozenError but got: NoMethodError (undefined method `filter!' for [true, false])
31
- fails "Array#flatten! raises a FrozenError on frozen arrays when the array is modified" # Expected FrozenError but no exception was raised ([1, 2] was returned)
32
- fails "Array#flatten! raises a FrozenError on frozen arrays when the array would not be modified" # Expected FrozenError but no exception was raised (nil was returned)
33
- fails "Array#initialize raises a FrozenError on frozen arrays" # Expected FrozenError but no exception was raised ([] was returned)
34
- fails "Array#insert raises a FrozenError on frozen arrays when the array is modified" # Expected FrozenError but no exception was raised (["x", 1, 2, 3] was returned)
35
- fails "Array#insert raises a FrozenError on frozen arrays when the array would not be modified" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
36
- fails "Array#keep_if on frozen objects with falsy block raises a FrozenError" # Expected FrozenError but no exception was raised ([] was returned)
37
- fails "Array#keep_if on frozen objects with truthy block raises a FrozenError" # Expected FrozenError but no exception was raised ([true, false] was returned)
38
- fails "Array#map! when frozen raises a FrozenError when calling #each on the returned Enumerator when empty" # Expected FrozenError but no exception was raised ([] was returned)
39
- fails "Array#map! when frozen raises a FrozenError when calling #each on the returned Enumerator" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
40
- fails "Array#map! when frozen raises a FrozenError when empty" # Expected FrozenError but no exception was raised ([] was returned)
41
- fails "Array#map! when frozen raises a FrozenError" # Expected FrozenError but no exception was raised ([nil, nil, nil] was returned)
42
- fails "Array#pop passed a number n as an argument raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([2, 3] was returned)
43
- fails "Array#pop raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised (3 was returned)
44
- fails "Array#pop raises a FrozenError on an empty frozen array" # Expected FrozenError but no exception was raised (nil was returned)
45
- fails "Array#prepend raises a FrozenError on a frozen array when the array is modified" # NoMethodError: undefined method `prepend' for [1, 2, 3]:Array
46
- fails "Array#prepend raises a FrozenError on a frozen array when the array would not be modified" # NoMethodError: undefined method `prepend' for [1, 2, 3]:Array
47
- fails "Array#push raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3, 1] was returned)
48
- fails "Array#reject! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised (nil was returned)
49
- fails "Array#reject! raises a FrozenError on an empty frozen array" # Expected FrozenError but no exception was raised (nil was returned)
50
- fails "Array#replace raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
51
- fails "Array#reverse! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([3, 2, 1] was returned)
52
- fails "Array#rotate does not mutate the receiver"
53
- fails "Array#rotate! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
54
- fails "Array#rotate! raises a RuntimeError on a frozen array"
55
- fails "Array#select! on frozen objects returns an Enumerator if no block is given"
56
- fails "Array#select! on frozen objects with falsy block raises a FrozenError" # Expected FrozenError but no exception was raised ([] was returned)
57
- fails "Array#select! on frozen objects with truthy block raises a FrozenError" # Expected FrozenError but no exception was raised (nil was returned)
58
- fails "Array#shift raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised (1 was returned)
59
- fails "Array#shift raises a FrozenError on an empty frozen array" # Expected FrozenError but no exception was raised (nil was returned)
60
- fails "Array#shuffle! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
61
- fails "Array#slice! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([] was returned)
62
- fails "Array#sort does not freezes self during being sorted"
63
- fails "Array#sort! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
64
- fails "Array#sort_by! raises a FrozenError on a frozen array" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
65
- fails "Array#sort_by! raises a FrozenError on an empty frozen array" # Expected FrozenError but no exception was raised ([] was returned)
66
- fails "Array#sort_by! raises a RuntimeError on a frozen array"
67
- fails "Array#sort_by! raises a RuntimeError on an empty frozen array"
68
- fails "Array#uniq! raises a FrozenError on a frozen array when the array is modified" # Expected FrozenError but no exception was raised ([1, 2] was returned)
69
- fails "Array#uniq! raises a FrozenError on a frozen array when the array would not be modified" # Expected FrozenError but no exception was raised (nil was returned)
70
- fails "Array#unshift raises a FrozenError on a frozen array when the array is modified" # Expected FrozenError but no exception was raised ([1, 1, 2, 3] was returned)
71
- fails "Array#unshift raises a FrozenError on a frozen array when the array would not be modified" # Expected FrozenError but no exception was raised ([1, 2, 3] was returned)
72
3
  fails "Date constants freezes MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYSNAMES"
73
- fails "Enumerable#sort doesn't raise an error if #to_a returns a frozen Array"
74
- fails "Enumerable#tally with a hash raises a FrozenError and does not update the given hash when the hash is frozen" # Expected FrozenError but got: ArgumentError ([Numerous#tally] wrong number of arguments(1 for 0))
75
- fails "Enumerator#initialize on frozen instance raises a RuntimeError"
76
- fails "Enumerator::Chain#initialize on frozen instance raises a RuntimeError" # Expected RuntimeError but no exception was raised (#<Enumerator::Chain: []> was returned)
77
- fails "Enumerator::Generator#initialize on frozen instance raises a RuntimeError" # Expected RuntimeError but no exception was raised (#<Proc:0x1b314> was returned)
78
- fails "Enumerator::Lazy#initialize on frozen instance raises a RuntimeError" # Expected RuntimeError but no exception was raised (nil was returned)
79
4
  fails "FalseClass#to_s returns a frozen string" # Expected "false".frozen? to be truthy but was false
80
5
  fails "File.basename returns a new unfrozen String" # Expected "foo.rb" not to be identical to "foo.rb"
81
6
  fails "FrozenError#receiver should return frozen object that modification was attempted on" # RuntimeError: RuntimeError
82
- fails "FrozenError.new should take optional receiver argument" # NoMethodError: undefined method `receiver' for #<FrozenError: msg>
83
7
  fails "Hash literal does not change encoding of literal string keys during creation"
84
8
  fails "Hash literal freezes string keys on initialization"
85
9
  fails "Hash#== compares keys with matching hash codes via eql?"
86
10
  fails "Hash#[]= doesn't duplicate and freeze already frozen string keys"
87
- fails "Hash#[]= raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised (2 was returned)
88
- fails "Hash#clear raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised ({} was returned)
89
- fails "Hash#compact! on frozen instance keeps pairs and raises a FrozenError" # Expected FrozenError but no exception was raised ({"truthy"=>true, "false"=>false, nil=>true} was returned)
90
- fails "Hash#compact! on frozen instance keeps pairs and raises a RuntimeError"
91
- fails "Hash#compare_by_identity raises a FrozenError on frozen hashes" # Expected FrozenError but no exception was raised ({} was returned)
92
- fails "Hash#default= raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised (nil was returned)
93
- fails "Hash#default_proc= raises a FrozenError if self is frozen" # Expected FrozenError but no exception was raised (main was returned)
94
- fails "Hash#delete raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised (nil was returned)
95
- fails "Hash#delete_if raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised ({1=>2, 3=>4} was returned)
96
- fails "Hash#delete_if returns an Enumerator if called on a frozen instance"
97
- fails "Hash#each returns an Enumerator if called on a frozen instance"
98
- fails "Hash#each_key returns an Enumerator if called on a frozen instance"
99
- fails "Hash#each_pair returns an Enumerator if called on a frozen instance"
100
- fails "Hash#each_value returns an Enumerator if called on a frozen instance"
101
11
  fails "Hash#eql? compares keys with matching hash codes via eql?"
102
- fails "Hash#filter returns an Enumerator if called on a frozen instance" # NoMethodError: undefined method `filter' for {1=>2, 3=>4, 5=>6}
103
- fails "Hash#filter! raises a FrozenError if called on a frozen instance that would not be modified" # Expected FrozenError but got: NoMethodError (undefined method `filter!' for {1=>2, 3=>4})
104
- fails "Hash#filter! raises a FrozenError if called on an empty frozen instance" # Expected FrozenError but got: NoMethodError (undefined method `filter!' for {})
105
- fails "Hash#filter! returns an Enumerator if called on a frozen instance" # NoMethodError: undefined method `filter!' for {1=>2, 3=>4, 5=>6}
106
- fails "Hash#initialize raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised ({1=>2, 3=>4} was returned)
107
- fails "Hash#keep_if raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised ({} was returned)
108
- fails "Hash#keep_if returns an Enumerator if called on a frozen instance"
109
- fails "Hash#merge! raises a FrozenError on a frozen instance that is modified" # Expected FrozenError but no exception was raised ({1=>2} was returned)
110
- fails "Hash#merge! raises a FrozenError on a frozen instance that would not be modified" # Expected FrozenError but no exception was raised ({1=>2} was returned)
111
- fails "Hash#rehash raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised ({} was returned)
112
- fails "Hash#reject returns an Enumerator if called on a frozen instance"
113
- fails "Hash#reject! raises a FrozenError if called on a frozen instance that is modified" # Expected FrozenError but no exception was raised (nil was returned)
114
- fails "Hash#reject! raises a FrozenError if called on a frozen instance that would not be modified" # Expected FrozenError but no exception was raised (nil was returned)
115
- fails "Hash#replace raises a FrozenError if called on a frozen instance that is modified" # Expected FrozenError but no exception was raised ({} was returned)
116
- fails "Hash#replace raises a FrozenError if called on a frozen instance that would not be modified" # Expected FrozenError but no exception was raised ({} was returned)
117
- fails "Hash#select returns an Enumerator if called on a frozen instance"
118
- fails "Hash#select! raises a FrozenError if called on a frozen instance that would not be modified" # Expected FrozenError but no exception was raised (nil was returned)
119
- fails "Hash#select! raises a FrozenError if called on an empty frozen instance" # Expected FrozenError but no exception was raised (nil was returned)
120
- fails "Hash#select! returns an Enumerator if called on a frozen instance"
121
- fails "Hash#shift raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised (nil was returned)
122
12
  fails "Hash#store doesn't duplicate and freeze already frozen string keys"
123
- fails "Hash#store raises a FrozenError if called on a frozen instance" # Expected FrozenError but no exception was raised (2 was returned)
124
- fails "Hash#transform_keys! on frozen instance keeps pairs and raises a FrozenError" # NoMethodError: undefined method `transform_keys!' for {"a"=>1, "b"=>2, "c"=>3, "d"=>4}
125
- fails "Hash#transform_keys! on frozen instance raises a FrozenError on an empty hash" # NoMethodError: undefined method `transform_keys!' for {}
126
- fails "Hash#transform_values! on frozen instance keeps pairs and raises a FrozenError" # Expected FrozenError but no exception was raised ({"a"=>2, "b"=>3, "c"=>4} was returned)
127
- fails "Hash#transform_values! on frozen instance keeps pairs and raises a RuntimeError"
128
- fails "Hash#transform_values! on frozen instance raises a FrozenError on an empty hash" # Expected FrozenError but no exception was raised ({} was returned)
129
- fails "Hash#transform_values! on frozen instance when no block is given does not raise an exception"
130
- fails "Hash#update raises a FrozenError on a frozen instance that is modified" # Expected FrozenError but no exception was raised ({1=>2} was returned)
131
- fails "Hash#update raises a FrozenError on a frozen instance that would not be modified" # Expected FrozenError but no exception was raised ({} was returned)
132
- fails "Kernel#clone copies frozen state from the original"
133
- fails "Kernel#clone copies frozen? and tainted?" # Expected false to be true
134
- fails "Kernel#clone takes an freeze: true option to frozen copy" # Expected #<KernelSpecs::Duplicate:0x25158>.frozen? to be truthy but was false
135
- fails "Kernel#clone takes an option to copy freeze state or not" # TODO: move to unsupported/freeze
136
- fails "Kernel#clone with freeze: anything else raises ArgumentError when passed not true/false/nil" # Expected ArgumentError (/unexpected value for freeze: Integer/) but no exception was raised (#<KernelSpecs::Duplicate:0x22130 @one=1 @two="a"> was returned)
137
- fails "Kernel#clone with freeze: false calls #initialize_clone with kwargs freeze: false even if #initialize_clone only takes a single argument" # Expected ArgumentError (wrong number of arguments (given 2, expected 1)) but no exception was raised (#<KernelSpecs::Clone:0x220b2> was returned)
138
- fails "Kernel#clone with freeze: false calls #initialize_clone with kwargs freeze: false" # Expected [#<KernelSpecs::CloneFreeze:0x220d0>, {}] == [#<KernelSpecs::CloneFreeze:0x220d0>, {"freeze"=>false}] to be truthy but was false
139
- fails "Kernel#clone with freeze: nil copies frozen state from the original, like #clone without arguments" # Expected #<KernelSpecs::Duplicate:0x21fd4 @one=1 @two="a">.frozen? to be truthy but was false
140
- fails "Kernel#clone with freeze: nil copies frozen?" # ArgumentError: [String#clone] wrong number of arguments(1 for 0)
141
- fails "Kernel#clone with freeze: true calls #initialize_clone with kwargs freeze: true even if #initialize_clone only takes a single argument" # Expected ArgumentError (wrong number of arguments (given 2, expected 1)) but no exception was raised (#<KernelSpecs::Clone:0x21ffa> was returned)
142
- fails "Kernel#clone with freeze: true calls #initialize_clone with kwargs freeze: true" # Expected [#<KernelSpecs::CloneFreeze:0x22050>, {}] == [#<KernelSpecs::CloneFreeze:0x22050>, {"freeze"=>true}] to be truthy but was false
143
- fails "Kernel#clone with freeze: true freezes the copy even if the original was not frozen" # Expected #<KernelSpecs::Duplicate:0x2200c @one=1 @two="a">.frozen? to be truthy but was false
144
- fails "Kernel#clone with freeze: true makes a frozen copy if the original is frozen" # Expected #<KernelSpecs::Duplicate:0x2202e @one=1 @two="a">.frozen? to be truthy but was false
145
- fails "Kernel#clone with no arguments copies frozen state from the original" # Expected #<KernelSpecs::Duplicate:0x21faa @one=1 @two="a">.frozen? to be truthy but was false
146
- fails "Kernel#clone with no arguments copies frozen?" # Expected false to be true
147
- fails "Kernel#extend on frozen instance raises a FrozenError" # Expected FrozenError but no exception was raised (main was returned)
148
- fails "Kernel#extend on frozen instance raises a RuntimeError"
149
- fails "Kernel#extend on frozen instance raises an ArgumentError when no arguments given"
150
- fails "Kernel#freeze causes instance_variable_set to raise RuntimeError"
151
- fails "Kernel#freeze causes mutative calls to raise RuntimeError"
152
- fails "Kernel#freeze on a Complex has no effect since it is already frozen" # Expected false to be true
153
- fails "Kernel#freeze on a Float has no effect since it is already frozen"
154
- fails "Kernel#freeze on a Rational has no effect since it is already frozen" # Expected false to be true
155
- fails "Kernel#freeze on a Symbol has no effect since it is already frozen"
156
- fails "Kernel#freeze on integers has no effect since they are already frozen"
157
- fails "Kernel#freeze on true, false and nil has no effect since they are already frozen"
158
- fails "Kernel#freeze prevents self from being further modified"
159
- fails "Kernel#freeze returns self"
160
- fails "Kernel#frozen? on a Complex literal returns true" # Expected false to be true
161
- fails "Kernel#frozen? on a Complex returns true" # Expected false to be true
162
- fails "Kernel#frozen? on a Float returns true"
163
- fails "Kernel#frozen? on a Rational literal returns true" # Expected false to be true
164
- fails "Kernel#frozen? on a Rational returns true" # Expected false to be true
165
- fails "Kernel#frozen? on a Symbol returns true"
166
- fails "Kernel#frozen? on integers returns true"
167
- fails "Kernel#frozen? on true, false and nil returns true"
168
- fails "Kernel#frozen? returns true if self is frozen"
169
- fails "Kernel#initialize_clone accepts a :freeze keyword argument for obj.clone(freeze: value)" # ArgumentError: [Object#initialize_clone] wrong number of arguments(2 for 1)
170
- fails "Kernel#instance_variable_set on frozen objects keeps stored object after any exceptions"
171
- fails "Kernel#instance_variable_set on frozen objects raises a FrozenError when passed replacement is different from stored object" # Expected FrozenError but no exception was raised ("replacement" was returned)
172
- fails "Kernel#instance_variable_set on frozen objects raises a FrozenError when passed replacement is identical to stored object" # Expected FrozenError but no exception was raised ("origin" was returned)
173
- fails "Kernel#instance_variable_set on frozen objects raises a RuntimeError when passed replacement is different from stored object"
174
- fails "Kernel#instance_variable_set on frozen objects raises a RuntimeError when passed replacement is identical to stored object"
13
+ fails "Kernel#clone with freeze: anything else raises ArgumentError when passed not true/false/nil" # Expected ArgumentError (/unexpected value for freeze: Integer/) but got: ArgumentError (unexpected value for freeze: Number)
14
+ fails "Kernel#clone with freeze: false calls #initialize_clone with kwargs freeze: false even if #initialize_clone only takes a single argument" # Expected ArgumentError (wrong number of arguments (given 2, expected 1)) but got: ArgumentError ([Clone#initialize_clone] wrong number of arguments (given 2, expected 1))
15
+ fails "Kernel#clone with freeze: nil copies frozen?" # Fails because of "".freeze.clone(freeze: nil)
16
+ fails "Kernel#clone with freeze: true calls #initialize_clone with kwargs freeze: true even if #initialize_clone only takes a single argument" # Expected ArgumentError (wrong number of arguments (given 2, expected 1)) but got: ArgumentError ([Clone#initialize_clone] wrong number of arguments (given 2, expected 1))
17
+ fails "Kernel#freeze causes mutative calls to raise RuntimeError" # Setting the value fails, but no Exception is raised
18
+ fails "Kernel#freeze on a Symbol has no effect since it is already frozen" # currently cant destinguish between Symbol and String as Symbol = String
19
+ fails "Kernel#frozen? on a Symbol returns true" # currently cant destinguish between Symbol and String as Symbol = String
175
20
  fails "Literal Ranges is frozen" # Expected 42...frozen? to be truthy but was false
176
21
  fails "Literal Regexps is frozen" # Expected /Hello/.frozen? to be truthy but was false
177
22
  fails "Marshal.load when called with freeze: true does not freeze classes" # ArgumentError: [Marshal.load] wrong number of arguments(2 for 1)
@@ -184,38 +29,11 @@ opal_unsupported_filter "freezing" do
184
29
  fails "Marshal.load when called with freeze: true when called with a proc call the proc with frozen objects" # ArgumentError: [Marshal.load] wrong number of arguments(3 for 1)
185
30
  fails "Marshal.load when called with freeze: true when called with a proc does not freeze the object returned by the proc" # ArgumentError: [Marshal.load] wrong number of arguments(3 for 1)
186
31
  fails "MatchData#string returns a frozen copy of the match string"
187
- fails "Module#alias_method raises FrozenError if frozen" # Expected FrozenError but no exception was raised (#<Class:0x39d44> was returned)
188
- fails "Module#alias_method raises RuntimeError if frozen"
189
- fails "Module#append_features when other is frozen raises a FrozenError before appending self" # Expected FrozenError but no exception was raised (#<Module:0x3fbfa> was returned)
190
- fails "Module#append_features when other is frozen raises a RuntimeError before appending self"
191
- fails "Module#autoload on a frozen module raises a FrozenError before setting the name" # Exception: Cannot read property '$pretty_inspect' of undefined
192
- fails "Module#autoload on a frozen module raises a RuntimeError before setting the name"
193
- fails "Module#class_variable_set raises a FrozenError when self is frozen" # Expected FrozenError but no exception was raised ("test" was returned)
194
- fails "Module#class_variable_set raises a RuntimeError when self is frozen"
195
- fails "Module#const_set on a frozen module raises a FrozenError before setting the name" # Expected FrozenError but no exception was raised (nil was returned)
196
- fails "Module#const_set on a frozen module raises a RuntimeError before setting the name"
197
- fails "Module#define_method raises a FrozenError if frozen" # Expected FrozenError but no exception was raised (#<Class:0x13e2> was returned)
198
- fails "Module#define_method raises a RuntimeError if frozen"
199
- fails "Module#extend_object when given a frozen object raises a RuntimeError before extending the object"
200
- fails "Module#name returns a frozen String" # Expected "ModuleSpecs".frozen? to be truthy but was false
201
- fails "Module#name returns a mutable string that when mutated does not modify the original module name" # NotImplementedError: String#<< not supported. Mutable String methods are not supported in Opal.
202
- fails "Module#remove_method on frozen instance does not raise exceptions when no arguments given"
203
- fails "Module#remove_method on frozen instance raises a FrozenError when passed a missing name" # NameError: method 'not_exist' not defined in
204
- fails "Module#remove_method on frozen instance raises a FrozenError when passed a name" # NameError: method 'method_to_remove' not defined in
205
- fails "Module#remove_method on frozen instance raises a RuntimeError when passed a missing name"
206
- fails "Module#remove_method on frozen instance raises a RuntimeError when passed a name"
207
- fails "Module#remove_method on frozen instance raises a TypeError when passed a not name"
208
- fails "Module#undef_method on frozen instance does not raise exceptions when no arguments given"
209
- fails "Module#undef_method on frozen instance raises a FrozenError when passed a missing name" # NameError: method 'not_exist' not defined in
210
- fails "Module#undef_method on frozen instance raises a FrozenError when passed a name" # NameError: method 'method_to_undef' not defined in
211
- fails "Module#undef_method on frozen instance raises a RuntimeError when passed a missing name"
212
- fails "Module#undef_method on frozen instance raises a RuntimeError when passed a name"
213
- fails "Module#undef_method on frozen instance raises a TypeError when passed a not name"
32
+ fails "Module#name returns a frozen String" # Expected "ModuleSpecs".frozen? to be truthy but was false due to Javascript automatic conversion of primitives into String 'object' when calling methods on the primitive
214
33
  fails "NilClass#to_s returns a frozen string" # Expected "".frozen? to be truthy but was false
215
34
  fails "OpenStruct#method_missing when called with a method name ending in '=' raises a TypeError when self is frozen"
216
35
  fails "Proc#[] with frozen_string_literals doesn't duplicate frozen strings" # Expected false to be true
217
36
  fails "Regexp#initialize raises a FrozenError on a Regexp literal" # Expected FrozenError but no exception was raised (nil was returned)
218
- fails "Set#compare_by_identity raises a FrozenError on frozen sets" # NoMethodError: undefined method `compare_by_identity' for #<Set: {}>
219
37
  fails "String#+@ returns an unfrozen copy of a frozen String"
220
38
  fails "String#+@ returns self if the String is not frozen"
221
39
  fails "String#-@ deduplicates frozen strings" # Expected "this string is frozen" not to be identical to "this string is frozen"
@@ -278,9 +96,7 @@ opal_unsupported_filter "freezing" do
278
96
  fails "String#tr_s! raises a FrozenError if self is frozen" # NotImplementedError: String#tr_s! not supported. Mutable String methods are not supported in Opal.
279
97
  fails "String#upcase! raises a FrozenError when self is frozen" # NotImplementedError: String#upcase! not supported. Mutable String methods are not supported in Opal.
280
98
  fails "StringScanner#initialize returns an instance of StringScanner"
281
- fails "Time#gmtime on a frozen time raises a RuntimeError if the time is not UTC"
282
99
  fails "Time#localtime on a frozen time does not raise an error if already in the right time zone"
283
100
  fails "Time#localtime on a frozen time raises a RuntimeError if the time has a different time zone"
284
- fails "Time#utc on a frozen time raises a RuntimeError if the time is not UTC"
285
101
  fails "TrueClass#to_s returns a frozen string" # Expected "true".frozen? to be truthy but was false
286
102
  end
@@ -2,35 +2,13 @@
2
2
  opal_unsupported_filter "Hash" do
3
3
  fails "Hash#[]= duplicates and freezes string keys"
4
4
  fails "Hash#[]= duplicates string keys using dup semantics" # TypeError: can't define singleton
5
- fails "Hash#[]= raises a RuntimeError if called on a frozen instance"
6
5
  fails "Hash#assoc only returns the first matching key-value pair for identity hashes"
7
- fails "Hash#clear raises a RuntimeError if called on a frozen instance"
8
- fails "Hash#compare_by_identity raises a RuntimeError on frozen hashes"
9
- fails "Hash#default= raises a RuntimeError if called on a frozen instance"
10
- fails "Hash#default_proc= raises a RuntimeError if self is frozen"
11
- fails "Hash#delete raises a RuntimeError if called on a frozen instance"
12
- fails "Hash#delete_if raises a RuntimeError if called on a frozen instance"
13
6
  fails "Hash#initialize is private"
14
- fails "Hash#initialize raises a RuntimeError if called on a frozen instance"
15
7
  fails "Hash#inspect does not raise if inspected result is not default external encoding" # Mock 'utf_16be' expected to receive 'inspect' exactly 1 times but received it 0 times
16
8
  fails "Hash#inspect returns a tainted string if self is tainted and not empty"
17
9
  fails "Hash#inspect returns an untrusted string if self is untrusted and not empty"
18
- fails "Hash#keep_if raises a RuntimeError if called on a frozen instance"
19
- fails "Hash#merge! checks frozen status before coercing an object with #to_hash"
20
- fails "Hash#merge! raises a RuntimeError on a frozen instance that is modified"
21
- fails "Hash#merge! raises a RuntimeError on a frozen instance that would not be modified"
22
- fails "Hash#rehash raises a RuntimeError if called on a frozen instance"
23
- fails "Hash#reject! raises a RuntimeError if called on a frozen instance that is modified"
24
- fails "Hash#reject! raises a RuntimeError if called on a frozen instance that would not be modified"
25
- fails "Hash#reject! returns an Enumerator if called on a frozen instance"
26
- fails "Hash#replace raises a RuntimeError if called on a frozen instance that is modified"
27
- fails "Hash#replace raises a RuntimeError if called on a frozen instance that would not be modified"
28
- fails "Hash#select! raises a RuntimeError if called on a frozen instance that would not be modified"
29
- fails "Hash#select! raises a RuntimeError if called on an empty frozen instance"
30
- fails "Hash#shift raises a RuntimeError if called on a frozen instance"
31
10
  fails "Hash#store duplicates and freezes string keys"
32
11
  fails "Hash#store duplicates string keys using dup semantics" # TypeError: can't define singleton
33
- fails "Hash#store raises a RuntimeError if called on a frozen instance"
34
12
  fails "Hash#to_a returns a tainted array if self is tainted"
35
13
  fails "Hash#to_a returns an untrusted array if self is untrusted"
36
14
  fails "Hash#to_proc the returned proc passed as a block to instance_exec always retrieves the original hash's values"
@@ -38,7 +16,4 @@ opal_unsupported_filter "Hash" do
38
16
  fails "Hash#to_s does not raise if inspected result is not default external encoding" # Mock 'utf_16be' expected to receive 'inspect' exactly 1 times but received it 0 times
39
17
  fails "Hash#to_s returns a tainted string if self is tainted and not empty"
40
18
  fails "Hash#to_s returns an untrusted string if self is untrusted and not empty"
41
- fails "Hash#update checks frozen status before coercing an object with #to_hash"
42
- fails "Hash#update raises a RuntimeError on a frozen instance that is modified"
43
- fails "Hash#update raises a RuntimeError on a frozen instance that would not be modified"
44
19
  end
@@ -12,7 +12,6 @@ opal_unsupported_filter "Kernel" do
12
12
  fails "Kernel#clone preserves tainted state from the original"
13
13
  fails "Kernel#clone preserves untrusted state from the original"
14
14
  fails "Kernel#clone raises a TypeError for Symbol"
15
- fails "Kernel#dup does not copy frozen state from the original"
16
15
  fails "Kernel#dup preserves tainted state from the original"
17
16
  fails "Kernel#dup preserves untrusted state from the original"
18
17
  fails "Kernel#dup raises a TypeError for Symbol"
@@ -14,6 +14,23 @@ opal_unsupported_filter "private" do
14
14
  fails "Defining an 'initialize_clone' method sets the method's visibility to private"
15
15
  fails "Defining an 'initialize_copy' method sets the method's visibility to private"
16
16
  fails "Defining an 'initialize_dup' method sets the method's visibility to private"
17
+ fails "DelegateClass.instance_method raises a NameError for a private instance methods of the delegated class" # Expected NameError but no exception was raised (#<UnboundMethod: DelegateSpecs::DelegateClass#priv (defined in #<Class:0x1663a> in ./delegate.rb:351)> was returned)
18
+ fails "DelegateClass.instance_methods does not include private methods" # Expected ["extra", "extra_private", "extra_protected", "__getobj__", "__setobj__", "pub", "priv", "prot", "to_json", "guard", "guard_not", "with_feature", "without_feature", "new_fd", "new_io", "should", "should_not", "version_is", "ruby_version_is", "suppress_warning", "suppress_keyword_warning", "should_receive", "should_not_receive", "stub!", "mock", "mock_int", "mock_numeric", "evaluate", "before", "after", "describe", "it", "it_should_behave_like", "context", "specify", "it_behaves_like", "ruby_bug", "conflicts_with", "big_endian", "little_endian", "platform_is", "platform_is_not", "quarantine!", "not_supported_on", "as_superuser", "as_user", "argf", "argv", "new_datetime", "with_timezone", "fixture", "flunk", "cp", "mkdir_p", "rm_r", "touch", "mock_to_path", "nan_value", "infinity_value", "bignum_value", "max_long", "min_long", "fixnum_max", "fixnum_min", "ruby_exe_options", "resolve_ruby_exe", "ruby_exe", "ruby_cmd", "opal_filter", "opal_unsupported_filter", "frozen_error_class", "pack_format", "DelegateClass", "expect", "eq", "pretty_print", "pretty_print_cycle", "pretty_print_instance_variables", "pretty_print_inspect", "<=>", "method", "Array", "at_exit", "caller", "caller_locations", "class", "copy_instance_variables", "copy_singleton_methods", "clone", "define_singleton_method", "dup", "enum_for", "exit", "extend", "gets", "hash", "initialize_copy", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "remove_instance_variable", "instance_variables", "Integer", "Float", "Hash", "is_a?", "itself", "lambda", "load", "loop", "nil?", "printf", "proc", "puts", "p", "print", "readline", "warn", "raise", "rand", "respond_to?", "require", "require_relative", "require_tree", "singleton_class", "sleep", "srand", "String", "tap", "to_proc", "catch", "throw", "open", "yield_self", "fail", "kind_of?", "object_id", "public_send", "send", "then", "to_enum", "format", "sprintf", "Complex", "Rational", "frozen?", "taint", "untaint", "tainted?", "private_methods", "private_instance_methods", "protected_instance_methods", "eval", "binding", "Pathname", "require_remote", "pretty_inspect", "pp", "opal_parse", "eval_js", "BigDecimal", "initialize", "method_missing", "respond_to_missing?", "target_respond_to?", "methods", "public_methods", "protected_methods", "==", "!=", "eql?", "!", "marshal_dump", "marshal_load", "initialize_clone", "initialize_dup", "freeze", "__raise__", "__send__", "__id__", "equal?", "instance_eval", "instance_exec", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "module_specs_public_method_on_object", "module_specs_private_method_on_object", "module_specs_protected_method_on_object", "module_specs_private_method_on_object_for_kernel_public", "module_specs_public_method_on_object_for_kernel_protected", "module_specs_public_method_on_object_for_kernel_private", "unpack_format", "be_close_to_matrix", "=~", "!~", "===", "inspect", "to_s", "module_specs_public_method_on_kernel", "module_specs_alias_on_kernel"] not to include "priv"
19
+ fails "DelegateClass.private_instance_methods includes private instance methods of the DelegateClass class" # Expected [] to include "extra_private"
20
+ fails "DelegateClass.protected_instance_methods includes protected instance methods of the DelegateClass class" # Expected [] to include "extra_protected"
21
+ fails "DelegateClass.protected_instance_methods includes the protected methods of the delegated class" # Expected [] to include "prot"
22
+ fails "DelegateClass.public_instance_methods does not include private methods" # Expected ["extra", "extra_private", "extra_protected", "__getobj__", "__setobj__", "pub", "priv", "prot", "to_json", "guard", "guard_not", "with_feature", "without_feature", "new_fd", "new_io", "should", "should_not", "version_is", "ruby_version_is", "suppress_warning", "suppress_keyword_warning", "should_receive", "should_not_receive", "stub!", "mock", "mock_int", "mock_numeric", "evaluate", "before", "after", "describe", "it", "it_should_behave_like", "context", "specify", "it_behaves_like", "ruby_bug", "conflicts_with", "big_endian", "little_endian", "platform_is", "platform_is_not", "quarantine!", "not_supported_on", "as_superuser", "as_user", "argf", "argv", "new_datetime", "with_timezone", "fixture", "flunk", "cp", "mkdir_p", "rm_r", "touch", "mock_to_path", "nan_value", "infinity_value", "bignum_value", "max_long", "min_long", "fixnum_max", "fixnum_min", "ruby_exe_options", "resolve_ruby_exe", "ruby_exe", "ruby_cmd", "opal_filter", "opal_unsupported_filter", "frozen_error_class", "pack_format", "DelegateClass", "expect", "eq", "pretty_print", "pretty_print_cycle", "pretty_print_instance_variables", "pretty_print_inspect", "<=>", "method", "Array", "at_exit", "caller", "caller_locations", "class", "copy_instance_variables", "copy_singleton_methods", "clone", "define_singleton_method", "dup", "enum_for", "exit", "extend", "gets", "hash", "initialize_copy", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "remove_instance_variable", "instance_variables", "Integer", "Float", "Hash", "is_a?", "itself", "lambda", "load", "loop", "nil?", "printf", "proc", "puts", "p", "print", "readline", "warn", "raise", "rand", "respond_to?", "require", "require_relative", "require_tree", "singleton_class", "sleep", "srand", "String", "tap", "to_proc", "catch", "throw", "open", "yield_self", "fail", "kind_of?", "object_id", "public_send", "send", "then", "to_enum", "format", "sprintf", "Complex", "Rational", "frozen?", "taint", "untaint", "tainted?", "private_methods", "private_instance_methods", "protected_instance_methods", "eval", "binding", "Pathname", "require_remote", "pretty_inspect", "pp", "opal_parse", "eval_js", "BigDecimal", "initialize", "method_missing", "respond_to_missing?", "target_respond_to?", "methods", "public_methods", "protected_methods", "==", "!=", "eql?", "!", "marshal_dump", "marshal_load", "initialize_clone", "initialize_dup", "freeze", "__raise__", "__send__", "__id__", "equal?", "instance_eval", "instance_exec", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "module_specs_public_method_on_object", "module_specs_private_method_on_object", "module_specs_protected_method_on_object", "module_specs_private_method_on_object_for_kernel_public", "module_specs_public_method_on_object_for_kernel_protected", "module_specs_public_method_on_object_for_kernel_private", "unpack_format", "be_close_to_matrix", "=~", "!~", "===", "inspect", "to_s", "module_specs_public_method_on_kernel", "module_specs_alias_on_kernel"] not to include "priv"
23
+ fails "DelegateClass.public_instance_methods does not include the protected methods of the delegated class" # Expected ["extra", "extra_private", "extra_protected", "__getobj__", "__setobj__", "pub", "priv", "prot", "to_json", "guard", "guard_not", "with_feature", "without_feature", "new_fd", "new_io", "should", "should_not", "version_is", "ruby_version_is", "suppress_warning", "suppress_keyword_warning", "should_receive", "should_not_receive", "stub!", "mock", "mock_int", "mock_numeric", "evaluate", "before", "after", "describe", "it", "it_should_behave_like", "context", "specify", "it_behaves_like", "ruby_bug", "conflicts_with", "big_endian", "little_endian", "platform_is", "platform_is_not", "quarantine!", "not_supported_on", "as_superuser", "as_user", "argf", "argv", "new_datetime", "with_timezone", "fixture", "flunk", "cp", "mkdir_p", "rm_r", "touch", "mock_to_path", "nan_value", "infinity_value", "bignum_value", "max_long", "min_long", "fixnum_max", "fixnum_min", "ruby_exe_options", "resolve_ruby_exe", "ruby_exe", "ruby_cmd", "opal_filter", "opal_unsupported_filter", "frozen_error_class", "pack_format", "DelegateClass", "expect", "eq", "pretty_print", "pretty_print_cycle", "pretty_print_instance_variables", "pretty_print_inspect", "<=>", "method", "Array", "at_exit", "caller", "caller_locations", "class", "copy_instance_variables", "copy_singleton_methods", "clone", "define_singleton_method", "dup", "enum_for", "exit", "extend", "gets", "hash", "initialize_copy", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "remove_instance_variable", "instance_variables", "Integer", "Float", "Hash", "is_a?", "itself", "lambda", "load", "loop", "nil?", "printf", "proc", "puts", "p", "print", "readline", "warn", "raise", "rand", "respond_to?", "require", "require_relative", "require_tree", "singleton_class", "sleep", "srand", "String", "tap", "to_proc", "catch", "throw", "open", "yield_self", "fail", "kind_of?", "object_id", "public_send", "send", "then", "to_enum", "format", "sprintf", "Complex", "Rational", "frozen?", "taint", "untaint", "tainted?", "private_methods", "private_instance_methods", "protected_instance_methods", "eval", "binding", "Pathname", "require_remote", "pretty_inspect", "pp", "opal_parse", "eval_js", "BigDecimal", "initialize", "method_missing", "respond_to_missing?", "target_respond_to?", "methods", "public_methods", "protected_methods", "==", "!=", "eql?", "!", "marshal_dump", "marshal_load", "initialize_clone", "initialize_dup", "freeze", "__raise__", "__send__", "__id__", "equal?", "instance_eval", "instance_exec", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "module_specs_public_method_on_object", "module_specs_private_method_on_object", "module_specs_protected_method_on_object", "module_specs_private_method_on_object_for_kernel_public", "module_specs_public_method_on_object_for_kernel_protected", "module_specs_public_method_on_object_for_kernel_private", "unpack_format", "be_close_to_matrix", "=~", "!~", "===", "inspect", "to_s", "module_specs_public_method_on_kernel", "module_specs_alias_on_kernel"] not to include "prot"
24
+ fails "Delegator#method raises a NameError for a private methods of the delegate object" # Expected warning to match: /delegator does not forward private method #priv/ but got: ""
25
+ fails "Delegator#method raises a NameError for protected methods of the delegate object" # Expected warning to match: /delegator does not forward private method #prot/ but got: ""
26
+ fails "Delegator#method returns a method object for private methods of the Delegator class" # NameError: undefined method `extra_private' for class `DelegateSpecs::Simple'
27
+ fails "Delegator#method returns a method object for protected methods of the Delegator class" # NameError: undefined method `extra_protected' for class `DelegateSpecs::Simple'
28
+ fails "Delegator#method returns a method object for public methods of the Delegator class" # NameError: undefined method `extra' for class `DelegateSpecs::Simple'
29
+ fails "Delegator#methods does not include private methods" # Expected ["singleton_method", "pub", "respond_to_missing?", "method_missing", "priv", "prot", "to_json", "guard", "guard_not", "with_feature", "without_feature", "new_fd", "new_io", "should", "should_not", "version_is", "ruby_version_is", "suppress_warning", "suppress_keyword_warning", "should_receive", "should_not_receive", "stub!", "mock", "mock_int", "mock_numeric", "evaluate", "before", "after", "describe", "it", "it_should_behave_like", "context", "specify", "it_behaves_like", "ruby_bug", "conflicts_with", "big_endian", "little_endian", "platform_is", "platform_is_not", "quarantine!", "not_supported_on", "as_superuser", "as_user", "argf", "argv", "new_datetime", "with_timezone", "fixture", "flunk", "cp", "mkdir_p", "rm_r", "touch", "mock_to_path", "nan_value", "infinity_value", "bignum_value", "max_long", "min_long", "fixnum_max", "fixnum_min", "ruby_exe_options", "resolve_ruby_exe", "ruby_exe", "ruby_cmd", "opal_filter", "opal_unsupported_filter", "frozen_error_class", "pack_format", "DelegateClass", "module_specs_public_method_on_object", "module_specs_private_method_on_object", "module_specs_protected_method_on_object", "module_specs_private_method_on_object_for_kernel_public", "module_specs_public_method_on_object_for_kernel_protected", "module_specs_public_method_on_object_for_kernel_private", "unpack_format", "be_close_to_matrix", "example_instance_method_of_object", "check_autoload", "main_public_method", "main_public_method2", "main_private_method", "main_private_method2", "lang_send_rest_len", "toplevel_define_other_method", "some_toplevel_method", "public_toplevel_method", "defined_specs_method", "defined_specs_receiver", "expect", "eq", "pretty_print", "pretty_print_cycle", "pretty_print_instance_variables", "pretty_print_inspect", "=~", "!~", "===", "<=>", "method", "methods", "public_methods", "Array", "at_exit", "caller", "caller_locations", "class", "copy_instance_variables", "copy_singleton_methods", "clone", "initialize_clone", "define_singleton_method", "dup", "initialize_dup", "enum_for", "equal?", "exit", "extend", "gets", "hash", "initialize_copy", "inspect", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "remove_instance_variable", "instance_variables", "Integer", "Float", "Hash", "is_a?", "itself", "lambda", "load", "loop", "nil?", "printf", "proc", "puts", "p", "print", "readline", "warn", "raise", "rand", "respond_to?", "require", "require_relative", "require_tree", "singleton_class", "sleep", "srand", "String", "tap", "to_proc", "to_s", "catch", "throw", "open", "yield_self", "fail", "kind_of?", "object_id", "public_send", "send", "then", "to_enum", "format", "sprintf", "Complex", "Rational", "freeze", "frozen?", "taint", "untaint", "tainted?", "private_methods", "protected_methods", "private_instance_methods", "protected_instance_methods", "eval", "binding", "Pathname", "require_remote", "pretty_inspect", "pp", "opal_parse", "eval_js", "BigDecimal", "module_specs_public_method_on_kernel", "module_specs_alias_on_kernel", "__send__", "__id__", "==", "!", "initialize", "eql?", "!=", "instance_eval", "instance_exec", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "__marshal__"] not to include "priv"
30
+ fails "Delegator#private_methods includes all private instance methods of the Delegate class" # Expected [] to include "extra_private"
31
+ fails "Delegator#protected_methods includes protected instance methods of the Delegator class" # Expected [] to include "extra_protected"
32
+ fails "Delegator#protected_methods includes protected methods of the delegate object" # Expected [] to include "prot"
33
+ fails "Delegator#public_methods includes public instance methods of the Delegator class" # Expected ["pub", "respond_to_missing?", "method_missing", "priv", "prot", "to_json", "guard", "guard_not", "with_feature", "without_feature", "new_fd", "new_io", "should", "should_not", "version_is", "ruby_version_is", "suppress_warning", "suppress_keyword_warning", "should_receive", "should_not_receive", "stub!", "mock", "mock_int", "mock_numeric", "evaluate", "before", "after", "describe", "it", "it_should_behave_like", "context", "specify", "it_behaves_like", "ruby_bug", "conflicts_with", "big_endian", "little_endian", "platform_is", "platform_is_not", "quarantine!", "not_supported_on", "as_superuser", "as_user", "argf", "argv", "new_datetime", "with_timezone", "fixture", "flunk", "cp", "mkdir_p", "rm_r", "touch", "mock_to_path", "nan_value", "infinity_value", "bignum_value", "max_long", "min_long", "fixnum_max", "fixnum_min", "ruby_exe_options", "resolve_ruby_exe", "ruby_exe", "ruby_cmd", "opal_filter", "opal_unsupported_filter", "frozen_error_class", "pack_format", "DelegateClass", "module_specs_public_method_on_object", "module_specs_private_method_on_object", "module_specs_protected_method_on_object", "module_specs_private_method_on_object_for_kernel_public", "module_specs_public_method_on_object_for_kernel_protected", "module_specs_public_method_on_object_for_kernel_private", "unpack_format", "be_close_to_matrix", "example_instance_method_of_object", "check_autoload", "main_public_method", "main_public_method2", "main_private_method", "main_private_method2", "lang_send_rest_len", "toplevel_define_other_method", "some_toplevel_method", "public_toplevel_method", "defined_specs_method", "defined_specs_receiver", "expect", "eq", "pretty_print", "pretty_print_cycle", "pretty_print_instance_variables", "pretty_print_inspect", "=~", "!~", "===", "<=>", "method", "methods", "public_methods", "Array", "at_exit", "caller", "caller_locations", "class", "copy_instance_variables", "copy_singleton_methods", "clone", "initialize_clone", "define_singleton_method", "dup", "initialize_dup", "enum_for", "equal?", "exit", "extend", "gets", "hash", "initialize_copy", "inspect", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "remove_instance_variable", "instance_variables", "Integer", "Float", "Hash", "is_a?", "itself", "lambda", "load", "loop", "nil?", "printf", "proc", "puts", "p", "print", "readline", "warn", "raise", "rand", "respond_to?", "require", "require_relative", "require_tree", "singleton_class", "sleep", "srand", "String", "tap", "to_proc", "to_s", "catch", "throw", "open", "yield_self", "fail", "kind_of?", "object_id", "public_send", "send", "then", "to_enum", "format", "sprintf", "Complex", "Rational", "freeze", "frozen?", "taint", "untaint", "tainted?", "private_methods", "protected_methods", "private_instance_methods", "protected_instance_methods", "eval", "binding", "Pathname", "require_remote", "pretty_inspect", "pp", "opal_parse", "eval_js", "BigDecimal", "module_specs_public_method_on_kernel", "module_specs_alias_on_kernel", "__send__", "__id__", "==", "!", "initialize", "eql?", "!=", "instance_eval", "instance_exec", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "__marshal__"] to include "extra"
17
34
  fails "Enumerator#initialize is a private method"
18
35
  fails "Enumerator::Chain#initialize is a private method" # Expected Enumerator::Chain to have private instance method 'initialize' but it does not
19
36
  fails "Enumerator::Generator#initialize is a private method" # Expected Enumerator::Generator to have private instance method 'initialize' but it does not
@@ -1,11 +1,19 @@
1
1
  require 'lib/spec_helper'
2
2
  require 'opal/builder'
3
+ require 'opal/builder_scheduler/sequential'
3
4
 
4
5
  RSpec.describe Opal::Builder do
5
6
  subject(:builder) { described_class.new(options) }
6
7
  let(:options) { {} }
7
8
  let(:ruby_processor) { Opal::BuilderProcessors::RubyProcessor }
8
9
 
10
+ def temporarily_with_sequential_scheduler(&block)
11
+ previous = Opal.builder_scheduler
12
+ Opal.builder_scheduler = Opal::BuilderScheduler::Sequential
13
+ yield
14
+ Opal.builder_scheduler = previous
15
+ end
16
+
9
17
  it 'compiles opal' do
10
18
  expect(builder.build('opal').to_s).to match('(Opal);')
11
19
  end
@@ -18,6 +26,8 @@ RSpec.describe Opal::Builder do
18
26
  describe ':stubs' do
19
27
  let(:options) { {stubs: ['foo']} }
20
28
 
29
+ around(:each) { |example| temporarily_with_sequential_scheduler(&example) }
30
+
21
31
  it 'compiles them as empty files' do
22
32
  source = 'require "foo"'
23
33
  expect(ruby_processor).to receive('new').with(source, anything, anything).once.and_call_original
@@ -39,6 +49,8 @@ RSpec.describe Opal::Builder do
39
49
  describe ':preload' do
40
50
  let(:options) { {preload: ['base64']} }
41
51
 
52
+ around(:each) { |example| temporarily_with_sequential_scheduler(&example) }
53
+
42
54
  it 'compiles them as empty files' do
43
55
  source = 'puts 5'
44
56
  expect(ruby_processor).to receive('new').with(anything, './base64.rb', anything).once.and_call_original
@@ -87,6 +99,8 @@ RSpec.describe Opal::Builder do
87
99
  end
88
100
 
89
101
  describe '#missing_require_severity' do
102
+ around(:each) { |example| temporarily_with_sequential_scheduler(&example) }
103
+
90
104
  it 'defaults to warning' do
91
105
  expect(builder.missing_require_severity).to eq(:error)
92
106
  end
@@ -15,11 +15,10 @@ RSpec.describe Opal::CliRunners::Server do
15
15
  expect(options[:Port]).to eq(1234)
16
16
  end
17
17
 
18
- builder = Opal::Builder.new
19
- builder.build_str("puts 123", "app.rb")
18
+ builder = -> { Opal::Builder.new.build_str("puts 123", "app.rb") }
20
19
  described_class.call(builder: builder, options: {port: 1234})
21
20
 
22
- get '/cli_runner.js'
21
+ get '/assets/cli_runner.js'
23
22
  expect(last_response.body).to include(".$puts(123)")
24
23
  end
25
24
  end
data/spec/lib/cli_spec.rb CHANGED
@@ -138,7 +138,7 @@ RSpec.describe Opal::CLI do
138
138
  let(:options) { {:gems => [gem_name], :evals => ['']} }
139
139
 
140
140
  it "adds the gem's lib paths to Opal.path" do
141
- builder = cli.builder
141
+ builder = cli.create_builder
142
142
 
143
143
  spec = Gem::Specification.find_by_name(gem_name)
144
144
  spec.require_paths.each do |require_path|
@@ -479,7 +479,7 @@ RSpec.describe Opal::Compiler do
479
479
 
480
480
  def expect_number_of_warnings(code)
481
481
  warnings_number = 0
482
- compiler = Opal::Compiler.new(code)
482
+ compiler = Opal::Compiler.new(code, eval: true)
483
483
  allow(compiler).to receive(:warning) { warnings_number += 1}
484
484
  compiler.compile
485
485
  expect(warnings_number)
@@ -0,0 +1,13 @@
1
+ describe "If statement" do
2
+ it "returns when wrapped" do
3
+ begin
4
+ 123
5
+
6
+ if true
7
+ foo while false
8
+
9
+ 5
10
+ end
11
+ end.should == 5
12
+ end
13
+ end
@@ -60,4 +60,12 @@ describe 'Module' do
60
60
  ->{ klass.new.cvarz0 }.should raise_error NameError
61
61
  ->{ klass.new.cvar0 }.should raise_error NameError
62
62
  end
63
+
64
+ it "can be set to a constant while being frozen" do
65
+ OPAL_SPEC_MODULE = Module.new.freeze
66
+ OPAL_SPEC_CLASS = Class.new.freeze
67
+
68
+ OPAL_SPEC_MODULE.class.should == Module
69
+ OPAL_SPEC_CLASS.class.should == Class
70
+ end
63
71
  end
data/spec/ruby_specs CHANGED
@@ -177,7 +177,8 @@ ruby/library/bigdecimal
177
177
  !ruby/library/bigdecimal/util_spec
178
178
  ruby/library/date
179
179
  ruby/library/datetime
180
- ruby/library/delegate/delegator/send_spec
180
+ ruby/library/delegate/delegate_class
181
+ ruby/library/delegate/delegator
181
182
  ruby/library/erb/util/h_spec
182
183
  ruby/library/erb/util/html_escape_spec
183
184
  ruby/library/logger/severity_spec
data/stdlib/await.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # helpers: coerce_to
2
- # await: true
2
+ # await: await
3
3
 
4
4
  if `Opal.config.experimental_features_severity == 'warning'`
5
5
  warn 'Await functionality is a technology preview, which means it may change its behavior ' \
@@ -19,21 +19,25 @@ class Array
19
19
  i = 0
20
20
  results = []
21
21
  while i < `self.length`
22
- results << yield(self[i]).__await__
22
+ results << yield(self[i]).await
23
23
  i += 1
24
24
  end
25
25
  results
26
26
  end
27
27
 
28
28
  def each_await(&block)
29
- map_await(&block).__await__
29
+ i = 0
30
+ while i < `self.length`
31
+ yield(self[i]).await
32
+ i += 1
33
+ end
30
34
  self
31
35
  end
32
36
  end
33
37
 
34
38
  module Enumerable
35
39
  def each_async(&block)
36
- PromiseV2.when(*map(&block)).__await__
40
+ PromiseV2.when(*map(&block)).await
37
41
  end
38
42
  end
39
43
 
@@ -44,7 +48,7 @@ module Kernel
44
48
 
45
49
  until $__at_exit__.empty?
46
50
  block = $__at_exit__.pop
47
- block.call.__await__
51
+ block.call.await
48
52
  end
49
53
 
50
54
  %x{
@@ -64,9 +68,7 @@ module Kernel
64
68
  `setTimeout(#{proc { prom.resolve }}, #{seconds * 1000})`
65
69
  prom
66
70
  end
67
- end
68
71
 
69
- module Kernel
70
72
  alias await itself
71
73
  end
72
74
 
@@ -81,3 +83,38 @@ class Method
81
83
  @method.async?
82
84
  end
83
85
  end
86
+
87
+ class BasicObject
88
+ def instance_exec_await(*args, &block)
89
+ ::Kernel.raise ::ArgumentError, 'no block given' unless block
90
+
91
+ # The awaits are defined inside an x-string. Opal can't find them
92
+ # reliably and async-ify a method. Therefore, let's make Opal know
93
+ # this is an async method.
94
+ nil.__await__
95
+
96
+ %x{
97
+ var block_self = block.$$s,
98
+ result;
99
+
100
+ block.$$s = null;
101
+
102
+ if (self.$$is_a_module) {
103
+ self.$$eval = true;
104
+ try {
105
+ result = await block.apply(self, args);
106
+ }
107
+ finally {
108
+ self.$$eval = false;
109
+ }
110
+ }
111
+ else {
112
+ result = await block.apply(self, args);
113
+ }
114
+
115
+ block.$$s = block_self;
116
+
117
+ return result;
118
+ }
119
+ end
120
+ end