opal 0.7.2 → 0.8.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -1
  3. data/CHANGELOG.md +29 -0
  4. data/CONTRIBUTING.md +51 -4
  5. data/Gemfile +3 -0
  6. data/README.md +5 -5
  7. data/config.ru +1 -1
  8. data/examples/sinatra/Gemfile +1 -0
  9. data/examples/sinatra/config.ru +13 -3
  10. data/lib/mspec/opal/rake_task.rb +21 -30
  11. data/lib/mspec/opal/runner.rb +37 -0
  12. data/lib/mspec/opal/special_calls.rb +6 -0
  13. data/lib/opal/builder.rb +1 -0
  14. data/lib/opal/builder_processors.rb +5 -2
  15. data/lib/opal/cli_runners/phantom.js +10 -1
  16. data/lib/opal/compiler.rb +6 -3
  17. data/lib/opal/config.rb +48 -0
  18. data/lib/opal/nodes/call.rb +3 -2
  19. data/lib/opal/nodes/literal.rb +19 -2
  20. data/lib/opal/parser/grammar.rb +2224 -2196
  21. data/lib/opal/parser/grammar.y +25 -7
  22. data/lib/opal/parser/lexer.rb +12 -9
  23. data/lib/opal/path_reader.rb +1 -1
  24. data/lib/opal/sprockets/erb.rb +6 -20
  25. data/lib/opal/sprockets/path_reader.rb +4 -2
  26. data/lib/opal/sprockets/processor.rb +135 -80
  27. data/lib/opal/sprockets/server.rb +49 -78
  28. data/lib/opal/sprockets/source_map_header_patch.rb +41 -0
  29. data/lib/opal/sprockets/source_map_server.rb +115 -0
  30. data/lib/opal/version.rb +1 -1
  31. data/lib/tilt/opal.rb +48 -0
  32. data/opal.gemspec +1 -1
  33. data/opal/corelib/array.rb +179 -51
  34. data/opal/corelib/array/inheritance.rb +14 -0
  35. data/opal/corelib/boolean.rb +5 -0
  36. data/opal/corelib/hash.rb +1 -1
  37. data/opal/corelib/kernel.rb +660 -164
  38. data/opal/corelib/match_data.rb +44 -21
  39. data/opal/corelib/module.rb +83 -53
  40. data/opal/corelib/numeric.rb +15 -1
  41. data/opal/corelib/regexp.rb +31 -75
  42. data/opal/corelib/runtime.js +20 -8
  43. data/opal/corelib/string.rb +754 -243
  44. data/opal/corelib/string/inheritance.rb +20 -3
  45. data/opal/corelib/struct.rb +30 -6
  46. data/opal/corelib/variables.rb +2 -2
  47. data/spec/filters/bugs/array.rb +0 -39
  48. data/spec/filters/bugs/kernel.rb +10 -7
  49. data/spec/filters/bugs/module.rb +21 -0
  50. data/spec/filters/bugs/opal.rb +0 -5
  51. data/spec/filters/bugs/singleton.rb +0 -2
  52. data/spec/filters/bugs/string.rb +69 -315
  53. data/spec/filters/bugs/struct.rb +0 -16
  54. data/spec/filters/unsupported/encoding.rb +7 -0
  55. data/spec/filters/unsupported/float.rb +3 -0
  56. data/spec/filters/unsupported/integer_size.rb +52 -0
  57. data/spec/filters/unsupported/marshal.rb +4 -0
  58. data/spec/filters/unsupported/mutable_strings.rb +37 -0
  59. data/spec/filters/unsupported/private_methods.rb +11 -0
  60. data/spec/filters/unsupported/rational_numbers.rb +4 -0
  61. data/spec/filters/unsupported/regular_expressions.rb +47 -0
  62. data/spec/filters/unsupported/symbols.rb +7 -0
  63. data/spec/filters/unsupported/tainted.rb +23 -1
  64. data/spec/filters/unsupported/trusted.rb +5 -0
  65. data/spec/lib/fixtures/complex_sprockets.js.rb.erb +4 -0
  66. data/spec/lib/fixtures/jst_file.js.jst +1 -0
  67. data/spec/lib/parser/call_spec.rb +19 -0
  68. data/spec/lib/parser/def_spec.rb +6 -0
  69. data/spec/lib/sprockets/erb_spec.rb +17 -4
  70. data/spec/lib/sprockets/processor_spec.rb +50 -18
  71. data/spec/lib/sprockets/server_spec.rb +39 -11
  72. data/spec/lib/tilt/opal_spec.rb +19 -0
  73. data/spec/opal/core/kernel/format_spec.rb +10 -10
  74. data/spec/opal/core/language/predefined_spec.rb +10 -0
  75. data/spec/opal/core/object_id_spec.rb +56 -0
  76. data/spec/opal/core/runtime/bridged_classes_spec.rb +4 -4
  77. data/spec/opal/core/runtime_spec.rb +7 -0
  78. data/spec/opal/stdlib/native/native_class_spec.rb +1 -1
  79. data/spec/opal/stdlib/promise/always_spec.rb +30 -0
  80. data/spec/opal/stdlib/promise/then_spec.rb +8 -0
  81. data/spec/opal/stdlib/promise/trace_spec.rb +8 -0
  82. data/spec/rubyspecs +15 -104
  83. data/spec/spec_helper.rb +4 -0
  84. data/stdlib/native.rb +7 -18
  85. data/stdlib/nodejs/file.rb +1 -1
  86. data/stdlib/opal-parser.rb +1 -0
  87. data/stdlib/pp.rb +7 -5
  88. data/stdlib/promise.rb +53 -41
  89. data/tasks/testing.rake +8 -6
  90. metadata +28 -14
  91. data/spec/filters/bugs/match_data.rb +0 -13
  92. data/spec/filters/bugs/numeric.rb +0 -22
  93. data/spec/filters/bugs/regexp.rb +0 -9
  94. data/spec/filters/bugs/unknown.rb +0 -11
@@ -15,6 +15,8 @@ class String
15
15
  end
16
16
 
17
17
  class String::Wrapper
18
+ `def.$$is_string = true`
19
+
18
20
  def self.allocate(string = "")
19
21
  obj = super()
20
22
  `obj.literal = string`
@@ -68,11 +70,26 @@ class String::Wrapper
68
70
  @literal
69
71
  end
70
72
 
71
- def to_str
72
- self
73
- end
73
+ alias to_str to_s
74
74
 
75
75
  def inspect
76
76
  @literal.inspect
77
77
  end
78
+
79
+ def +(other)
80
+ @literal + other
81
+ end
82
+
83
+ def *(other)
84
+ %x{
85
+ var result = #{@literal * other};
86
+
87
+ if (result.$$is_string) {
88
+ return #{self.class.allocate(`result`)}
89
+ }
90
+ else {
91
+ return result;
92
+ }
93
+ }
94
+ end
78
95
  end
@@ -1,4 +1,8 @@
1
+ require 'corelib/enumerable'
2
+
1
3
  class Struct
4
+ include Enumerable
5
+
2
6
  def self.new(name = undefined, *args, &block)
3
7
  return super unless self == Struct
4
8
 
@@ -34,8 +38,6 @@ class Struct
34
38
  end
35
39
 
36
40
  def self.inherited(klass)
37
- return if self == Struct
38
-
39
41
  members = @members
40
42
 
41
43
  klass.instance_eval {
@@ -47,8 +49,6 @@ class Struct
47
49
  alias [] new
48
50
  end
49
51
 
50
- include Enumerable
51
-
52
52
  def initialize(*args)
53
53
  members.each_with_index {|name, index|
54
54
  instance_variable_set "@#{name}", args[index]
@@ -61,11 +61,14 @@ class Struct
61
61
 
62
62
  def [](name)
63
63
  if Integer === name
64
+ raise IndexError, "offset #{name} too small for struct(size:#{members.size})" if name < -members.size
64
65
  raise IndexError, "offset #{name} too large for struct(size:#{members.size})" if name >= members.size
65
66
 
66
67
  name = members[name]
67
- else
68
+ elsif String === name
68
69
  raise NameError, "no member '#{name}' in struct" unless members.include?(name.to_sym)
70
+ else
71
+ raise TypeError, "no implicit conversion of #{name.class} into Integer"
69
72
  end
70
73
 
71
74
  instance_variable_get "@#{name}"
@@ -73,11 +76,14 @@ class Struct
73
76
 
74
77
  def []=(name, value)
75
78
  if Integer === name
79
+ raise IndexError, "offset #{name} too small for struct(size:#{members.size})" if name < -members.size
76
80
  raise IndexError, "offset #{name} too large for struct(size:#{members.size})" if name >= members.size
77
81
 
78
82
  name = members[name]
79
- else
83
+ elsif String === name
80
84
  raise NameError, "no member '#{name}' in struct" unless members.include?(name.to_sym)
85
+ else
86
+ raise TypeError, "no implicit conversion of #{name.class} into Integer"
81
87
  end
82
88
 
83
89
  instance_variable_set "@#{name}", value
@@ -132,4 +138,22 @@ class Struct
132
138
  end
133
139
 
134
140
  alias to_s inspect
141
+
142
+ def to_h
143
+ members.inject({}) {|h, name| h[name] = self[name]; h}
144
+ end
145
+
146
+ def values_at(*args)
147
+ args = args.map{|arg| `arg.$$is_range ? #{arg.to_a} : arg`}.flatten
148
+ %x{
149
+ var result = [];
150
+ for (var i = 0, len = args.length; i < len; i++) {
151
+ if (!args[i].$$is_number) {
152
+ #{raise TypeError, "no implicit conversion of #{`args[i]`.class} into Integer"}
153
+ }
154
+ result.push(#{self[`args[i]`]});
155
+ }
156
+ return result;
157
+ }
158
+ end
135
159
  end
@@ -20,5 +20,5 @@ $SAFE = 0
20
20
  RUBY_PLATFORM = 'opal'
21
21
  RUBY_ENGINE = 'opal'
22
22
  RUBY_VERSION = '2.1.1'
23
- RUBY_ENGINE_VERSION = '0.7.2'
24
- RUBY_RELEASE_DATE = '2014-04-15'
23
+ RUBY_ENGINE_VERSION = '0.8.0.dev'
24
+ RUBY_RELEASE_DATE = '2015-02-14'
@@ -17,25 +17,10 @@ opal_filter "Array" do
17
17
  fails "Array#<=> tries to convert the passed argument to an Array using #to_ary"
18
18
  fails "Array#<=> returns nil when the argument is not array-like"
19
19
 
20
- fails "Array#delete may be given a block that is executed if no element matches object"
21
- fails "Array#delete returns the last element in the array for which object is equal under #=="
22
-
23
20
  fails "Array.[] can unpack 2 or more nested referenced array"
24
21
 
25
22
  fails "Array#[]= sets elements in the range arguments when passed ranges"
26
23
 
27
- fails "Array#flatten does not call flatten on elements"
28
- fails "Array#flatten with a non-Array object in the Array ignores the return value of #to_ary if it is nil"
29
- fails "Array#flatten with a non-Array object in the Array raises a TypeError if the return value of #to_ary is not an Array"
30
- fails "Array#flatten raises a TypeError when the passed Object can't be converted to an Integer"
31
- fails "Array#flatten tries to convert passed Objects to Integers using #to_int"
32
-
33
- fails "Array#flatten! does not call flatten! on elements"
34
- fails "Array#flatten! flattens any elements which responds to #to_ary, using the return value of said method"
35
- fails "Array#flatten! raises a TypeError when the passed Object can't be converted to an Integer"
36
- fails "Array#flatten! tries to convert passed Objects to Integers using #to_int"
37
- fails "Array#flatten! should not check modification by size"
38
-
39
24
  fails "Array#initialize with (size, object=nil) sets the array to the values returned by the block before break is executed"
40
25
  fails "Array#initialize with (size, object=nil) returns the value passed to break"
41
26
  fails "Array#initialize with (size, object=nil) uses the block value instead of using the default value"
@@ -81,15 +66,6 @@ opal_filter "Array" do
81
66
  fails "Array#permutation returns an Enumerator of permutations of given length when called with an argument but no block"
82
67
  fails "Array#permutation returns an Enumerator of all permutations when called without a block or arguments"
83
68
 
84
- fails "Array#product when given an empty block returns self"
85
- fails "Array#product when given a block will ignore unreasonable numbers of products and yield anyway"
86
- fails "Array#product when given a block yields all combinations in turn"
87
- fails "Array#product does not attempt to produce an unreasonable number of products"
88
- fails "Array#product returns an empty array when the argument is an empty array"
89
- fails "Array#product has no required argument"
90
- fails "Array#product returns the expected result"
91
- fails "Array#product returns converted arguments using :to_ary"
92
-
93
69
  fails "Array#rassoc does not check the last element in each contained but speficically the second"
94
70
  fails "Array#rassoc calls elem == obj on the second element of each contained array"
95
71
 
@@ -203,30 +179,15 @@ opal_filter "Array" do
203
179
  fails "Array#zip calls #to_ary to convert the argument to an Array"
204
180
  fails "Array#zip uses #each to extract arguments' elements when #to_ary fails"
205
181
 
206
- fails "Array#hash returns the same value if arrays are #eql?"
207
- fails "Array#hash returns same hash code for arrays with the same content"
208
- fails "Array#hash ignores array class differences"
209
- fails "Array#hash calls to_int on result of calling hash on each element"
210
182
  fails "Array#hash returns the same fixnum for arrays with the same content"
211
183
 
212
184
  fails "Array#partition returns in the left array values for which the block evaluates to true"
213
- fails "Array#partition returns two arrays"
214
- fails "Array#partition does not return subclass instances on Array subclasses"
215
185
 
216
186
  fails "Array#| acts as if using an intermediate hash to collect values"
217
187
 
218
188
  # recursive arrays
219
- fails "Array#join raises an ArgumentError when the Array is recursive"
220
189
  fails "Array#uniq! properly handles recursive arrays"
221
- fails "Array#| properly handles recursive arrays"
222
190
  fails "Array#<=> properly handles recursive arrays"
223
- fails "Array#eql? handles well recursive arrays"
224
- fails "Array#== handles well recursive arrays"
225
- fails "Array#flatten raises an ArgumentError on recursive arrays"
226
- fails "Array#flatten! raises an ArgumentError on recursive arrays"
227
- fails "Array#partition properly handles recursive arrays"
228
- fails "Array#& properly handles recursive arrays"
229
191
  fails "Array#values_at properly handles recursive arrays"
230
192
  fails "Array#hash returns the same hash for equal recursive arrays through hashes"
231
- fails "Array#hash returns the same hash for equal recursive arrays"
232
193
  end
@@ -1,10 +1,13 @@
1
1
  opal_filter "Kernel" do
2
- fails "Kernel.rand returns a float if no argument is passed"
3
- fails "Kernel.rand returns an integer for an integer argument"
2
+ fails "Kernel.Array does not call #to_a on an Array" #something funky with the spec itself
3
+ fails "Kernel#Array does not call #to_a on an Array" #something funky with the spec itself
4
4
 
5
- fails "Kernel#<=> returns 0 if self is == to the argument"
6
- fails "Kernel#<=> returns nil if self is eql? but not == to the argument"
7
- fails "Kernel#<=> returns nil if self.==(arg) returns nil"
8
-
9
- fails "Kernel#equal? returns true only if obj and other are the same object"
5
+ fails "Kernel.String raises a TypeError if #to_s does not exist"
6
+ fails "Kernel.String raises a TypeError if respond_to? returns false for #to_s"
7
+ fails "Kernel.String raises a TypeError if #to_s is not defined, even though #respond_to?(:to_s) returns true"
8
+ fails "Kernel.String calls #to_s if #respond_to?(:to_s) returns true"
9
+ fails "Kernel#String raises a TypeError if #to_s does not exist"
10
+ fails "Kernel#String raises a TypeError if respond_to? returns false for #to_s"
11
+ fails "Kernel#String raises a TypeError if #to_s is not defined, even though #respond_to?(:to_s) returns true"
12
+ fails "Kernel#String calls #to_s if #respond_to?(:to_s) returns true"
10
13
  end
@@ -11,6 +11,16 @@ opal_filter "Module" do
11
11
 
12
12
  fails "Module#const_defined? should not search parent scopes of classes and modules if inherit is false"
13
13
  fails "Module#const_get should not search parent scopes of classes and modules if inherit is false"
14
+ fails "Module#const_get raises a NameError with the not found constant symbol"
15
+ fails "Module#const_get calls #to_str to convert the given name to a String"
16
+ fails "Module#const_get raises a TypeError if conversion to a String by calling #to_str fails"
17
+ fails "Module#const_get does not search the singleton class of a Class or Module"
18
+ fails "Module#const_get raises a NameError if the constant is defined in the receiver's supperclass and the inherit flag is false"
19
+ fails "Module#const_get accepts a toplevel scope qualifier"
20
+ fails "Module#const_get raises a NameError if a Symbol is a scoped constant name"
21
+ fails "Module#const_get with dynamically assigned constants searches a module included in the immediate class before the superclass"
22
+ fails "Module#const_get with dynamically assigned constants searches a module included in the superclass"
23
+ fails "Module#const_get with dynamically assigned constants searches the superclass chain"
14
24
 
15
25
  fails "Module#class_variable_set sets the value of a class variable with the given name defined in an included module"
16
26
  fails "Module#class_variable_get returns the value of a class variable with the given name defined in an included module"
@@ -28,4 +38,15 @@ opal_filter "Module" do
28
38
  fails "Module#module_function as a toggle (no arguments) in a Module body does not affect module_evaled method definitions also if outside the eval itself"
29
39
  fails "Module#module_function as a toggle (no arguments) in a Module body has no effect if inside a module_eval if the definitions are outside of it"
30
40
  fails "Module#module_function with specific method names creates an independent copy of the method, not a redirect"
41
+
42
+ fails "Module#include adds all ancestor modules when a previously included module is included again"
43
+ fails "Module#include raises a TypeError when the argument is not a Module"
44
+ fails "Module#include imports instance methods to modules and classes"
45
+ fails "Module#include doesn't include module if it is included in a super class"
46
+ fails "Module#include recursively includes new mixins"
47
+ fails "Module#include preserves ancestor order"
48
+ fails "Module#include detects cyclic includes"
49
+ fails "Module#include ignores modules it has already included via module mutual inclusion"
50
+ fails "Module#include? returns true if the given module is included by self or one of it's ancestors"
51
+ fails "Module#include? raises a TypeError when no module was given"
31
52
  end
@@ -5,10 +5,5 @@ opal_filter "Opal bugs" do
5
5
  fails "Array#shift passed a number n as an argument raises an ArgumentError if more arguments are passed"
6
6
  fails "Array#pop passed a number n as an argument raises an ArgumentError if more arguments are passed"
7
7
 
8
- # lacking regexp conversion
9
- fails "String#index with Regexp supports \\G which matches at the given start offset"
10
- fails "String#index with Regexp starts the search at the given offset"
11
- fails "String#index with Regexp returns the index of the first match of regexp"
12
-
13
8
  fails "Kernel#warn requires multiple arguments"
14
9
  end
@@ -1,6 +1,4 @@
1
1
  opal_filter "Singleton" do
2
- fails "Singleton#_dump returns an empty string"
3
- fails "Singleton#_dump returns an empty string from a singleton subclass"
4
2
  fails "Singleton.instance returns an instance of the singleton's clone"
5
3
  fails "Singleton.instance returns the same instance for multiple class to instance on clones"
6
4
  end
@@ -1,248 +1,25 @@
1
1
  opal_filter "String" do
2
- fails "String#=== ignores subclass differences"
3
- fails "String#=== returns false if obj does not respond to to_str"
4
- fails "String#=== returns obj == self if obj responds to to_str"
5
- fails "String#=== returns obj == self if obj responds to to_str"
6
-
7
- fails "String#=~ raises a TypeError if a obj is a string"
8
-
9
- fails "String#[] calls to_int on the given index"
10
- fails "String#[] calls to_int on the given index"
11
- fails "String#[] raises a TypeError if the given index is nil"
12
- fails "String#[] raises a TypeError if the given index can't be converted to an Integer"
13
- fails "String#[] with index, length returns nil if the length is negative"
14
- fails "String#[] with index, length calls to_int on the given index and the given length"
15
- fails "String#[] with index, length calls to_int on the given index and the given length"
16
- fails "String#[] with index, length raises a TypeError when idx or length can't be converted to an integer"
17
- fails "String#[] with index, length raises a TypeError when the given index or the given length is nil"
18
- fails "String#[] with Range returns nil if the beginning of the range falls outside of self"
19
- fails "String#[] with Range calls to_int on range arguments"
2
+ #The following two failures are waiting for https://github.com/opal/opal/issues/710 to be fixed
20
3
  fails "String#[] with Range calls to_int on range arguments"
21
- fails "String#[] with Range handles repeated application"
22
- fails "String#[] with Regexp returns the matching portion of self"
23
- fails "String#[] with Regexp returns nil if there is no match"
24
- fails "String#[] with Regexp sets $~ to MatchData when there is a match and nil when there's none"
25
- fails "String#[] with Regexp, index returns the capture for the given index"
26
- fails "String#[] with Regexp, index returns nil if there is no match"
27
- fails "String#[] with Regexp, index returns nil if there is no capture for the given index"
28
- fails "String#[] with Regexp, index calls to_int on the given index"
29
- fails "String#[] with Regexp, index calls to_int on the given index"
30
- fails "String#[] with Regexp, index raises a TypeError when the given index can't be converted to Integer"
31
- fails "String#[] with Regexp, index raises a TypeError when the given index is nil"
32
- fails "String#[] with Regexp, index sets $~ to MatchData when there is a match and nil when there's none"
33
- fails "String#[] with String returns other_str if it occurs in self"
34
- fails "String#[] with String returns nil if there is no match"
35
- fails "String#[] with String doesn't call to_str on its argument"
36
- fails "String#[] with String returns a subclass instance when given a subclass instance"
4
+ fails "String#slice with Range calls to_int on range arguments"
37
5
 
38
- fails "String#dup does not copy constants defined in the singleton class"
39
- fails "String#dup does not modify the original string when changing dupped string"
6
+ fails "String#clone copies singleton methods"
7
+ fails "String#clone copies modules included in the singleton class"
8
+ fails "String#clone does not modify the original string when changing cloned string"
40
9
 
41
- fails "String#end_with? converts its argument using :to_str"
42
- fails "String#end_with? returns true if other is empty"
10
+ fails "String#dup does not copy constants defined in the singleton class"
43
11
 
44
- fails "String#each_line accepts a string separator"
45
- fails "String#each_line passes self as a whole to the block if the separator is nil"
46
- fails "String#each_line yields paragraphs (broken by 2 or more successive newlines) when passed ''"
47
- fails "String#each_line uses $/ as the separator when none is given"
48
12
  fails "String#each_line yields subclass instances for subclasses"
49
- fails "String#each_line tries to convert the separator to a string using to_str"
50
- fails "String#each_line tries to convert the separator to a string using to_str"
51
- fails "String#each_line does not care if the string is modified while substituting"
52
- fails "String#each_line raises a TypeError when the separator can't be converted to a string"
53
- fails "String#each_line accept string separator"
54
- fails "String#each_line raises a TypeError when the separator is a symbol"
55
- fails "String#each_line returns an enumerator when no block given"
56
-
57
- fails "String#gsub with pattern and replacement inserts the replacement around every character when the pattern collapses"
58
- fails "String#gsub with pattern and replacement respects $KCODE when the pattern collapses"
59
- fails "String#gsub with pattern and replacement doesn't freak out when replacing ^"
60
- fails "String#gsub with pattern and replacement returns a copy of self with all occurrences of pattern replaced with replacement"
61
- fails "String#gsub with pattern and replacement supports \\G which matches at the beginning of the remaining (non-matched) string"
62
- fails "String#gsub with pattern and replacement replaces \\1 sequences with the regexp's corresponding capture"
63
- fails "String#gsub with pattern and replacement treats \\1 sequences without corresponding captures as empty strings"
64
- fails "String#gsub with pattern and replacement replaces \\& and \\0 with the complete match"
65
- fails "String#gsub with pattern and replacement replaces \\` with everything before the current match"
66
- fails "String#gsub with pattern and replacement replaces \\' with everything after the current match"
67
- fails "String#gsub with pattern and replacement replaces \\+ with the last paren that actually matched"
68
- fails "String#gsub with pattern and replacement treats \\+ as an empty string if there was no captures"
69
- fails "String#gsub with pattern and replacement maps \\\\ in replacement to \\"
70
- fails "String#gsub with pattern and replacement handles pattern collapse without $KCODE"
71
- fails "String#gsub with pattern and replacement raises a TypeError when replacement can't be converted to a string"
72
- fails "String#gsub with pattern and replacement sets $~ to MatchData of last match and nil when there's none"
73
- fails "String#gsub with pattern and Hash returns a copy of self with all occurrences of pattern replaced with the value of the corresponding hash key"
74
- fails "String#gsub with pattern and Hash ignores keys that don't correspond to matches"
75
- fails "String#gsub with pattern and Hash returns an empty string if the pattern matches but the hash specifies no replacements"
76
- fails "String#gsub with pattern and Hash ignores non-String keys"
77
- fails "String#gsub with pattern and Hash uses a key's value as many times as needed"
78
- fails "String#gsub with pattern and Hash uses the hash's default value for missing keys"
79
- fails "String#gsub with pattern and Hash coerces the hash values with #to_s"
80
- fails "String#gsub with pattern and Hash coerces the hash values with #to_s"
81
- fails "String#gsub with pattern and Hash uses the hash's value set from default_proc for missing keys"
82
- fails "String#gsub with pattern and Hash sets $~ to MatchData of last match and nil when there's none for access from outside"
83
- fails "String#gsub with pattern and Hash doesn't interpolate special sequences like \\1 for the block's return value"
84
- fails "String#gsub with pattern and block sets $~ for access from the block"
85
- fails "String#gsub with pattern and block restores $~ after leaving the block"
86
- fails "String#gsub with pattern and block sets $~ to MatchData of last match and nil when there's none for access from outside"
87
-
88
- fails "String#index raises a TypeError if passed a Symbol"
89
13
 
90
- fails "String#intern does not special case certain operators"
91
- fails "String#intern special cases +(binary) and -(binary)"
92
-
93
- fails "String#lines accepts a string separator"
94
- fails "String#lines should split on the default record separator and return enumerator if not block is given"
95
- fails "String#lines splits using default newline separator when none is specified"
96
- fails "String#lines splits self using the supplied record separator and passes each substring to the block"
97
- fails "String#lines passes self as a whole to the block if the separator is nil"
98
- fails "String#lines yields paragraphs (broken by 2 or more successive newlines) when passed ''"
99
14
  fails "String#lines yields subclass instances for subclasses"
100
- fails "String#lines returns self"
101
- fails "String#lines tries to convert the separator to a string using to_str"
102
- fails "String#lines tries to convert the separator to a string using to_str"
103
- fails "String#lines does not care if the string is modified while substituting"
104
- fails "String#lines raises a TypeError when the separator can't be converted to a string"
105
- fails "String#lines accept string separator"
106
- fails "String#lines raises a TypeError when the separator is a symbol"
107
- fails "String#lines returns an array when no block given"
108
-
109
- fails "String#lstrip returns a copy of self with leading whitespace removed"
110
-
111
- fails "String#next returns the successor by increasing the rightmost alphanumeric (digit => digit, letter => letter with same case)"
112
- fails "String#next increases the next best alphanumeric (jumping over non-alphanumerics) if there is a carry"
113
- fails "String#next increases the next best character if there is a carry for non-alphanumerics"
114
- fails "String#next adds an additional character (just left to the last increased one) if there is a carry and no character left to increase"
115
-
116
-
117
- fails "String#partition with String accepts regexp"
118
- fails "String#partition with String sets global vars if regexp used"
119
- fails "String#partition with String converts its argument using :to_str"
120
- fails "String#partition with String converts its argument using :to_str"
121
- fails "String#partition with String raises an error if not convertible to string"
122
-
123
- fails "String#rindex with object raises a TypeError if obj isn't a String, Fixnum or Regexp"
124
- fails "String#rindex with object tries to convert obj to a string via to_str"
125
- fails "String#rindex with String ignores string subclasses"
126
- fails "String#rindex with String returns nil if the substring isn't found"
127
- fails "String#rindex with String raises a TypeError when given offset is nil"
128
- fails "String#rindex with Regexp behaves the same as String#rindex(string) for escaped string regexps"
129
- fails "String#rindex with Regexp returns the index of the first match from the end of string of regexp"
130
- fails "String#rindex with Regexp sets $~ to MatchData of match and nil when there's none"
131
- fails "String#rindex with Regexp starts the search at the given offset"
132
- fails "String#rindex with Regexp supports \\G which matches at the given start offset"
133
- fails "String#rindex with Regexp tries to convert start_offset to an integer via to_int"
134
- fails "String#rindex with Regexp raises a TypeError when given offset is nil"
135
-
136
- fails "String#rstrip returns a copy of self with trailing whitespace removed"
137
- fails "String#rstrip returns a copy of self with all trailing whitespace and NULL bytes removed"
138
-
139
- fails "String#slice calls to_int on the given index"
140
- fails "String#slice calls to_int on the given index"
141
- fails "String#slice raises a TypeError if the given index is nil"
142
- fails "String#slice raises a TypeError if the given index can't be converted to an Integer"
143
- fails "String#slice with index, length returns nil if the length is negative"
144
- fails "String#slice with index, length calls to_int on the given index and the given length"
145
- fails "String#slice with index, length calls to_int on the given index and the given length"
146
- fails "String#slice with index, length raises a TypeError when idx or length can't be converted to an integer"
147
- fails "String#slice with index, length raises a TypeError when the given index or the given length is nil"
148
- fails "String#slice with Range returns nil if the beginning of the range falls outside of self"
149
- fails "String#slice with Range calls to_int on range arguments"
150
- fails "String#slice with Range calls to_int on range arguments"
151
- fails "String#slice with Range handles repeated application"
152
- fails "String#slice with Regexp returns the matching portion of self"
153
- fails "String#slice with Regexp returns nil if there is no match"
154
- fails "String#slice with Regexp sets $~ to MatchData when there is a match and nil when there's none"
155
- fails "String#slice with Regexp, index returns the capture for the given index"
156
- fails "String#slice with Regexp, index returns nil if there is no match"
157
- fails "String#slice with Regexp, index returns nil if there is no capture for the given index"
158
- fails "String#slice with Regexp, index calls to_int on the given index"
159
- fails "String#slice with Regexp, index calls to_int on the given index"
160
- fails "String#slice with Regexp, index raises a TypeError when the given index can't be converted to Integer"
161
- fails "String#slice with Regexp, index raises a TypeError when the given index is nil"
162
- fails "String#slice with Regexp, index sets $~ to MatchData when there is a match and nil when there's none"
163
- fails "String#slice with String returns other_str if it occurs in self"
164
- fails "String#slice with String returns nil if there is no match"
165
- fails "String#slice with String doesn't call to_str on its argument"
166
- fails "String#slice with String returns a subclass instance when given a subclass instance"
167
- fails "String#slice with Regexp, group"
168
15
 
169
16
  fails "String#split with String returns subclass instances based on self"
170
- fails "String#split with Regexp respects $KCODE when splitting between characters"
171
17
  fails "String#split with Regexp includes all captures in the result array"
172
18
  fails "String#split with Regexp does not include non-matching captures in the result array"
173
19
  fails "String#split with Regexp returns subclass instances based on self"
174
20
  fails "String#split with Regexp does not call constructor on created subclass instances"
175
21
  fails "String#split with String does not call constructor on created subclass instances"
176
22
 
177
- fails "String#squeeze negates sets starting with ^"
178
- fails "String#squeeze squeezes all chars in a sequence"
179
- fails "String#squeeze raises an ArgumentError when the parameter is out of sequence"
180
-
181
- fails "String#start_with? ignores arguments not convertible to string"
182
- fails "String#start_with? converts its argument using :to_str"
183
-
184
- fails "String#strip returns a new string with leading and trailing whitespace removed"
185
- fails "String#strip returns a copy of self with trailing NULL bytes and whitespace"
186
-
187
- fails "String#sub with pattern, replacement supports \\G which matches at the beginning of the string"
188
- fails "String#sub with pattern, replacement replaces \\1 sequences with the regexp's corresponding capture"
189
- fails "String#sub with pattern, replacement treats \\1 sequences without corresponding captures as empty strings"
190
- fails "String#sub with pattern, replacement replaces \\& and \\0 with the complete match"
191
- fails "String#sub with pattern, replacement replaces \\` with everything before the current match"
192
- fails "String#sub with pattern, replacement replaces \\' with everything after the current match"
193
- fails "String#sub with pattern, replacement replaces \\+ with the last paren that actually matched"
194
- fails "String#sub with pattern, replacement treats \\+ as an empty string if there was no captures"
195
- fails "String#sub with pattern, replacement sets $~ to MatchData of match and nil when there's none"
196
- fails "String#sub with pattern and block sets $~ for access from the block"
197
- fails "String#sub with pattern and block sets $~ to MatchData of last match and nil when there's none for access from outside"
198
- fails "String#sub with pattern and block doesn't raise a RuntimeError if the string is modified while substituting"
199
-
200
- fails "String#succ returns the successor by increasing the rightmost alphanumeric (digit => digit, letter => letter with same case)"
201
- fails "String#succ increases the next best alphanumeric (jumping over non-alphanumerics) if there is a carry"
202
- fails "String#succ increases the next best character if there is a carry for non-alphanumerics"
203
- fails "String#succ adds an additional character (just left to the last increased one) if there is a carry and no character left to increase"
204
-
205
- fails "String#sum returns a basic n-bit checksum of the characters in self"
206
- fails "String#sum tries to convert n to an integer using to_int"
207
- fails "String#sum tries to convert n to an integer using to_int"
208
- fails "String#sum returns sum of the bytes in self if n less or equal to zero"
209
-
210
- fails "String#to_str returns a new instance of String when called on a subclass"
211
-
212
- fails "String#to_sym does not special case certain operators"
213
- fails "String#to_sym special cases +(binary) and -(binary)"
214
-
215
- fails "String#tr raises an ArgumentError a descending range in the replacement as containing just the start character"
216
- fails "String#tr raises an ArgumentError a descending range in the source as empty"
217
- fails "String#tr translates chars not in from_string when it starts with a ^"
218
- fails "String#tr tries to convert from_str and to_str to strings using to_str"
219
- fails "String#tr tries to convert from_str and to_str to strings using to_str"
220
-
221
- fails "String#tr_s translates chars not in from_string when it starts with a ^"
222
- fails "String#tr_s tries to convert from_str and to_str to strings using to_str"
223
-
224
- fails "String#sub with pattern, replacement replaces \\\\\\+ with \\\\+"
225
- fails "String#sub with pattern, replacement replaces \\\\\1 with \\"
226
- fails "String#sub with pattern, replacement replaces \\\1 with \1"
227
- fails "String#sub with pattern and Hash returns a copy of self with the first occurrence of pattern replaced with the value of the corresponding hash key"
228
- fails "String#sub with pattern and Hash removes keys that don't correspond to matches"
229
- fails "String#sub with pattern and Hash ignores non-String keys"
230
- fails "String#sub with pattern and Hash uses a key's value only a single time"
231
- fails "String#sub with pattern and Hash uses the hash's default value for missing keys"
232
- fails "String#sub with pattern and Hash coerces the hash values with #to_s"
233
- fails "String#sub with pattern and Hash uses the hash's value set from default_proc for missing keys"
234
- fails "String#sub with pattern and Hash sets $~ to MatchData of first match and nil when there's none for access from outside"
235
- fails "String#sub with pattern and Hash doesn't interpolate special sequences like \\1 for the block's return value"
236
- fails "String#sub with pattern and Hash untrusts the result if the original string is untrusted"
237
- fails "String#sub with pattern and Hash untrusts the result if a hash value is untrusted"
238
- fails "String#sub with pattern and Hash taints the result if the original string is tainted"
239
- fails "String#sub with pattern and Hash taints the result if a hash value is tainted"
240
-
241
-
242
-
243
- fails "String#casecmp independent of case for non-ASCII characters returns -1 when numerically less than other"
244
- fails "String#casecmp independent of case for non-ASCII characters returns 1 when numerically greater than other"
245
-
246
23
  fails "String#byteslice returns the character code of the character at the given index"
247
24
  fails "String#byteslice returns nil if index is outside of self"
248
25
  fails "String#byteslice calls to_int on the given index"
@@ -266,95 +43,72 @@ opal_filter "String" do
266
43
  fails "String#byteslice with Range works with Range subclasses"
267
44
  fails "String#byteslice with Range handles repeated application"
268
45
 
269
- fails "String#count counts occurrences of chars from the intersection of the specified sets"
270
- fails "String#count negates sets starting with ^"
271
- fails "String#count counts all chars in a sequence"
272
- fails "String#count raises if the given sequences are invalid"
273
- fails "String#count calls #to_str to convert each set arg to a String"
274
- fails "String#count raises a TypeError when a set arg can't be converted to a string"
275
-
276
- fails "String#delete returns a new string with the chars from the intersection of sets removed"
277
- fails "String#delete raises an ArgumentError when given no arguments"
278
- fails "String#delete negates sets starting with ^"
279
- fails "String#delete deletes all chars in a sequence"
280
- fails "String#delete respects backslash for escaping a -"
281
- fails "String#delete raises if the given ranges are invalid"
282
- fails "String#delete taints result when self is tainted"
283
- fails "String#delete tries to convert each set arg to a string using to_str"
284
- fails "String#delete raises a TypeError when one set arg can't be converted to a string"
285
- fails "String#delete returns subclass instances when called on a subclass"
46
+ fails "String#getbyte returns an Integer if given a valid index"
47
+ fails "String#getbyte starts indexing at 0"
48
+ fails "String#getbyte counts from the end of the String if given a negative argument"
49
+ fails "String#getbyte returns an Integer between 0 and 255"
50
+ fails "String#getbyte regards a multi-byte character as having multiple bytes"
51
+ fails "String#getbyte mirrors the output of #bytes"
52
+ fails "String#getbyte interprets bytes relative to the String's encoding"
53
+ fails "String#getbyte returns nil for out-of-bound indexes"
54
+ fails "String#getbyte regards the empty String as containing no bytes"
55
+ fails "String#getbyte raises a TypeError unless its argument can be coerced into an Integer"
286
56
 
287
57
  fails "String#each_byte returns an enumerator when no block given"
288
58
  fails "String#each_byte keeps iterating from the old position (to new string end) when self changes"
289
59
  fails "String#each_byte passes each byte in self to the given block"
290
60
 
291
- fails "String#== returns obj == self if obj responds to to_str"
292
- fails "String#== returns false if obj does not respond to to_str"
293
- fails "String#eql? when given a non-String returns false"
294
-
295
- fails "String#hex treats leading characters of self as a string of hex digits"
296
-
297
- fails "String#initialize with an argument raises a RuntimeError on a frozen instance when self-replacing"
298
- fails "String#initialize with an argument raises a RuntimeError on a frozen instance that is modified"
299
- fails "String#initialize with an argument raises a TypeError if other can't be converted to string"
300
- fails "String#initialize with an argument tries to convert other to string using to_str"
301
- fails "String#initialize with an argument replaces the encoding of self with that of other"
302
- fails "String#initialize with an argument does not trust self if other is trusted"
303
- fails "String#initialize with an argument untrusts self if other is untrusted"
304
- fails "String#initialize with an argument does not untaint self if other is untainted"
305
- fails "String#initialize with an argument taints self if other is tainted"
306
- fails "String#initialize with an argument replaces the content of self with other"
307
- fails "String#initialize with an argument returns self"
308
- fails "String#initialize with no arguments does not raise an exception when frozen"
309
- fails "String#initialize is a private method"
310
-
311
- fails "String#upto passes successive values, starting at self and ending at other_string, to the block"
312
- fails "String#upto calls the block once even when start eqals stop"
313
- fails "String#upto doesn't call block with self even if self is less than stop but stop length is less than self length"
314
- fails "String#upto doesn't call block if stop is less than self and stop length is less than self length"
315
- fails "String#upto doesn't call the block if self is greater than stop"
316
- fails "String#upto stops iterating as soon as the current value's character count gets higher than stop's"
317
- fails "String#upto returns self"
318
- fails "String#upto tries to convert other to string using to_str"
319
- fails "String#upto raises a TypeError if other can't be converted to a string"
320
- fails "String#upto does not work with symbols"
321
- fails "String#upto returns an enumerator when no block given"
322
- fails "String#upto returns non-alphabetic characters in the ASCII range for single letters"
323
- fails "String#upto stops before the last value if exclusive"
324
- fails "String#upto on sequence of numbers calls the block as Integer#upto"
325
-
326
- fails "String#* always taints the result when self is tainted"
327
- fails "String#* returns subclass instances"
328
- fails "String#* raises a RangeError when given integer is a Bignum"
329
- fails "String#* raises an ArgumentError when given integer is negative"
330
- fails "String#* tries to convert the given argument to an integer using to_int"
331
-
332
- fails "String.new returns a binary String"
333
- fails "String.new raises TypeError on inconvertible object"
334
- fails "String.new is called on subclasses"
335
- fails "String.new returns an instance of a subclass"
336
- fails "String.new returns a new string given a string argument"
337
- fails "String.new returns a fully-formed String"
338
-
339
- fails "String#+ taints the result when self or other is tainted"
340
- fails "String#+ when self is in an ASCII-incompatible encoding incompatible with the argument's encoding uses self's encoding if both are empty"
341
- fails "String#+ when self is in an ASCII-incompatible encoding incompatible with the argument's encoding uses self's encoding if the argument is empty"
342
- fails "String#+ when self is in an ASCII-incompatible encoding incompatible with the argument's encoding uses the argument's encoding if self is empty"
343
- fails "String#+ when self is in an ASCII-incompatible encoding incompatible with the argument's encoding raises Encoding::CompatibilityError if neither are empty"
344
- fails "String#+ when the argument is in an ASCII-incompatible encoding incompatible with self's encoding uses self's encoding if both are empty"
345
- fails "String#+ when the argument is in an ASCII-incompatible encoding incompatible with self's encoding uses self's encoding if the argument is empty"
346
- fails "String#+ when the argument is in an ASCII-incompatible encoding incompatible with self's encoding uses the argument's encoding if self is empty"
347
- fails "String#+ when the argument is in an ASCII-incompatible encoding incompatible with self's encoding raises Encoding::CompatibilityError if neither are empty"
348
- fails "String#+ when self and the argument are in different ASCII-compatible encodings uses self's encoding if both are ASCII-only"
349
- fails "String#+ when self and the argument are in different ASCII-compatible encodings uses self's encoding if the argument is ASCII-only"
350
- fails "String#+ when self and the argument are in different ASCII-compatible encodings uses the argument's encoding if self is ASCII-only"
351
- fails "String#+ when self and the argument are in different ASCII-compatible encodings raises Encoding::CompatibilityError if neither are ASCII-only"
352
- fails "String#+ when self is ASCII-8BIT and argument is US-ASCII uses ASCII-8BIT encoding"
353
-
354
- fails "String#rpartition with String raises an error if not convertible to string"
355
- fails "String#rpartition with String converts its argument using :to_str"
356
- fails "String#rpartition with String affects $~"
357
- fails "String#rpartition with String accepts regexp"
358
- fails "String#rpartition with String always returns 3 elements"
359
- fails "String#rpartition with String returns an array of substrings based on splitting on the given string"
61
+ fails "String#to_c returns a Complex object"
62
+ fails "String#to_c understands integers"
63
+ fails "String#to_c understands negative integers"
64
+ fails "String#to_c understands fractions (numerator/denominator) for the real part"
65
+ fails "String#to_c understands fractions (numerator/denominator) for the imaginary part"
66
+ fails "String#to_c understands negative fractions (-numerator/denominator) for the real part"
67
+ fails "String#to_c understands negative fractions (-numerator/denominator) for the imaginary part"
68
+ fails "String#to_c understands floats (a.b) for the real part"
69
+ fails "String#to_c understands floats (a.b) for the imaginary part"
70
+ fails "String#to_c understands negative floats (-a.b) for the real part"
71
+ fails "String#to_c understands negative floats (-a.b) for the imaginary part"
72
+ fails "String#to_c understands an integer followed by 'i' to mean that integer is the imaginary part"
73
+ fails "String#to_c understands a negative integer followed by 'i' to mean that negative integer is the imaginary part"
74
+ fails "String#to_c understands an 'i' by itself as denoting a complex number with an imaginary part of 1"
75
+ fails "String#to_c understands a '-i' by itself as denoting a complex number with an imaginary part of -1"
76
+ fails "String#to_c understands 'a+bi' to mean a complex number with 'a' as the real part, 'b' as the imaginary"
77
+ fails "String#to_c understands 'a-bi' to mean a complex number with 'a' as the real part, '-b' as the imaginary"
78
+ fails "String#to_c understands scientific notation for the real part"
79
+ fails "String#to_c understands negative scientific notation for the real part"
80
+ fails "String#to_c understands scientific notation for the imaginary part"
81
+ fails "String#to_c understands negative scientific notation for the imaginary part"
82
+ fails "String#to_c understands scientific notation for the real and imaginary part in the same String"
83
+ fails "String#to_c understands negative scientific notation for the real and imaginary part in the same String"
84
+ fails "String#to_c returns a complex number with 0 as the real part, 0 as the imaginary part for unrecognised Strings"
85
+
86
+ fails "String#to_r returns a Rational object"
87
+ fails "String#to_r returns (0/1) for the empty String"
88
+ fails "String#to_r returns (n/1) for a String starting with a decimal _n_"
89
+ fails "String#to_r ignores trailing characters"
90
+ fails "String#to_r ignores leading spaces"
91
+ fails "String#to_r does not ignore arbitrary, non-numeric leading characters"
92
+ fails "String#to_r treats leading hypens as minus signs"
93
+ fails "String#to_r does not treat a leading period without a numeric prefix as a decimal point"
94
+ fails "String#to_r understands decimal points"
95
+ fails "String#to_r ignores underscores between numbers"
96
+ fails "String#to_r understands a forward slash as separating the numerator from the denominator"
97
+ fails "String#to_r returns (0/1) for Strings it can't parse"
98
+
99
+ fails "String#dump taints the result if self is tainted"
100
+ fails "String#dump untrusts the result if self is untrusted"
101
+ fails "String#dump returns a subclass instance"
102
+ fails "String#dump returns a string with special characters replaced with \\<char> notation"
103
+ fails "String#dump returns a string with \" and \\ escaped with a backslash"
104
+ fails "String#dump returns a string with \\#<char> when # is followed by $, @, {"
105
+ fails "String#dump returns a string with # not escaped when followed by any other character"
106
+ fails "String#dump returns a string with printable non-alphanumeric characters unescaped"
107
+ fails "String#dump returns a string with numeric characters unescaped"
108
+ fails "String#dump returns a string with upper-case alpha characters unescaped"
109
+ fails "String#dump returns a string with lower-case alpha characters unescaped"
110
+ fails "String#dump returns a string with non-printing ASCII characters replaced by \\x notation"
111
+ fails "String#dump returns a string with non-printing single-byte UTF-8 characters replaced by \\x notation"
112
+ fails "String#dump returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits"
113
+ fails "String#dump includes .force_encoding(name) if the encoding isn't ASCII compatible"
360
114
  end