opal 1.2.0 → 1.3.0.alpha1

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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.await.js +6 -0
  3. data/.eslintrc.js +34 -0
  4. data/.github/workflows/build.yml +8 -0
  5. data/.rubocop.yml +9 -0
  6. data/CHANGELOG.md +4 -0
  7. data/README.md +1 -1
  8. data/Rakefile +1 -0
  9. data/UNRELEASED.md +64 -38
  10. data/docs/async.md +109 -0
  11. data/docs/roda-sprockets.md +0 -2
  12. data/exe/opal +2 -0
  13. data/exe/opal-repl +2 -2
  14. data/lib/opal/builder.rb +5 -1
  15. data/lib/opal/builder_processors.rb +7 -2
  16. data/lib/opal/cache/file_cache.rb +119 -0
  17. data/lib/opal/cache.rb +71 -0
  18. data/lib/opal/cli.rb +35 -1
  19. data/lib/opal/cli_options.rb +21 -0
  20. data/lib/opal/cli_runners/chrome.rb +21 -14
  21. data/lib/opal/cli_runners/chrome_cdp_interface.js +30285 -0
  22. data/lib/opal/cli_runners/{chrome.js → chrome_cdp_interface.rb} +27 -6
  23. data/lib/opal/cli_runners/compiler.rb +2 -1
  24. data/lib/opal/cli_runners/gjs.rb +27 -0
  25. data/lib/opal/cli_runners/mini_racer.rb +36 -0
  26. data/lib/opal/cli_runners/source-map-support-browser.js +276 -91
  27. data/lib/opal/cli_runners/source-map-support-node.js +276 -91
  28. data/lib/opal/cli_runners/source-map-support.js +60 -18
  29. data/lib/opal/cli_runners.rb +2 -0
  30. data/lib/opal/compiler.rb +99 -10
  31. data/lib/opal/fragment.rb +77 -14
  32. data/lib/opal/nodes/args/extract_kwrestarg.rb +6 -4
  33. data/lib/opal/nodes/args/extract_restarg.rb +10 -12
  34. data/lib/opal/nodes/args.rb +28 -0
  35. data/lib/opal/nodes/base.rb +29 -5
  36. data/lib/opal/nodes/call.rb +123 -2
  37. data/lib/opal/nodes/case.rb +7 -1
  38. data/lib/opal/nodes/class.rb +12 -2
  39. data/lib/opal/nodes/def.rb +3 -23
  40. data/lib/opal/nodes/definitions.rb +21 -4
  41. data/lib/opal/nodes/helpers.rb +2 -2
  42. data/lib/opal/nodes/if.rb +39 -9
  43. data/lib/opal/nodes/iter.rb +15 -3
  44. data/lib/opal/nodes/lambda.rb +3 -1
  45. data/lib/opal/nodes/literal.rb +13 -7
  46. data/lib/opal/nodes/logic.rb +2 -2
  47. data/lib/opal/nodes/module.rb +12 -2
  48. data/lib/opal/nodes/rescue.rb +59 -34
  49. data/lib/opal/nodes/scope.rb +88 -6
  50. data/lib/opal/nodes/super.rb +52 -25
  51. data/lib/opal/nodes/top.rb +13 -7
  52. data/lib/opal/nodes/while.rb +7 -1
  53. data/lib/opal/parser/patch.rb +2 -1
  54. data/lib/opal/repl.rb +137 -49
  55. data/lib/opal/rewriters/binary_operator_assignment.rb +10 -10
  56. data/lib/opal/rewriters/block_to_iter.rb +3 -3
  57. data/lib/opal/rewriters/for_rewriter.rb +7 -7
  58. data/lib/opal/rewriters/js_reserved_words.rb +5 -3
  59. data/lib/opal/source_map/file.rb +7 -4
  60. data/lib/opal/source_map/map.rb +17 -3
  61. data/lib/opal/version.rb +1 -1
  62. data/opal/corelib/array.rb +2 -2
  63. data/opal/corelib/binding.rb +46 -0
  64. data/opal/corelib/boolean.rb +54 -4
  65. data/opal/corelib/class.rb +2 -0
  66. data/opal/corelib/constants.rb +2 -2
  67. data/opal/corelib/error.rb +98 -12
  68. data/opal/corelib/io.rb +250 -38
  69. data/opal/corelib/kernel/format.rb +5 -2
  70. data/opal/corelib/kernel.rb +44 -23
  71. data/opal/corelib/main.rb +5 -0
  72. data/opal/corelib/method.rb +1 -0
  73. data/opal/corelib/module.rb +28 -0
  74. data/opal/corelib/number.rb +12 -1
  75. data/opal/corelib/random/seedrandom.js.rb +2 -2
  76. data/opal/corelib/regexp.rb +47 -3
  77. data/opal/corelib/runtime.js +152 -12
  78. data/opal/corelib/string/encoding.rb +17 -17
  79. data/opal/corelib/string.rb +2 -0
  80. data/opal/corelib/struct.rb +10 -3
  81. data/opal/corelib/trace_point.rb +57 -0
  82. data/opal/opal/full.rb +2 -0
  83. data/package.json +3 -2
  84. data/spec/filters/bugs/array.rb +0 -1
  85. data/spec/filters/bugs/basicobject.rb +0 -1
  86. data/spec/filters/bugs/binding.rb +27 -0
  87. data/spec/filters/bugs/enumerator.rb +132 -0
  88. data/spec/filters/bugs/exception.rb +70 -93
  89. data/spec/filters/bugs/float.rb +0 -1
  90. data/spec/filters/bugs/kernel.rb +3 -9
  91. data/spec/filters/bugs/language.rb +15 -58
  92. data/spec/filters/bugs/main.rb +16 -0
  93. data/spec/filters/bugs/matrix.rb +39 -0
  94. data/spec/filters/bugs/method.rb +0 -2
  95. data/spec/filters/bugs/module.rb +36 -79
  96. data/spec/filters/bugs/proc.rb +0 -1
  97. data/spec/filters/bugs/regexp.rb +0 -16
  98. data/spec/filters/bugs/trace_point.rb +12 -0
  99. data/spec/filters/bugs/warnings.rb +0 -4
  100. data/spec/filters/unsupported/freeze.rb +2 -0
  101. data/spec/filters/unsupported/privacy.rb +4 -0
  102. data/spec/lib/compiler_spec.rb +7 -1
  103. data/spec/lib/repl_spec.rb +4 -2
  104. data/spec/lib/source_map/file_spec.rb +1 -1
  105. data/spec/mspec-opal/formatters.rb +18 -4
  106. data/spec/mspec-opal/runner.rb +2 -2
  107. data/spec/opal/core/boolean_spec.rb +44 -0
  108. data/spec/opal/core/hash_spec.rb +8 -0
  109. data/spec/opal/core/number/to_s_spec.rb +11 -0
  110. data/spec/opal/stdlib/json/ext_spec.rb +3 -3
  111. data/spec/opal/stdlib/logger/logger_spec.rb +10 -1
  112. data/spec/ruby_specs +18 -0
  113. data/stdlib/await.rb +83 -0
  114. data/stdlib/base64.rb +4 -4
  115. data/stdlib/bigdecimal/bignumber.js.rb +4 -2
  116. data/stdlib/bigdecimal.rb +1 -0
  117. data/stdlib/gjs/io.rb +33 -0
  118. data/stdlib/gjs/kernel.rb +5 -0
  119. data/stdlib/gjs.rb +2 -0
  120. data/stdlib/js.rb +4 -0
  121. data/stdlib/json.rb +3 -3
  122. data/stdlib/logger.rb +1 -1
  123. data/stdlib/nashorn/file.rb +2 -0
  124. data/stdlib/nodejs/env.rb +7 -0
  125. data/stdlib/nodejs/file.rb +6 -41
  126. data/stdlib/nodejs/io.rb +21 -5
  127. data/stdlib/nodejs/js-yaml-3-6-1.js +2 -2
  128. data/stdlib/opal/miniracer.rb +6 -0
  129. data/stdlib/opal/platform.rb +4 -0
  130. data/stdlib/opal/repl_js.rb +5 -0
  131. data/stdlib/opal/replutils.rb +271 -0
  132. data/stdlib/opal-parser.rb +24 -11
  133. data/stdlib/opal-platform.rb +8 -0
  134. data/stdlib/promise/v2.rb +16 -4
  135. data/stdlib/promise.rb +14 -0
  136. data/stdlib/stringio.rb +13 -110
  137. data/stdlib/thread.rb +29 -0
  138. data/tasks/building.rake +10 -4
  139. data/tasks/linting-parse-eslint-results.js +39 -0
  140. data/tasks/linting.rake +38 -28
  141. data/tasks/performance/asciidoctor_test.rb.erb +6 -0
  142. data/tasks/performance/optimization_status.rb +77 -0
  143. data/tasks/performance.rake +149 -0
  144. data/tasks/testing.rake +9 -1
  145. data/test/nodejs/test_await.rb +169 -0
  146. data/test/opal/promisev2/test_error.rb +9 -3
  147. data/test/opal/unsupported_and_bugs.rb +5 -0
  148. data/vendored-minitest/minitest/benchmark.rb +9 -7
  149. data/vendored-minitest/minitest/test.rb +14 -12
  150. data/vendored-minitest/minitest.rb +19 -16
  151. data/yarn.lock +686 -117
  152. metadata +60 -23
  153. data/.jshintrc +0 -41
  154. data/spec/filters/unsupported/refinements.rb +0 -8
  155. data/vendored-minitest/minitest/hell.rb +0 -11
  156. data/vendored-minitest/minitest/parallel.rb +0 -65
  157. data/vendored-minitest/minitest/pride.rb +0 -4
  158. data/vendored-minitest/minitest/pride_plugin.rb +0 -142
  159. data/vendored-minitest/minitest/unit.rb +0 -45
@@ -109,13 +109,13 @@ Encoding.register 'UTF-8', aliases: ['CP65001'], ascii: true do
109
109
  def each_byte(string, &block)
110
110
  %x{
111
111
  // Taken from: https://github.com/feross/buffer/blob/f52dffd9df0445b93c0c9065c2f8f0f46b2c729a/index.js#L1954-L2032
112
- var units = Infinity
113
- var codePoint
114
- var length = string.length
115
- var leadSurrogate = null
112
+ var units = Infinity;
113
+ var codePoint;
114
+ var length = string.length;
115
+ var leadSurrogate = null;
116
116
 
117
117
  for (var i = 0; i < length; ++i) {
118
- codePoint = string.charCodeAt(i)
118
+ codePoint = string.charCodeAt(i);
119
119
 
120
120
  // is surrogate component
121
121
  if (codePoint > 0xD7FF && codePoint < 0xE000) {
@@ -129,7 +129,7 @@ Encoding.register 'UTF-8', aliases: ['CP65001'], ascii: true do
129
129
  #{yield `0xBF`};
130
130
  #{yield `0xBD`};
131
131
  }
132
- continue
132
+ continue;
133
133
  } else if (i + 1 === length) {
134
134
  // unpaired lead
135
135
  if ((units -= 3) > -1) {
@@ -137,13 +137,13 @@ Encoding.register 'UTF-8', aliases: ['CP65001'], ascii: true do
137
137
  #{yield `0xBF`};
138
138
  #{yield `0xBD`};
139
139
  }
140
- continue
140
+ continue;
141
141
  }
142
142
 
143
143
  // valid lead
144
- leadSurrogate = codePoint
144
+ leadSurrogate = codePoint;
145
145
 
146
- continue
146
+ continue;
147
147
  }
148
148
 
149
149
  // 2 leads in a row
@@ -153,12 +153,12 @@ Encoding.register 'UTF-8', aliases: ['CP65001'], ascii: true do
153
153
  #{yield `0xBF`};
154
154
  #{yield `0xBD`};
155
155
  }
156
- leadSurrogate = codePoint
157
- continue
156
+ leadSurrogate = codePoint;
157
+ continue;
158
158
  }
159
159
 
160
160
  // valid surrogate pair
161
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
161
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
162
162
  } else if (leadSurrogate) {
163
163
  // valid bmp char, but last char was a lead
164
164
  if ((units -= 3) > -1) {
@@ -168,23 +168,23 @@ Encoding.register 'UTF-8', aliases: ['CP65001'], ascii: true do
168
168
  }
169
169
  }
170
170
 
171
- leadSurrogate = null
171
+ leadSurrogate = null;
172
172
 
173
173
  // encode utf8
174
174
  if (codePoint < 0x80) {
175
- if ((units -= 1) < 0) break
175
+ if ((units -= 1) < 0) break;
176
176
  #{yield `codePoint`};
177
177
  } else if (codePoint < 0x800) {
178
- if ((units -= 2) < 0) break
178
+ if ((units -= 2) < 0) break;
179
179
  #{yield `codePoint >> 0x6 | 0xC0`};
180
180
  #{yield `codePoint & 0x3F | 0x80`};
181
181
  } else if (codePoint < 0x10000) {
182
- if ((units -= 3) < 0) break
182
+ if ((units -= 3) < 0) break;
183
183
  #{yield `codePoint >> 0xC | 0xE0`};
184
184
  #{yield `codePoint >> 0x6 & 0x3F | 0x80`};
185
185
  #{yield `codePoint & 0x3F | 0x80`};
186
186
  } else if (codePoint < 0x110000) {
187
- if ((units -= 4) < 0) break
187
+ if ((units -= 4) < 0) break;
188
188
  #{yield `codePoint >> 0x12 | 0xF0`};
189
189
  #{yield `codePoint >> 0xC & 0x3F | 0x80`};
190
190
  #{yield `codePoint >> 0x6 & 0x3F | 0x80`};
@@ -628,6 +628,7 @@ class String < `String`
628
628
 
629
629
  def inspect
630
630
  %x{
631
+ /* eslint-disable no-misleading-character-class */
631
632
  var escapable = /[\\\"\x00-\x1f\u007F-\u009F\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
632
633
  meta = {
633
634
  '\u0007': '\\a',
@@ -651,6 +652,7 @@ class String < `String`
651
652
  }
652
653
  });
653
654
  return '"' + escaped.replace(/\#[\$\@\{]/g, '\\$&') + '"';
655
+ /* eslint-enable no-misleading-character-class */
654
656
  }
655
657
  end
656
658
 
@@ -5,11 +5,18 @@ class Struct
5
5
 
6
6
  def self.new(const_name, *args, keyword_init: false, &block)
7
7
  if const_name
8
- begin
9
- const_name = Opal.const_name!(const_name)
10
- rescue TypeError, NameError
8
+ if const_name.class == String && const_name[0].upcase != const_name[0]
9
+ # Fast track so that we skip needlessly going thru exceptions
10
+ # in most cases.
11
11
  args.unshift(const_name)
12
12
  const_name = nil
13
+ else
14
+ begin
15
+ const_name = Opal.const_name!(const_name)
16
+ rescue TypeError, NameError
17
+ args.unshift(const_name)
18
+ const_name = nil
19
+ end
13
20
  end
14
21
  end
15
22
 
@@ -0,0 +1,57 @@
1
+ class TracePoint
2
+ # partial implementation of TracePoint
3
+ # for the moment only supports the :class event
4
+ def self.trace(event, &block)
5
+ new(event, &block).enable
6
+ end
7
+
8
+ attr_reader :event
9
+
10
+ def initialize(event, &block)
11
+ raise 'Only the :class event is supported' unless event == :class
12
+ @event = event
13
+ @block = block
14
+ @trace_object = nil
15
+ @trace_evt = "trace_#{@event}"
16
+ @tracers_for_evt = "tracers_for_#{@event}"
17
+ end
18
+
19
+ def enable(*args, &enable_block)
20
+ previous_state = enabled?
21
+ %x{
22
+ Opal[#{@tracers_for_evt}].push(self);
23
+ Opal[#{@trace_evt}] = true;
24
+ }
25
+ if block_given?
26
+ yield
27
+ disable
28
+ end
29
+ previous_state
30
+ end
31
+
32
+ def enabled?
33
+ `Opal[#{@trace_evt}] && Opal[#{@tracers_for_evt}].includes(self)`
34
+ end
35
+
36
+ def disable
37
+ %x{
38
+ var idx = Opal[#{@tracers_for_evt}].indexOf(self)
39
+
40
+ if (idx > -1) {
41
+ Opal[#{@tracers_for_evt}].splice(idx, 1);
42
+
43
+ if (Opal[#{@tracers_for_evt}].length === 0) {
44
+ Opal[#{@trace_evt}] = false;
45
+ }
46
+
47
+ return true;
48
+ } else {
49
+ return false;
50
+ }
51
+ }
52
+ end
53
+
54
+ def self
55
+ @trace_object
56
+ end
57
+ end
data/opal/opal/full.rb CHANGED
@@ -3,3 +3,5 @@ require 'corelib/string/unpack'
3
3
  require 'corelib/array/pack'
4
4
  require 'corelib/object_space'
5
5
  require 'corelib/pattern_matching'
6
+ require 'corelib/trace_point'
7
+ require 'corelib/binding'
data/package.json CHANGED
@@ -4,11 +4,12 @@
4
4
  "dependencies": {
5
5
  "benchmark": "^2.1.4",
6
6
  "browserify": "^17.0.0",
7
- "jshint": "^2.11.0-rc1",
8
7
  "source-map-support": "0.5.19",
9
8
  "uglify-js": "^3.7.2"
10
9
  },
11
- "devDependencies": {},
10
+ "devDependencies": {
11
+ "eslint": "^7.32.0"
12
+ },
12
13
  "repository": {
13
14
  "type": "git",
14
15
  "url": "git+https://github.com/opal/opal.git"
@@ -31,7 +31,6 @@ opal_filter "Array" do
31
31
  fails "Array#flatten performs respond_to? and method_missing-aware checks when coercing elements to array"
32
32
  fails "Array#flatten with a non-Array object in the Array calls #method_missing if defined"
33
33
  fails "Array#inspect does not call #to_str on the object returned from #to_s when it is not a String" # Exception: Cannot convert object to primitive value
34
- fails "Array#join raises a NoMethodError if an element does not respond to #to_str, #to_ary, or #to_s"
35
34
  fails "Array#partition returns in the left array values for which the block evaluates to true"
36
35
  fails "Array#rassoc calls elem == obj on the second element of each contained array"
37
36
  fails "Array#rassoc does not check the last element in each contained but specifically the second" # Expected [1, "foobar", #<MockObject:0x4ef6e>] to equal [2, #<MockObject:0x4ef6e>, 1]
@@ -6,7 +6,6 @@ opal_filter "BasicObject" do
6
6
  fails "BasicObject#instance_eval evaluates string with given filename and linenumber"
7
7
  fails "BasicObject#instance_eval evaluates string with given filename and negative linenumber" # Expected ["RuntimeError"] to equal ["b_file", "-98"]
8
8
  fails "BasicObject#instance_eval has access to the caller's local variables" # Expected nil to equal "value"
9
- fails "BasicObject#instance_exec binds the block's binding self to the receiver"
10
9
  fails "BasicObject#instance_exec raises a LocalJumpError unless given a block"
11
10
  fails "BasicObject#method_missing for an instance sets the receiver of the raised NoMethodError"
12
11
  fails "BasicObject#singleton_method_added when singleton_method_added is undefined calls #method_missing" # Expected [] == [["singleton_method_added", "foo"], ["singleton_method_added", "bar"], ["singleton_method_added", "baz"]] to be truthy but was false
@@ -0,0 +1,27 @@
1
+ # NOTE: run bin/format-filters after changing this file
2
+ opal_filter "Binding" do
3
+ fails "Binding#clone is a shallow copy of the Binding object" # NoMethodError: undefined method `a' for #<BindingSpecs::Demo:0x1c7b0>
4
+ fails "Binding#clone returns a copy of the Binding object" # NoMethodError: undefined method `a' for #<BindingSpecs::Demo:0x1c958>
5
+ fails "Binding#dup is a shallow copy of the Binding object" # NoMethodError: undefined method `a' for #<BindingSpecs::Demo:0x67b30>
6
+ fails "Binding#dup returns a copy of the Binding object" # NoMethodError: undefined method `a' for #<BindingSpecs::Demo:0x67cd8>
7
+ fails "Binding#eval behaves like Kernel.eval(..., self)" # NoMethodError: undefined method `a' for #<BindingSpecs::Demo:0x8e1d4>
8
+ fails "Binding#eval does not leak variables to cloned bindings" # Expected [] == ["x"] to be truthy but was false
9
+ fails "Binding#eval reflects refinements activated in the binding scope" # NameError: uninitialized constant BindingSpecs::Refined
10
+ fails "Binding#eval starts with a __LINE__ from the third argument if passed" # Expected 1 == 88 to be truthy but was false
11
+ fails "Binding#eval starts with line 1 if the Binding is created with #send" # RuntimeError: Opal doesn't support dynamic calls to binding
12
+ fails "Binding#eval with __method__ returns the method where the Binding was created" # Expected nil == "get_binding_and_method" to be truthy but was false
13
+ fails "Binding#eval with __method__ returns the method where the Binding was created, ignoring #send" # Expected nil == "get_binding_with_send_and_method" to be truthy but was false
14
+ fails "Binding#irb creates an IRB session with the binding in scope" # NoMethodError: undefined method `popen' for IO
15
+ fails "Binding#local_variable_defined? allows usage of an object responding to #to_str as the variable name" # Expected false == true to be truthy but was false
16
+ fails "Binding#local_variable_defined? returns true when a local variable is defined using Binding#local_variable_set" # Expected false == true to be truthy but was false
17
+ fails "Binding#local_variable_defined? returns true when a local variable is defined using eval()" # Expected false == true to be truthy but was false
18
+ fails "Binding#local_variable_get gets a local variable defined using eval()" # Exception: number is not defined
19
+ fails "Binding#local_variable_set adds nonexistent variables to the binding's eval scope" # NoMethodError: undefined method `local_variables' for #<BindingSpecs::Demo:0x77602>
20
+ fails "Binding#local_variable_set raises a NameError on global access" # Expected NameError but no exception was raised ("" was returned)
21
+ fails "Binding#local_variable_set raises a NameError on special variable access" # Expected NameError but got: Exception (Unexpected token '~')
22
+ fails "Binding#local_variable_set sets a local variable using an object responding to #to_str as the variable name" # Exception: Invalid or unexpected token
23
+ fails "Binding#local_variables includes local variables defined after calling binding.local_variables" # Expected [] == ["a", "b"] to be truthy but was false
24
+ fails "Binding#local_variables includes local variables of inherited scopes and eval'ed context" # Expected ["c"] == ["c", "a", "b", "p"] to be truthy but was false
25
+ fails "Binding#local_variables includes new variables defined in the binding" # Expected ["b"] == ["a", "b"] to be truthy but was false
26
+ fails "Proc#curry produces Procs that raise ArgumentError for #binding" # Expected ArguentError but no exception was raised (#<Binding:0x1ade4> was returned)
27
+ end
@@ -45,4 +45,136 @@ opal_filter "Enumerator" do
45
45
  fails "Enumerator.produce terminates iteration when block raises StopIteration exception" # NoMethodError: undefined method `produce' for Enumerator
46
46
  fails "Enumerator.produce when initial value skipped starts enumerable from result of first block call" # NoMethodError: undefined method `produce' for Enumerator
47
47
  fails "Enumerator.produce when initial value skipped uses nil instead" # NoMethodError: undefined method `produce' for Enumerator
48
+ fails "Enumerator::Generator#each returns the block returned value" # Expected #<Enumerator::Generator:0x74c7e> to be identical to "block_returned"
49
+ fails "Enumerator::Generator#initialize returns self when given a block" # Expected #<Proc:0x1b2ee> to be identical to #<Enumerator::Generator:0x1b2e2>
50
+ fails "Enumerator::Lazy defines lazy versions of a whitelist of Enumerator methods" # Expected ["initialize", "force", "lazy", "collect", "collect_concat", "drop", "drop_while", "enum_for", "filter", "find_all", "flat_map", "grep", "map", "select", "reject", "take", "take_while", "to_enum", "inspect"] to include "chunk"
51
+ fails "Enumerator::Lazy#chunk calls the block with gathered values when yield with multiple arguments" # NoMethodError: undefined method `force' for #<Enumerator: #<Enumerator::Generator:0x5dcd4>:each>
52
+ fails "Enumerator::Lazy#chunk on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected 0 == 2 to be truthy but was false
53
+ fails "Enumerator::Lazy#chunk returns a new instance of Enumerator::Lazy" # Expected #<Enumerator: #<Enumerator::Generator:0x5dcbc>:each> (Enumerator) to be an instance of Enumerator::Lazy
54
+ fails "Enumerator::Lazy#chunk returns an Enumerator if called without a block" # NoMethodError: undefined method `force' for #<Enumerator: #<Enumerator::Generator:0x5dc8a>:each>
55
+ fails "Enumerator::Lazy#chunk when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Exception: Object.defineProperty called on non-object
56
+ fails "Enumerator::Lazy#chunk works with an infinite enumerable" # TypeError: can't iterate from Float
57
+ fails "Enumerator::Lazy#chunk_while should return a lazy enumerator" # Expected #<Enumerator: #<Enumerator::Generator:0x5174c>:each> (Enumerator) to be kind of Enumerator::Lazy
58
+ fails "Enumerator::Lazy#chunk_while works with an infinite enumerable" # TypeError: can't iterate from Float
59
+ fails "Enumerator::Lazy#collect on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [2, 3, 4] to be truthy but was false
60
+ fails "Enumerator::Lazy#collect when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [1, 2, 3] to be truthy but was false
61
+ fails "Enumerator::Lazy#collect works with an infinite enumerable" # TypeError: can't iterate from Float
62
+ fails "Enumerator::Lazy#collect_concat on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first flattens elements when the given block returned an array or responding to .each and .force" # Expected [] == ["0", "1", "0", "2", "0", "3"] to be truthy but was false
63
+ fails "Enumerator::Lazy#collect_concat on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == ["0", "10", "20", "30", "40", "50"] to be truthy but was false
64
+ fails "Enumerator::Lazy#collect_concat when the returned lazy enumerator is evaluated by Enumerable#first flattens elements when the given block returned an array or responding to .each and .force" # Expected [] == ["0", "1", "0", "2", "0", "3"] to be truthy but was false
65
+ fails "Enumerator::Lazy#collect_concat when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == ["0", "10", "20", "30", "40", "50"] to be truthy but was false
66
+ fails "Enumerator::Lazy#collect_concat works with an infinite enumerable" # TypeError: can't iterate from Float
67
+ fails "Enumerator::Lazy#drop on a nested Lazy sets difference of given count with old size to new size" # Expected 20 == 30 to be truthy but was false
68
+ fails "Enumerator::Lazy#drop on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [4, 5] to be truthy but was false
69
+ fails "Enumerator::Lazy#drop sets difference of given count with old size to new size" # Expected 20 == 80 to be truthy but was false
70
+ fails "Enumerator::Lazy#drop when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [2, 3] to be truthy but was false
71
+ fails "Enumerator::Lazy#drop works with an infinite enumerable" # TypeError: can't iterate from Float
72
+ fails "Enumerator::Lazy#drop_while on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [6, 7] to be truthy but was false
73
+ fails "Enumerator::Lazy#drop_while when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [5, 6] to be truthy but was false
74
+ fails "Enumerator::Lazy#drop_while works with an infinite enumerable" # TypeError: can't iterate from Float
75
+ fails "Enumerator::Lazy#eager does not enumerate an enumerator" # NoMethodError: undefined method `eager' for #<Enumerator::Lazy: [1, 2, 3]>
76
+ fails "Enumerator::Lazy#eager returns a non-lazy Enumerator converted from the lazy enumerator" # NoMethodError: undefined method `eager' for #<Enumerator::Lazy: [1, 2, 3]>
77
+ fails "Enumerator::Lazy#enum_for generates a lazy enumerator from the given name" # Expected [] == [[0, 10], [1, 11], [2, 12]] to be truthy but was false
78
+ fails "Enumerator::Lazy#enum_for passes given arguments to wrapped method" # Expected [] == [0, 6, 20, 42] to be truthy but was false
79
+ fails "Enumerator::Lazy#enum_for works with an infinite enumerable" # TypeError: can't iterate from Float
80
+ fails "Enumerator::Lazy#filter calls the block with a gathered array when yield with multiple arguments" # NoMethodError: undefined method `force' for [[], 0, [0, 1], [0, 1, 2], [0, 1, 2], nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]]
81
+ fails "Enumerator::Lazy#filter on a nested Lazy sets #size to nil" # Expected 0 == nil to be truthy but was false
82
+ fails "Enumerator::Lazy#filter on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [6, 8, 10] to be truthy but was false
83
+ fails "Enumerator::Lazy#filter raises an ArgumentError when not given a block" # Expected ArgumentError but no exception was raised (#<Enumerator::Lazy: nil> was returned)
84
+ fails "Enumerator::Lazy#filter returns a new instance of Enumerator::Lazy" # Expected [] (Array) to be an instance of Enumerator::Lazy
85
+ fails "Enumerator::Lazy#filter sets #size to nil" # Expected 0 == nil to be truthy but was false
86
+ fails "Enumerator::Lazy#filter when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [0, 2, 4] to be truthy but was false
87
+ fails "Enumerator::Lazy#filter works with an infinite enumerable" # TypeError: can't iterate from Float
88
+ fails "Enumerator::Lazy#filter_map does not map false results" # Expected [] == [1, 3, 5, 7] to be truthy but was false
89
+ fails "Enumerator::Lazy#filter_map maps only truthy results" # Expected [] == [1, 3, 5, 7] to be truthy but was false
90
+ fails "Enumerator::Lazy#find_all calls the block with a gathered array when yield with multiple arguments" # Expected [nil, 0, 0, 0, 0, nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]] == [nil, 0, [0, 1], [0, 1, 2], [0, 1, 2], nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]] to be truthy but was false
91
+ fails "Enumerator::Lazy#find_all on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [6, 8, 10] to be truthy but was false
92
+ fails "Enumerator::Lazy#find_all when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [0, 2, 4] to be truthy but was false
93
+ fails "Enumerator::Lazy#find_all works with an infinite enumerable" # TypeError: can't iterate from Float
94
+ fails "Enumerator::Lazy#flat_map on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first flattens elements when the given block returned an array or responding to .each and .force" # Expected [] == ["0", "1", "0", "2", "0", "3"] to be truthy but was false
95
+ fails "Enumerator::Lazy#flat_map on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == ["0", "10", "20", "30", "40", "50"] to be truthy but was false
96
+ fails "Enumerator::Lazy#flat_map when the returned lazy enumerator is evaluated by Enumerable#first flattens elements when the given block returned an array or responding to .each and .force" # Expected [] == ["0", "1", "0", "2", "0", "3"] to be truthy but was false
97
+ fails "Enumerator::Lazy#flat_map when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == ["0", "10", "20", "30", "40", "50"] to be truthy but was false
98
+ fails "Enumerator::Lazy#flat_map works with an infinite enumerable" # TypeError: can't iterate from Float
99
+ fails "Enumerator::Lazy#force on a nested Lazy calls all block and returns an Array" # Expected [] == [1, 2] to be truthy but was false
100
+ fails "Enumerator::Lazy#force passes given arguments to receiver.each" # Expected [[], 0, [0, 1], [0, 1, 2], [0, 1, 2], nil, "arg1", ["arg2", "arg3"], [], [0], [0, 1], [0, 1, 2]] == [nil, 0, [0, 1], [0, 1, 2], [0, 1, 2], nil, "arg1", ["arg2", "arg3"], [], [0], [0, 1], [0, 1, 2]] to be truthy but was false
101
+ fails "Enumerator::Lazy#force works with an infinite enumerable" # TypeError: can't iterate from Float
102
+ fails "Enumerator::Lazy#grep calls the block with a gathered array when yield with multiple arguments" # Expected [[], [], 0, 0, [0, 1], [...], [0, 1, 2], [...], [0, 1, 2], [...], nil, nil, "default_arg", "default_arg", [], [], [], [], [0], [...], [0, 1], [...], [0, 1, 2], [...]] == [nil, 0, [0, 1], [0, 1, 2], [0, 1, 2], nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]] to be truthy but was false
103
+ fails "Enumerator::Lazy#grep on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when given a block" # Exception: Object.defineProperty called on non-object
104
+ fails "Enumerator::Lazy#grep on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when not given a block" # Expected [] == [0, 1, 2] to be truthy but was false
105
+ fails "Enumerator::Lazy#grep when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when given a block" # Expected [] == [1, 2, 3] to be truthy but was false
106
+ fails "Enumerator::Lazy#grep when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when not given a block" # Expected [] == [0, 1, 2] to be truthy but was false
107
+ fails "Enumerator::Lazy#grep works with an infinite enumerable" # TypeError: can't iterate from Float
108
+ fails "Enumerator::Lazy#grep_v calls the block with a gathered array when yield with multiple arguments" # NoMethodError: undefined method `force' for [[nil, 0, nil, "default_arg"], [nil, 0, nil, "default_arg"], [nil, 0, nil, "default_arg"], [nil, 0, nil, "default_arg"]]
109
+ fails "Enumerator::Lazy#grep_v on a nested Lazy sets #size to nil" # Expected 0 == nil to be truthy but was false
110
+ fails "Enumerator::Lazy#grep_v on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when given a block" # Exception: Object.defineProperty called on non-object
111
+ fails "Enumerator::Lazy#grep_v on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when not given a block" # Expected [] == [0, 1, 2] to be truthy but was false
112
+ fails "Enumerator::Lazy#grep_v returns a new instance of Enumerator::Lazy" # Expected [] (Array) to be an instance of Enumerator::Lazy
113
+ fails "Enumerator::Lazy#grep_v sets #size to nil" # Expected 0 == nil to be truthy but was false
114
+ fails "Enumerator::Lazy#grep_v sets $~ in the block" # NoMethodError: undefined method `force' for [nil]
115
+ fails "Enumerator::Lazy#grep_v sets $~ in the next block with each" # Expected #<MatchData>(#pretty_inspect raised #<NoMethodError: undefined method `named_captures' for /e/>) == nil to be truthy but was false
116
+ fails "Enumerator::Lazy#grep_v sets $~ in the next block with map" # Expected #<MatchData>(#pretty_inspect raised #<NoMethodError: undefined method `named_captures' for /e/>) == nil to be truthy but was false
117
+ fails "Enumerator::Lazy#grep_v when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when given a block" # Expected [] == [1, 2, 3] to be truthy but was false
118
+ fails "Enumerator::Lazy#grep_v when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times when not given a block" # Expected [] == [0, 1, 2] to be truthy but was false
119
+ fails "Enumerator::Lazy#grep_v works with an infinite enumerable" # TypeError: can't iterate from Float
120
+ fails "Enumerator::Lazy#initialize returns self" # Expected nil to be identical to #<Enumerator::Lazy: #<Object:0x4d524>>
121
+ fails "Enumerator::Lazy#initialize sets #size to nil if given size is nil" # NoMethodError: undefined method `size' for nil
122
+ fails "Enumerator::Lazy#initialize sets #size to nil if not given a size" # NoMethodError: undefined method `size' for nil
123
+ fails "Enumerator::Lazy#initialize sets given size to own size if the given size is Float::INFINITY" # Expected 4 to be identical to Infinity
124
+ fails "Enumerator::Lazy#initialize sets given size to own size if the given size is a Proc" # NoMethodError: undefined method `size' for nil
125
+ fails "Enumerator::Lazy#initialize sets given size to own size if the given size is an Integer" # Expected 4 == 100 to be truthy but was false
126
+ fails "Enumerator::Lazy#initialize when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # NoMethodError: undefined method `first' for nil
127
+ fails "Enumerator::Lazy#map on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [2, 3, 4] to be truthy but was false
128
+ fails "Enumerator::Lazy#map when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [1, 2, 3] to be truthy but was false
129
+ fails "Enumerator::Lazy#map works with an infinite enumerable" # TypeError: can't iterate from Float
130
+ fails "Enumerator::Lazy#reject calls the block with a gathered array when yield with multiple arguments" # Expected [nil, 0, 0, 0, 0, nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]] == [nil, 0, [0, 1], [0, 1, 2], [0, 1, 2], nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]] to be truthy but was false
131
+ fails "Enumerator::Lazy#reject lets exceptions raised in the block go through" # Expected RuntimeError (foo) but no exception was raised (#<Enumerator::Generator:0x44bec> was returned)
132
+ fails "Enumerator::Lazy#reject on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [5, 7, 9] to be truthy but was false
133
+ fails "Enumerator::Lazy#reject when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [1, 3, 5] to be truthy but was false
134
+ fails "Enumerator::Lazy#reject works with an infinite enumerable" # TypeError: can't iterate from Float
135
+ fails "Enumerator::Lazy#select calls the block with a gathered array when yield with multiple arguments" # Expected [nil, 0, 0, 0, 0, nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]] == [nil, 0, [0, 1], [0, 1, 2], [0, 1, 2], nil, "default_arg", [], [], [0], [0, 1], [0, 1, 2]] to be truthy but was false
136
+ fails "Enumerator::Lazy#select doesn't over-evaluate when peeked" # NoMethodError: undefined method `peek' for #<Enumerator::Lazy: #<Enumerator::Lazy: ["Text1", "Text2", "Text3"]>>
137
+ fails "Enumerator::Lazy#select doesn't pre-evaluate the next element" # NoMethodError: undefined method `next' for #<Enumerator::Lazy: #<Enumerator::Lazy: ["Text1", "Text2", "Text3"]>>
138
+ fails "Enumerator::Lazy#select doesn't re-evaluate after peek" # NoMethodError: undefined method `peek' for #<Enumerator::Lazy: #<Enumerator::Lazy: ["Text1", "Text2", "Text3"]>>
139
+ fails "Enumerator::Lazy#select on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [6, 8, 10] to be truthy but was false
140
+ fails "Enumerator::Lazy#select when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [0, 2, 4] to be truthy but was false
141
+ fails "Enumerator::Lazy#select works with an infinite enumerable" # TypeError: can't iterate from Float
142
+ fails "Enumerator::Lazy#slice_after should return a lazy enumerator" # Expected #<Enumerator: #<Enumerator::Generator:0x53eae>:each> (Enumerator) to be kind of Enumerator::Lazy
143
+ fails "Enumerator::Lazy#slice_after works with an infinite enumerable" # TypeError: can't iterate from Float
144
+ fails "Enumerator::Lazy#slice_before should return a lazy enumerator" # Expected #<Enumerator: #<Enumerator::Generator:0x72c3a>:each> (Enumerator) to be kind of Enumerator::Lazy
145
+ fails "Enumerator::Lazy#slice_before works with an infinite enumerable" # TypeError: can't iterate from Float
146
+ fails "Enumerator::Lazy#slice_when should return a lazy enumerator" # Expected #<Enumerator: #<Enumerator::Generator:0x50bb6>:each> (Enumerator) to be kind of Enumerator::Lazy
147
+ fails "Enumerator::Lazy#slice_when works with an infinite enumerable" # TypeError: can't iterate from Float
148
+ fails "Enumerator::Lazy#take on a nested Lazy when the returned lazy enumerator is evaluated by .force stops after specified times" # Expected [] == [1, 2] to be truthy but was false
149
+ fails "Enumerator::Lazy#take on a nested Lazy when the returned lazy enumerator is evaluated by .force stops without iterations if the given argument is 0" # Expected ["before_yield"] == [] to be truthy but was false
150
+ fails "Enumerator::Lazy#take sets given count to size if the old size is Infinity" # Expected Infinity == 20 to be truthy but was false
151
+ fails "Enumerator::Lazy#take when the returned lazy enumerator is evaluated by .force stops after specified times" # Expected [] == [0, 1] to be truthy but was false
152
+ fails "Enumerator::Lazy#take when the returned lazy enumerator is evaluated by .force stops without iterations if the given argument is 0" # Expected ["before_yield"] == [] to be truthy but was false
153
+ fails "Enumerator::Lazy#take_while on a nested Lazy when the returned lazy enumerator is evaluated by .force stops after specified times" # Expected [] == [0] to be truthy but was false
154
+ fails "Enumerator::Lazy#take_while when the returned lazy enumerator is evaluated by .force stops after specified times" # Expected [] == [0, 1, 2] to be truthy but was false
155
+ fails "Enumerator::Lazy#to_enum generates a lazy enumerator from the given name" # Expected [] == [[0, 10], [1, 11], [2, 12]] to be truthy but was false
156
+ fails "Enumerator::Lazy#to_enum passes given arguments to wrapped method" # Expected [] == [0, 6, 20, 42] to be truthy but was false
157
+ fails "Enumerator::Lazy#to_enum works with an infinite enumerable" # TypeError: can't iterate from Float
158
+ fails "Enumerator::Lazy#uniq when yielded with an argument return same value after rewind" # NoMethodError: undefined method `force' for [0, 1]
159
+ fails "Enumerator::Lazy#uniq when yielded with an argument returns a lazy enumerator" # Expected [0, 1] (Array) to be an instance of Enumerator::Lazy
160
+ fails "Enumerator::Lazy#uniq when yielded with an argument sets the size to nil" # Expected 2 == nil to be truthy but was false
161
+ fails "Enumerator::Lazy#uniq when yielded with multiple arguments return same value after rewind" # NoMethodError: undefined method `force' for [[0, "foo"], [2, "bar"]]
162
+ fails "Enumerator::Lazy#uniq when yielded with multiple arguments returns all yield arguments as an array" # NoMethodError: undefined method `force' for [[0, "foo"], [2, "bar"]]
163
+ fails "Enumerator::Lazy#uniq without block return same value after rewind" # NoMethodError: undefined method `force' for [0, 1]
164
+ fails "Enumerator::Lazy#uniq without block returns a lazy enumerator" # Expected [0, 1] (Array) to be an instance of Enumerator::Lazy
165
+ fails "Enumerator::Lazy#uniq without block sets the size to nil" # Expected 2 == nil to be truthy but was false
166
+ fails "Enumerator::Lazy#uniq works with an infinite enumerable" # TypeError: can't iterate from Float
167
+ fails "Enumerator::Lazy#zip calls the block with a gathered array when yield with multiple arguments" # NoMethodError: undefined method `force' for [[[], []], [0, 0], [[0, 1], [0, 1]], [[0, 1, 2], [0, 1, 2]], [[0, 1, 2], [0, 1, 2]], [nil, nil], ["default_arg", "default_arg"], [[], []], [[], []], [[0], [0]], [[0, 1], [0, 1]], [[0, 1, 2], [0, 1, 2]]]
168
+ fails "Enumerator::Lazy#zip keeps size" # Expected 0 == 100 to be truthy but was false
169
+ fails "Enumerator::Lazy#zip on a nested Lazy keeps size" # Expected 0 == 100 to be truthy but was false
170
+ fails "Enumerator::Lazy#zip on a nested Lazy when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [[1, 4, 8], [2, 5, nil]] to be truthy but was false
171
+ fails "Enumerator::Lazy#zip raises a TypeError if arguments contain non-list object" # Expected TypeError but got: NoMethodError (undefined method `each' for #<Object:0x5898c>)
172
+ fails "Enumerator::Lazy#zip returns a Lazy when no arguments given" # Expected [[[]], [0], [[0, 1]], [[0, 1, 2]], [[0, 1, 2]], [nil], ["default_arg"], [[]], [[]], [[0]], [[0, 1]], [[0, 1, 2]]] (Array) to be an instance of Enumerator::Lazy
173
+ fails "Enumerator::Lazy#zip returns a new instance of Enumerator::Lazy" # Expected [[[], nil], [0, nil], [[0, 1], nil], [[0, 1, 2], nil], [[0, 1, 2], nil], [nil, nil], ["default_arg", nil], [[], nil], [[], nil], [[0], nil], [[0, 1], nil], [[0, 1, 2], nil]] (Array) to be an instance of Enumerator::Lazy
174
+ fails "Enumerator::Lazy#zip when the returned lazy enumerator is evaluated by Enumerable#first stops after specified times" # Expected [] == [[0, 4, 8], [1, 5, nil]] to be truthy but was false
175
+ fails "Enumerator::Lazy#zip works with an infinite enumerable and an array" # TypeError: can't iterate from Float
176
+ fails "Enumerator::Lazy#zip works with two infinite enumerables" # TypeError: can't iterate from Float
177
+ fails "Enumerator::Yielder#<< when multiple arguments passed raises an ArgumentError" # Expected ArgumentError (/wrong number of arguments/) but no exception was raised (#<Enumerator::Yielder:0x4b442> was returned)
178
+ fails "Enumerator::Yielder#initialize returns self when given a block" # Expected #<Proc:0x3d4f8> to be identical to #<Enumerator::Yielder:0x3d4ec>
179
+ fails "Enumerator::Yielder#to_proc returns a Proc object that takes an argument and yields it to the block" # Expected Enumerator::Yielder == Proc to be truthy but was false
48
180
  end