opal 1.8.0.alpha1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +1 -0
  3. data/CHANGELOG.md +119 -2
  4. data/README.md +7 -7
  5. data/UNRELEASED.md +1 -78
  6. data/docs/releasing.md +8 -16
  7. data/lib/opal/cli_runners/chrome.rb +5 -1
  8. data/lib/opal/nodes/closure.rb +15 -7
  9. data/lib/opal/nodes/defined.rb +1 -1
  10. data/lib/opal/nodes/literal.rb +10 -6
  11. data/lib/opal/nodes/rescue.rb +1 -1
  12. data/lib/opal/simple_server.rb +2 -2
  13. data/lib/opal/version.rb +1 -1
  14. data/opal/corelib/array.rb +39 -21
  15. data/opal/corelib/class.rb +26 -8
  16. data/opal/corelib/complex.rb +1 -1
  17. data/opal/corelib/constants.rb +2 -2
  18. data/opal/corelib/enumerator/arithmetic_sequence.rb +1 -1
  19. data/opal/corelib/error.rb +10 -0
  20. data/opal/corelib/hash.rb +36 -20
  21. data/opal/corelib/kernel.rb +0 -1
  22. data/opal/corelib/method.rb +1 -0
  23. data/opal/corelib/module.rb +82 -22
  24. data/opal/corelib/number.rb +28 -1
  25. data/opal/corelib/range.rb +55 -11
  26. data/opal/corelib/rational.rb +1 -1
  27. data/opal/corelib/runtime.js +132 -50
  28. data/opal/corelib/string.rb +36 -8
  29. data/opal/corelib/struct.rb +1 -1
  30. data/opal/corelib/time.rb +1 -1
  31. data/spec/filters/bugs/array.rb +58 -0
  32. data/spec/filters/bugs/basicobject.rb +7 -0
  33. data/spec/filters/bugs/bigdecimal.rb +1 -2
  34. data/spec/filters/bugs/binding.rb +1 -0
  35. data/spec/filters/bugs/cgi.rb +40 -0
  36. data/spec/filters/bugs/class.rb +2 -3
  37. data/spec/filters/bugs/complex.rb +3 -0
  38. data/spec/filters/bugs/date.rb +5 -2
  39. data/spec/filters/bugs/datetime.rb +1 -0
  40. data/spec/filters/bugs/delegate.rb +1 -2
  41. data/spec/filters/bugs/encoding.rb +1 -1
  42. data/spec/filters/bugs/enumerable.rb +11 -0
  43. data/spec/filters/bugs/enumerator.rb +15 -2
  44. data/spec/filters/bugs/exception.rb +9 -4
  45. data/spec/filters/bugs/file.rb +2 -0
  46. data/spec/filters/bugs/float.rb +1 -0
  47. data/spec/filters/bugs/freeze.rb +5 -49
  48. data/spec/filters/bugs/hash.rb +1 -0
  49. data/spec/filters/bugs/integer.rb +5 -6
  50. data/spec/filters/bugs/kernel.rb +12 -6
  51. data/spec/filters/bugs/language.rb +33 -15
  52. data/spec/filters/bugs/marshal.rb +63 -4
  53. data/spec/filters/bugs/method.rb +2 -13
  54. data/spec/filters/bugs/module.rb +19 -17
  55. data/spec/filters/bugs/objectspace.rb +2 -0
  56. data/spec/filters/bugs/pathname.rb +1 -0
  57. data/spec/filters/bugs/proc.rb +4 -2
  58. data/spec/filters/bugs/random.rb +0 -3
  59. data/spec/filters/bugs/range.rb +3 -17
  60. data/spec/filters/bugs/rational.rb +2 -0
  61. data/spec/filters/bugs/refinement.rb +19 -0
  62. data/spec/filters/bugs/regexp.rb +27 -5
  63. data/spec/filters/bugs/ruby-32.rb +0 -4
  64. data/spec/filters/bugs/set.rb +10 -2
  65. data/spec/filters/bugs/singleton.rb +0 -2
  66. data/spec/filters/bugs/string.rb +140 -1
  67. data/spec/filters/bugs/struct.rb +15 -5
  68. data/spec/filters/bugs/time.rb +56 -2
  69. data/spec/filters/bugs/trace_point.rb +1 -0
  70. data/spec/filters/bugs/unboundmethod.rb +4 -9
  71. data/spec/filters/bugs/warnings.rb +0 -1
  72. data/spec/filters/platform/firefox/exception.rb +3 -3
  73. data/spec/filters/platform/firefox/kernel.rb +1 -0
  74. data/spec/filters/platform/safari/exception.rb +2 -2
  75. data/spec/filters/platform/safari/float.rb +1 -0
  76. data/spec/filters/platform/safari/kernel.rb +1 -0
  77. data/spec/filters/platform/safari/literal_regexp.rb +2 -2
  78. data/spec/filters/unsupported/hash.rb +1 -1
  79. data/spec/lib/compiler_spec.rb +4 -0
  80. data/spec/opal/core/class/clone_spec.rb +36 -0
  81. data/spec/opal/core/module/define_method_spec.rb +29 -0
  82. data/spec/opal/core/object_id_spec.rb +0 -6
  83. data/spec/opal/language/predefined_spec.rb +20 -0
  84. data/spec/opal/language/yield_spec.rb +43 -0
  85. data/spec/ruby_specs +1 -2
  86. data/stdlib/bigdecimal.rb +2 -0
  87. data/stdlib/cgi/util.rb +89 -0
  88. data/stdlib/cgi.rb +1 -14
  89. data/stdlib/delegate.rb +3 -4
  90. data/stdlib/pathname.rb +1 -1
  91. data/stdlib/promise/v2.rb +22 -7
  92. data/stdlib/stringio.rb +2 -0
  93. data/tasks/testing.rake +15 -11
  94. data/test/opal/promisev2/test_always.rb +14 -0
  95. data/test/opal/unsupported_and_bugs.rb +0 -8
  96. metadata +16 -8
@@ -2,14 +2,24 @@
2
2
  opal_filter "Struct" do
3
3
  fails "Struct#dig returns the value by the index" # Expected nil == "one" to be truthy but was false
4
4
  fails "Struct#hash returns different hashes for structs with different values when using keyword_init: true" # NameError: wrong constant name 1 non symbol member
5
- fails "Struct#hash returns the same integer for structs with the same content" # Expected "Hash" (String) to be kind of Integer
6
- fails "Struct#initialize warns about passing only keyword arguments" # Expected warning to match: /warning: Passing only keyword arguments/ but got: ""
5
+ fails "Struct#initialize can be initialized with keyword arguments" # Expected "3.2" == {"version"=>"3.2", "platform"=>"OS"} to be truthy but was false
6
+ fails "Struct#inspect does not call #name method when struct is anonymous" # Expected "#<struct #<Class:0x55d36> a=\"\">" == "#<struct a=\"\">" to be truthy but was false
7
7
  fails "Struct#to_h with block converts [key, value] pairs returned by the block to a hash" # Expected {"Ford"=>"", "Ranger"=>"", ""=>""} == {"make"=>"ford", "model"=>"ranger", "year"=>""} to be truthy but was false
8
- fails "Struct-based class#dup retains an included module in the ancestor chain for the struct's singleton class" # NoMethodError: undefined method `hello' for #<Module:0x776e4>
8
+ fails "Struct#to_s does not call #name method when struct is anonymous" # Expected "#<struct #<Class:0x29fd6> a=\"\">" == "#<struct a=\"\">" to be truthy but was false
9
+ fails "Struct#values_at supports mixing of names and indices" # TypeError: no implicit conversion of String into Integer
10
+ fails "Struct#values_at when passed a list of Integers returns nil value for any integer that is out of range" # Exception: Cannot read properties of undefined (reading '$$is_array')
11
+ fails "Struct#values_at when passed an integer Range fills with nil values for range elements larger than the captured values number" # Exception: Cannot read properties of undefined (reading '$$is_array')
12
+ fails "Struct#values_at when passed an integer Range fills with nil values for range elements larger than the structure" # IndexError: offset 3 too large for struct(size:3)
13
+ fails "Struct#values_at when passed an integer Range raises RangeError if any element of the range is negative and out of range" # Expected RangeError (-4..3 out of range) but got: IndexError (offset -4 too small for struct(size:3))
14
+ fails "Struct#values_at when passed an integer Range returns an empty Array when Range is empty" # Exception: Cannot read properties of undefined (reading '$$is_number')
15
+ fails "Struct#values_at when passed an integer Range supports endless Range" # TypeError: cannot convert endless range to an array
16
+ fails "Struct#values_at when passed names slices captures with the given String names" # TypeError: no implicit conversion of String into Integer
17
+ fails "Struct#values_at when passed names slices captures with the given names" # TypeError: no implicit conversion of String into Integer
9
18
  fails "Struct.new keyword_init: true option raises when there is a duplicate member" # Expected ArgumentError (duplicate member: foo) but no exception was raised (#<Class:0x76a42> was returned)
10
19
  fails "Struct.new raises ArgumentError when there is a duplicate member" # Expected ArgumentError (duplicate member: foo) but no exception was raised (#<Class:0x769fa> was returned)
11
- fails "Struct.new raises a TypeError or ArgumentError if passed a Hash with an unknown key" # Expected StandardError but no exception was raised (#<Class:0x76a0a> was returned)
12
- fails "StructClass#keyword_init? returns nil for a struct that did not explicitly specify keyword_init" # Expected false to be nil
20
+ fails "StructClass#keyword_init? returns nil for a struct that did not explicitly specify keyword_init" # Expected false to be nil
21
+ fails "StructClass#keyword_init? returns true for any truthy value, not just for true" # Expected 1 to be true
13
22
  fails_badly "Struct#hash returns different hashes for different struct classes" # A failure in Chromium that once passes, other times it doesn't, most probably related to some kind of undeterminism.
14
23
  fails_badly "Struct#hash returns different hashes for structs with different values" # Ditto
24
+ fails_badly "Struct#values_at when passed an integer Range supports beginningless Range" # TypeError: cannot convert endless range to an array
15
25
  end
@@ -10,6 +10,13 @@ opal_filter "Time" do
10
10
  fails "Time#ceil copies own timezone to the returning value" # NoMethodError: undefined method `ceil' for 2010-03-30 05:43:25 UTC
11
11
  fails "Time#ceil defaults to ceiling to 0 places" # NoMethodError: undefined method `ceil' for 2010-03-30 05:43:25 UTC
12
12
  fails "Time#ceil returns an instance of Time, even if #ceil is called on a subclass" # Expected Time to be identical to #<Class:0xa40e6>
13
+ fails "Time#deconstruct_keys ignores non-Symbol keys" # NoMethodError: undefined method `deconstruct_keys' for 2022-10-05 13:30:00 +0200
14
+ fails "Time#deconstruct_keys ignores not existing Symbol keys" # NoMethodError: undefined method `deconstruct_keys' for 2022-10-05 13:30:00 +0200
15
+ fails "Time#deconstruct_keys it raises error when argument is neither nil nor array" # Expected TypeError (wrong argument type Integer (expected Array or nil)) but got: NoMethodError (undefined method `deconstruct_keys' for 2022-10-05 13:30:00 +0200)
16
+ fails "Time#deconstruct_keys requires one argument" # Expected ArgumentError but got: NoMethodError (undefined method `deconstruct_keys' for 2022-10-05 13:30:00 +0200)
17
+ fails "Time#deconstruct_keys returns only specified keys" # NoMethodError: undefined method `deconstruct_keys' for 2022-10-05 13:39:00 UTC
18
+ fails "Time#deconstruct_keys returns whole hash for nil as an argument" # NoMethodError: undefined method `deconstruct_keys' for 2022-10-05 13:30:00 UTC
19
+ fails "Time#deconstruct_keys returns {} when passed []" # NoMethodError: undefined method `deconstruct_keys' for 2022-10-05 13:30:00 +0200
13
20
  fails "Time#dup returns a clone of Time instance" # NoMethodError: undefined method `now' for #<Module:0x133b8>
14
21
  fails "Time#floor copies own timezone to the returning value" # NoMethodError: undefined method `floor' for 2010-03-30 05:43:25 UTC
15
22
  fails "Time#floor defaults to flooring to 0 places" # NoMethodError: undefined method `floor' for 2010-03-30 05:43:25 UTC
@@ -24,19 +31,22 @@ opal_filter "Time" do
24
31
  fails "Time#getlocal with a timezone argument subject's class implements .find_timezone method calls .find_timezone to build a time object if passed zone name as a timezone argument" # NoMethodError: undefined method `getlocal' for 2000-01-01 12:00:00 UTC
25
32
  fails "Time#getlocal with a timezone argument subject's class implements .find_timezone method does not call .find_timezone if passed any not string/numeric/timezone timezone argument" # Expected TypeError (/can't convert \w+ into an exact number/) but got: NoMethodError (undefined method `getlocal' for 2000-01-01 12:00:00 UTC)
26
33
  fails "Time#gmtime converts self to UTC, modifying the receiver" # Expected 2007-01-09 05:00:00 UTC == 2007-01-09 12:00:00 UTC to be truthy but was false
27
- fails "Time#hash returns an Integer" # Expected "Time:100000" (String) to be an instance of Integer
28
34
  fails "Time#inspect omits trailing zeros from microseconds" # Expected "2007-11-01 15:25:00 UTC" == "2007-11-01 15:25:00.1 UTC" to be truthy but was false
29
35
  fails "Time#inspect preserves microseconds" # Expected "2007-11-01 15:25:00 UTC" == "2007-11-01 15:25:00.123456 UTC" to be truthy but was false
30
36
  fails "Time#inspect preserves nanoseconds" # Expected "2007-11-01 15:25:00 UTC" == "2007-11-01 15:25:00.123456789 UTC" to be truthy but was false
31
37
  fails "Time#inspect uses the correct time zone with microseconds" # NoMethodError: undefined method `localtime' for 2000-01-01 00:00:00 UTC
32
38
  fails "Time#inspect uses the correct time zone without microseconds" # NoMethodError: undefined method `localtime' for 2000-01-01 00:00:00 UTC
39
+ fails "Time#localtime on a frozen time raises a FrozenError if the time has a different time zone" # Expected FrozenError but got: NoMethodError (undefined method `localtime' for 2007-01-09 12:00:00 UTC)
33
40
  fails "Time#localtime raises ArgumentError if the String argument is not in an ASCII-compatible encoding" # Expected ArgumentError but got: NoMethodError (undefined method `localtime' for 2022-12-07 05:21:43 +0100)
41
+ fails "Time#localtime returns a Time with a UTC offset specified as A-Z military zone" # NoMethodError: undefined method `localtime' for 2007-01-09 12:00:00 +0100
42
+ fails "Time#localtime returns a Time with a UTC offset specified as UTC" # NoMethodError: undefined method `localtime' for 2007-01-09 12:00:00 +0100
34
43
  fails "Time#nsec returns a positive value for dates before the epoch" # NoMethodError: undefined method `nsec' for 1969-11-12 13:18:57 UTC
35
44
  fails "Time#round copies own timezone to the returning value" # NoMethodError: undefined method `round' for 2010-03-30 05:43:25 UTC
36
45
  fails "Time#round defaults to rounding to 0 places" # NoMethodError: undefined method `round' for 2010-03-30 05:43:25 UTC
37
46
  fails "Time#round returns an instance of Time, even if #round is called on a subclass" # Expected Time to be identical to #<Class:0x5990a>
38
47
  fails "Time#round rounds to 0 decimal places with an explicit argument" # NoMethodError: undefined method `round' for 2010-03-30 05:43:25 UTC
39
48
  fails "Time#round rounds to 7 decimal places with an explicit argument" # NoMethodError: undefined method `round' for 2010-03-30 05:43:25 UTC
49
+ fails "Time#strftime applies '-' flag to UTC time" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: Z
40
50
  fails "Time#strftime rounds an offset to the nearest second when formatting with %z" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
41
51
  fails "Time#strftime should be able to print the commercial year with leading zeroes" # Expected "200" == "0200" to be truthy but was false
42
52
  fails "Time#strftime should be able to print the commercial year with only two digits" # TypeError: no implicit conversion of Range into Integer
@@ -51,6 +61,7 @@ opal_filter "Time" do
51
61
  fails "Time#strftime with %N formats the nanoseconds of the second with %9N" # Expected "000000000" == "001234000" to be truthy but was false
52
62
  fails "Time#strftime with %N formats the nanoseconds of the second with %N" # Expected "000000000" == "001234560" to be truthy but was false
53
63
  fails "Time#strftime with %N formats the picoseconds of the second with %12N" # Expected "000000000000" == "999999999999" to be truthy but was false
64
+ fails "Time#strftime works correctly with width, _ and 0 flags, and :" # Expected "-0000" == " -000" to be truthy but was false
54
65
  fails "Time#subsec returns 0 as an Integer for a Time with a whole number of seconds" # NoMethodError: undefined method `subsec' for 1970-01-01 01:01:40 +0100
55
66
  fails "Time#to_date yields accurate julian date for Julian-Gregorian gap value" # Expected 2299170 == 2299160 to be truthy but was false
56
67
  fails "Time#to_date yields accurate julian date for ambiguous pre-Gregorian reform value" # Expected 2299160 == 2299150 to be truthy but was false
@@ -62,9 +73,17 @@ opal_filter "Time" do
62
73
  fails "Time#tv_sec rounds fractional seconds toward zero" # Expected -315619200 == -315619199 to be truthy but was false
63
74
  fails "Time#usec returns a positive value for dates before the epoch" # Expected 0 == 404240 to be truthy but was false
64
75
  fails "Time#utc converts self to UTC, modifying the receiver" # Expected 2007-01-09 05:00:00 UTC == 2007-01-09 12:00:00 UTC to be truthy but was false
76
+ fails "Time#utc? does not treat time with +00:00 offset as UTC" # Expected true == false to be truthy but was false
77
+ fails "Time#utc? does not treat time with 0 offset as UTC" # Expected true == false to be truthy but was false
78
+ fails "Time#utc? does treat time with 'UTC' offset as UTC" # NoMethodError: undefined method `localtime' for 2023-09-20 22:52:11 +0200
79
+ fails "Time#utc? does treat time with -00:00 offset as UTC" # NoMethodError: undefined method `localtime' for 2023-09-20 22:52:11 +0200
80
+ fails "Time#utc? does treat time with Z offset as UTC" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: Z
65
81
  fails "Time#zone Encoding.default_internal is set returns an ASCII string" # NoMethodError: undefined method `default_internal' for Encoding
66
82
  fails "Time#zone defaults to UTC when bad zones given" # Expected 3600 == 0 to be truthy but was false
83
+ fails "Time#zone returns UTC when called on a UTC time" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: Z
84
+ fails "Time.at :in keyword argument could be UTC offset as a 'UTC' String" # TypeError: no implicit conversion of Hash into Integer
67
85
  fails "Time.at :in keyword argument could be UTC offset as a String in '+HH:MM or '-HH:MM' format" # TypeError: no implicit conversion of Hash into Integer
86
+ fails "Time.at :in keyword argument could be UTC offset as a military zone A-Z" # TypeError: no implicit conversion of Hash into Integer
68
87
  fails "Time.at :in keyword argument could be UTC offset as a number of seconds" # TypeError: no implicit conversion of Hash into Integer
69
88
  fails "Time.at :in keyword argument could be a timezone object" # TypeError: no implicit conversion of Hash into Integer
70
89
  fails "Time.at :in keyword argument raises ArgumentError if format is invalid" # Expected ArgumentError but got: TypeError (no implicit conversion of Hash into Integer)
@@ -81,21 +100,45 @@ opal_filter "Time" do
81
100
  fails "Time.at passed non-Time, non-Numeric with an argument that responds to #to_r needs for the argument to respond to #to_int too" # Mock 'rational-but-no-to_int' expected to receive to_r("any_args") exactly 1 times but received it 0 times
82
101
  fails "Time.gm handles fractional usec close to rounding limit" # NoMethodError: undefined method `nsec' for 2000-01-01 12:30:00 UTC
83
102
  fails "Time.gm raises an ArgumentError for out of range microsecond" # Expected ArgumentError but no exception was raised (2000-01-01 20:15:01 UTC was returned)
103
+ fails "Time.gm raises an ArgumentError for out of range month" # Expected ArgumentError (/(mon|argument) out of range/) but got: ArgumentError (month out of range: 16)
104
+ fails "Time.gm raises an ArgumentError for out of range second" # Expected ArgumentError (argument out of range) but got: ArgumentError (sec out of range: -1)
84
105
  fails "Time.httpdate parses RFC-2616 strings" # NoMethodError: undefined method `httpdate' for Time
85
106
  fails "Time.local raises an ArgumentError for out of range microsecond" # Expected ArgumentError but no exception was raised (2000-01-01 20:15:01 +0100 was returned)
107
+ fails "Time.local raises an ArgumentError for out of range month" # Expected ArgumentError (/(mon|argument) out of range/) but got: ArgumentError (month out of range: 16)
108
+ fails "Time.local raises an ArgumentError for out of range second" # Expected ArgumentError (argument out of range) but got: ArgumentError (sec out of range: -1)
86
109
  fails "Time.local uses the 'CET' timezone with TZ=Europe/Amsterdam in 1970" # Expected [0, 0, 0, 16, 5, 1970, 6, 136, false, "Central European Standard Time"] == [0, 0, 0, 16, 5, 1970, 6, 136, false, "CET"] to be truthy but was false
87
110
  fails "Time.mktime raises an ArgumentError for out of range microsecond" # Expected ArgumentError but no exception was raised (2000-01-01 20:15:01 +0100 was returned)
111
+ fails "Time.mktime raises an ArgumentError for out of range month" # Expected ArgumentError (/(mon|argument) out of range/) but got: ArgumentError (month out of range: 16)
112
+ fails "Time.mktime raises an ArgumentError for out of range second" # Expected ArgumentError (argument out of range) but got: ArgumentError (sec out of range: -1)
88
113
  fails "Time.mktime uses the 'CET' timezone with TZ=Europe/Amsterdam in 1970" # Expected [0, 0, 0, 16, 5, 1970, 6, 136, false, "Central European Standard Time"] == [0, 0, 0, 16, 5, 1970, 6, 136, false, "CET"] to be truthy but was false
89
114
  fails "Time.new has at least microsecond precision" # NoMethodError: undefined method `nsec' for 2022-12-07 05:20:59 +0100
115
+ fails "Time.new raises an ArgumentError for out of range month" # Expected ArgumentError (/(mon|argument) out of range/) but got: ArgumentError (month out of range: 16)
116
+ fails "Time.new raises an ArgumentError for out of range second" # Expected ArgumentError (argument out of range) but got: ArgumentError (sec out of range: -1)
90
117
  fails "Time.new uses the 'CET' timezone with TZ=Europe/Amsterdam in 1970" # Expected [0, 0, 0, 16, 5, 1970, 6, 136, false, "Central European Standard Time"] == [0, 0, 0, 16, 5, 1970, 6, 136, false, "CET"] to be truthy but was false
91
118
  fails "Time.new uses the local timezone" # Expected 3600 == -28800 to be truthy but was false
92
119
  fails "Time.new with a timezone argument #name method cannot marshal Time if #name method isn't implemented" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
93
120
  fails "Time.new with a timezone argument #name method uses the optional #name method for marshaling" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
121
+ fails "Time.new with a timezone argument :in keyword argument allows omitting minor arguments" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
122
+ fails "Time.new with a timezone argument :in keyword argument converts to a provided timezone if all the positional arguments are omitted" # TypeError: no implicit conversion of Hash into Integer
94
123
  fails "Time.new with a timezone argument :in keyword argument could be UTC offset as a String in '+HH:MM or '-HH:MM' format" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
95
124
  fails "Time.new with a timezone argument :in keyword argument could be UTC offset as a number of seconds" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
96
125
  fails "Time.new with a timezone argument :in keyword argument could be a timezone object" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
126
+ fails "Time.new with a timezone argument :in keyword argument raises ArgumentError if two offset arguments are given" # Expected ArgumentError (timezone argument given as positional and keyword arguments) but got: ArgumentError ([Time.new] wrong number of arguments (given 8, expected -1))
127
+ fails "Time.new with a timezone argument :in keyword argument returns a Time with UTC offset specified as a single letter military timezone" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
97
128
  fails "Time.new with a timezone argument Time-like argument of #utc_to_local and #local_to_utc methods has attribute values the same as a Time object in UTC" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
98
129
  fails "Time.new with a timezone argument Time-like argument of #utc_to_local and #local_to_utc methods implements subset of Time methods" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
130
+ fails "Time.new with a timezone argument Time.new with a String argument accepts precision keyword argument and truncates specified digits of sub-second part" # NoMethodError: undefined method `subsec' for 2021-01-01 00:00:00 +0100
131
+ fails "Time.new with a timezone argument Time.new with a String argument converts precision keyword argument into Integer if is not nil" # TypeError: no implicit conversion of Hash into Integer
132
+ fails "Time.new with a timezone argument Time.new with a String argument parses an ISO-8601 like format" # Expected 2020-01-01 00:00:00 +0100 == 2020-12-24 15:56:17 UTC to be truthy but was false
133
+ fails "Time.new with a timezone argument Time.new with a String argument raise TypeError is can't convert precision keyword argument into Integer" # Expected TypeError (no implicit conversion from string) but got: TypeError (no implicit conversion of Hash into Integer)
134
+ fails "Time.new with a timezone argument Time.new with a String argument raises ArgumentError if String argument is not in the supported format" # Expected ArgumentError (year must be 4 or more digits: 021) but no exception was raised (21-01-01 00:00:00 +0124 was returned)
135
+ fails "Time.new with a timezone argument Time.new with a String argument raises ArgumentError if date/time parts values are not valid" # Expected ArgumentError (mon out of range) but no exception was raised (2020-01-01 00:00:00 +0100 was returned)
136
+ fails "Time.new with a timezone argument Time.new with a String argument raises ArgumentError if part of time string is missing" # Expected ArgumentError (missing sec part: 00:56 ) but no exception was raised (2020-01-01 00:00:00 +0100 was returned)
137
+ fails "Time.new with a timezone argument Time.new with a String argument raises ArgumentError if string has not ascii-compatible encoding" # Expected ArgumentError (time string should have ASCII compatible encoding) but no exception was raised (2021-01-01 00:00:00 +0100 was returned)
138
+ fails "Time.new with a timezone argument Time.new with a String argument raises ArgumentError if subsecond is missing after dot" # Expected ArgumentError (subsecond expected after dot: 00:56:17. ) but no exception was raised (2020-01-01 00:00:00 +0100 was returned)
139
+ fails "Time.new with a timezone argument Time.new with a String argument returns Time in timezone specified in the String argument even if the in keyword argument provided" # TypeError: no implicit conversion of Hash into Integer
140
+ fails "Time.new with a timezone argument Time.new with a String argument returns Time in timezone specified in the String argument" # Expected "2021-01-01 00:00:00 +0100" == "2021-12-25 00:00:00 +0500" to be truthy but was false
141
+ fails "Time.new with a timezone argument Time.new with a String argument returns Time in timezone specified with in keyword argument if timezone isn't provided in the String argument" # TypeError: no implicit conversion of Hash into Integer
99
142
  fails "Time.new with a timezone argument accepts timezone argument that must have #local_to_utc and #utc_to_local methods" # Expected to not get Exception but got: ArgumentError (Opal doesn't support other types for a timezone argument than Integer and String)
100
143
  fails "Time.new with a timezone argument does not raise exception if timezone does not implement #utc_to_local method" # Expected to not get Exception but got: ArgumentError (Opal doesn't support other types for a timezone argument than Integer and String)
101
144
  fails "Time.new with a timezone argument raises TypeError if timezone does not implement #local_to_utc method" # Expected TypeError (/can't convert \w+ into an exact number/) but got: ArgumentError (Opal doesn't support other types for a timezone argument than Integer and String)
@@ -110,12 +153,20 @@ opal_filter "Time" do
110
153
  fails "Time.new with a timezone argument subject's class implements .find_timezone method does not call .find_timezone if passed any not string/numeric/timezone timezone argument" # Expected TypeError (/can't convert \w+ into an exact number/) but got: ArgumentError (Opal doesn't support other types for a timezone argument than Integer and String)
111
154
  fails "Time.new with a timezone argument the #abbr method is used by '%Z' in #strftime" # ArgumentError: Opal doesn't support other types for a timezone argument than Integer and String
112
155
  fails "Time.new with a utc_offset argument raises ArgumentError if the String argument is not in an ASCII-compatible encoding" # Expected ArgumentError but no exception was raised (2000-01-01 00:00:00 -0410.000000000000028 was returned)
113
- fails "Time.new with a utc_offset argument raises ArgumentError if the month is greater than 12" # Expected ArgumentError (/(mon|argument) out of range/) but got: ArgumentError (month out of range: 13)
156
+ fails "Time.new with a utc_offset argument raises ArgumentError if the string argument is J" # Expected ArgumentError ("+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: J) but got: ArgumentError ("+HH:MM", "-HH:MM", "UTC" expected for utc_offset: J)
114
157
  fails "Time.new with a utc_offset argument raises ArgumentError if the utc_offset argument is greater than or equal to 10e9" # Expected ArgumentError but no exception was raised (2000-01-01 00:00:00 +27777746.66666666418314 was returned)
158
+ fails "Time.new with a utc_offset argument returns a Time with UTC offset specified as a single letter military timezone" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: A
159
+ fails "Time.new with a utc_offset argument returns a Time with a UTC offset specified as +HH" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: +05
115
160
  fails "Time.new with a utc_offset argument returns a Time with a UTC offset specified as +HH:MM:SS" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: +05:30:37
161
+ fails "Time.new with a utc_offset argument returns a Time with a UTC offset specified as +HHMM" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: +0530
162
+ fails "Time.new with a utc_offset argument returns a Time with a UTC offset specified as +HHMMSS" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: +053037
163
+ fails "Time.new with a utc_offset argument returns a Time with a UTC offset specified as -HH" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: -05
164
+ fails "Time.new with a utc_offset argument returns a Time with a UTC offset specified as -HHMM" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: -0530
165
+ fails "Time.new with a utc_offset argument returns a Time with a UTC offset specified as -HHMMSS" # ArgumentError: "+HH:MM", "-HH:MM", "UTC" expected for utc_offset: -053037
116
166
  fails "Time.now :in keyword argument could be UTC offset as a String in '+HH:MM or '-HH:MM' format" # ArgumentError: [Time.now] wrong number of arguments (given 1, expected 0)
117
167
  fails "Time.now :in keyword argument could be UTC offset as a number of seconds" # ArgumentError: [Time.now] wrong number of arguments (given 1, expected 0)
118
168
  fails "Time.now :in keyword argument could be a timezone object" # ArgumentError: [Time.now] wrong number of arguments (given 1, expected 0)
169
+ fails "Time.now :in keyword argument returns a Time with UTC offset specified as a single letter military timezone" # ArgumentError: [Time.now] wrong number of arguments (given 1, expected 0)
119
170
  fails "Time.now has at least microsecond precision" # NoMethodError: undefined method `nsec' for 2022-12-07 05:21:38 +0100
120
171
  fails "Time.now uses the local timezone" # Expected 3600 == -28800 to be truthy but was false
121
172
  fails "Time.rfc2822 parses RFC-2822 strings" # NoMethodError: undefined method `rfc2822' for Time
@@ -124,9 +175,12 @@ opal_filter "Time" do
124
175
  fails "Time.rfc822 parses RFC-822 strings" # NoMethodError: undefined method `rfc2822' for Time
125
176
  fails "Time.utc handles fractional usec close to rounding limit" # NoMethodError: undefined method `nsec' for 2000-01-01 12:30:00 UTC
126
177
  fails "Time.utc raises an ArgumentError for out of range microsecond" # Expected ArgumentError but no exception was raised (2000-01-01 20:15:01 UTC was returned)
178
+ fails "Time.utc raises an ArgumentError for out of range month" # Expected ArgumentError (/(mon|argument) out of range/) but got: ArgumentError (month out of range: 16)
179
+ fails "Time.utc raises an ArgumentError for out of range second" # Expected ArgumentError (argument out of range) but got: ArgumentError (sec out of range: -1)
127
180
  fails "Time.xmlschema parses ISO-8601 strings" # NoMethodError: undefined method `xmlschema' for Time
128
181
  fails_badly "Time#dst? dst? returns whether time is during daylight saving time" # Expected false == true to be truthy but was false
129
182
  fails_badly "Time#isdst dst? returns whether time is during daylight saving time" # Expected false == true to be truthy but was false
130
183
  fails_badly "Time#strftime with %z formats a local time with positive UTC offset as '+HHMM'" # Expected "+0900" == "+0100" to be truthy but was false
131
184
  fails_badly "Time#yday returns an integer representing the day of the year, 1..366" # Expected 117 == 116 to be truthy but was false
185
+ fails_badly "Time.new with a timezone argument Time.new with a String argument returns Time in local timezone if not provided in the String argument" # Expected "Fiji Summer Time" == "Fiji Standard Time" to be truthy but was false
132
186
  end
@@ -8,5 +8,6 @@ opal_filter "TracePoint" do
8
8
  fails "TracePoint#inspect returns a String showing the event, path and line for a :class event" # Expected "#<TracePoint:0x89c86 @event=\"class\" @block=#<Proc:0x89c88> @trace_object=TracePointSpec::C @trace_evt=\"trace_class\" @tracers_for_evt=\"tracers_for_class\">" == "#<TracePoint:class ruby/core/tracepoint/inspect_spec.rb:87>" to be truthy but was false
9
9
  fails "TracePoint#inspect returns a String showing the event, path and line" # RuntimeError: Only the :class event is supported
10
10
  fails "TracePoint#inspect returns a string containing a human-readable TracePoint status" # RuntimeError: Only the :class event is supported
11
+ fails "TracePoint#inspect shows only whether it's enabled when outside the TracePoint handler" # RuntimeError: Only the :class event is supported
11
12
  fails "TracePoint#self return the trace object from event" # RuntimeError: Only the :class event is supported
12
13
  end
@@ -3,9 +3,12 @@ opal_filter "UnboundMethod" do
3
3
  fails "UnboundMethod#== considers methods through aliasing and visibility change equal" # Expected #<Method: Class#new (defined in Class in <internal:corelib/class.rb>:40)> == #<Method: Class#n (defined in #<Class:> in <internal:corelib/class.rb>:40)> to be truthy but was false
4
4
  fails "UnboundMethod#== considers methods through aliasing equal" # Expected #<Method: Class#new (defined in Class in <internal:corelib/class.rb>:40)> == #<Method: Class#n (defined in #<Class:> in <internal:corelib/class.rb>:40)> to be truthy but was false
5
5
  fails "UnboundMethod#== considers methods through visibility change equal" # Expected #<Method: Class#new (defined in Class in <internal:corelib/class.rb>:40)> == #<Method: Class#new (defined in Class in <internal:corelib/class.rb>:40)> to be truthy but was false
6
+ fails "UnboundMethod#== returns false if same method but extracted from two different subclasses" # Expected false == true to be truthy but was false
6
7
  fails "UnboundMethod#== returns true if both are aliases for a third method" # Expected false == true to be truthy but was false
7
8
  fails "UnboundMethod#== returns true if either is an alias for the other" # Expected false == true to be truthy but was false
9
+ fails "UnboundMethod#== returns true if methods are the same but added from an included Module" # Expected false == true to be truthy but was false
8
10
  fails "UnboundMethod#== returns true if objects refer to the same method" # Expected false == true to be truthy but was false
11
+ fails "UnboundMethod#== returns true if same method but one extracted from a subclass" # Expected false == true to be truthy but was false
9
12
  fails "UnboundMethod#== returns true if same method is extracted from the same subclass" # Expected false == true to be truthy but was false
10
13
  fails "UnboundMethod#arity for a Method generated by respond_to_missing? returns -1" # Mock 'method arity respond_to_missing' expected to receive respond_to_missing?("any_args") exactly 1 times but received it 0 times
11
14
  fails "UnboundMethod#bind the returned Method is equal to the one directly returned by obj.method" # Expected #<Method: UnboundMethodSpecs::Methods#foo (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:30)> == #<Method: UnboundMethodSpecs::Methods#foo (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:30)> to be truthy but was false
@@ -17,16 +20,8 @@ opal_filter "UnboundMethod" do
17
20
  fails "UnboundMethod#original_name returns the name of the method" # NoMethodError: undefined method `original_name' for #<UnboundMethod: String#upcase (defined in String in <internal:corelib/string.rb>:1685)>
18
21
  fails "UnboundMethod#original_name returns the original name even when aliased twice" # NoMethodError: undefined method `original_name' for #<UnboundMethod: UnboundMethodSpecs::Methods#foo (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:30)>
19
22
  fails "UnboundMethod#original_name returns the original name" # NoMethodError: undefined method `original_name' for #<UnboundMethod: UnboundMethodSpecs::Methods#foo (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:30)>
20
- fails "UnboundMethod#private? returns false when the method is protected" # NoMethodError: undefined method `private?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_protected_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:58)>
21
- fails "UnboundMethod#private? returns false when the method is public" # NoMethodError: undefined method `private?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_public_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:57)>
22
- fails "UnboundMethod#private? returns true when the method is private" # NoMethodError: undefined method `private?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_private_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:59)>
23
- fails "UnboundMethod#protected? returns false when the method is private" # NoMethodError: undefined method `protected?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_private_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:59)>
24
- fails "UnboundMethod#protected? returns false when the method is public" # NoMethodError: undefined method `protected?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_public_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:57)>
25
- fails "UnboundMethod#protected? returns true when the method is protected" # NoMethodError: undefined method `protected?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_protected_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:58)>
26
- fails "UnboundMethod#public? returns false when the method is private" # NoMethodError: undefined method `public?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_private_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:59)>
27
- fails "UnboundMethod#public? returns false when the method is protected" # NoMethodError: undefined method `public?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_protected_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:58)>
28
- fails "UnboundMethod#public? returns true when the method is public" # NoMethodError: undefined method `public?' for #<UnboundMethod: UnboundMethodSpecs::Methods#my_public_method (defined in UnboundMethodSpecs::Methods in ruby/core/unboundmethod/fixtures/classes.rb:57)>
29
23
  fails "UnboundMethod#source_location sets the first value to the path of the file in which the method was defined" # Expected "ruby/core/unboundmethod/fixtures/classes.rb" == "./ruby/core/unboundmethod/fixtures/classes.rb" to be truthy but was false
24
+ fails "UnboundMethod#source_location works for eval with a given line" # Expected ["(eval)", 0] == ["foo", 100] to be truthy but was false
30
25
  fails "UnboundMethod#super_method after aliasing an inherited method returns the expected super_method" # NoMethodError: undefined method `super_method' for #<UnboundMethod: MethodSpecs::InheritedMethods::C#meow (defined in MethodSpecs::InheritedMethods::C in ruby/core/method/fixtures/classes.rb:233)>
31
26
  fails "UnboundMethod#super_method after changing an inherited methods visibility returns the expected super_method" # NoMethodError: undefined method `super_method' for #<UnboundMethod: MethodSpecs::InheritedMethods::C#derp (defined in MethodSpecs::InheritedMethods::B in ruby/core/method/fixtures/classes.rb:233)>
32
27
  fails "UnboundMethod#super_method returns nil when the parent's method is removed" # NoMethodError: undefined method `super_method' for #<UnboundMethod: #<Class:0x4b228>#foo (defined in #<Class:0x4b228> in ruby/core/unboundmethod/super_method_spec.rb:21)>
@@ -3,7 +3,6 @@ opal_filter "warnings" do
3
3
  fails "Array#join when $, is not nil warns" # Expected warning to match: /warning: \$, is set to non-nil value/ but got: ""
4
4
  fails "Constant resolution within methods with dynamically assigned constants returns the updated value when a constant is reassigned" # Expected warning to match: /already initialized constant/ but got: ""
5
5
  fails "Hash#fetch gives precedence to the default block over the default argument when passed both" # Expected warning to match: /block supersedes default value argument/ but got: ""
6
- fails "Kernel#=~ is deprecated" # Expected warning to match: /deprecated Object#=~ is called on Object/ but got: ""
7
6
  fails "Literal (A::X) constant resolution with dynamically assigned constants returns the updated value when a constant is reassigned" # Expected warning to match: /already initialized constant/ but got: ""
8
7
  fails "Literal Regexps matches against $_ (last input) in a conditional if no explicit matchee provided" # Expected warning to match: /regex literal in condition/ but got: ""
9
8
  fails "Module#const_get with dynamically assigned constants returns the updated value of a constant" # Expected warning to match: /already initialized constant/ but got: ""
@@ -1,8 +1,8 @@
1
- # Source map support currently is only available for Chrome and Nodejs
1
+ # NOTE: run bin/format-filters after changing this file
2
2
  opal_unsupported_filter "Exception" do
3
- fails "Exception#backtrace_locations sets each element to a Thread::Backtrace::Location"
4
3
  fails "Exception#backtrace contains lines of the same format for each prior position in the stack"
5
4
  fails "Exception#backtrace sets each element to a String"
6
- fails "Invoking a method when the method is not available should omit the method_missing call from the backtrace for NoMethodError"
5
+ fails "Exception#backtrace_locations sets each element to a Thread::Backtrace::Location"
7
6
  fails "Invoking a method when the method is not available should omit the method_missing call from the backtrace for NameError"
7
+ fails "Invoking a method when the method is not available should omit the method_missing call from the backtrace for NoMethodError"
8
8
  end
@@ -1,3 +1,4 @@
1
+ # NOTE: run bin/format-filters after changing this file
1
2
  opal_unsupported_filter "Kernel" do
2
3
  fails "Kernel#caller includes core library methods defined in Ruby"
3
4
  end
@@ -1,8 +1,8 @@
1
- # Source map support currently is only available for Chrome and Nodejs
1
+ # NOTE: run bin/format-filters after changing this file
2
2
  opal_unsupported_filter "Exception" do
3
3
  fails "Exception#backtrace contains lines of the same format for each prior position in the stack"
4
- fails "Exception#backtrace_locations sets each element to a Thread::Backtrace::Location"
5
4
  fails "Exception#backtrace returns an Array that can be updated"
6
5
  fails "Exception#backtrace returns the same array after duping"
7
6
  fails "Exception#backtrace sets each element to a String"
7
+ fails "Exception#backtrace_locations sets each element to a Thread::Backtrace::Location"
8
8
  end
@@ -1,3 +1,4 @@
1
+ # NOTE: run bin/format-filters after changing this file
1
2
  opal_filter "Float" do
2
3
  fails "Float#fdiv performs floating-point division between self and an Integer" # Expected 8.900000000008007e-117 == 8.900000000008011e-117 to be truthy but was false
3
4
  fails "Float#quo performs floating-point division between self and an Integer" # Expected 8.900000000008007e-117 == 8.900000000008011e-117 to be truthy but was false
@@ -1,3 +1,4 @@
1
+ # NOTE: run bin/format-filters after changing this file
1
2
  opal_unsupported_filter "Kernel" do
2
3
  fails "Kernel#caller includes core library methods defined in Ruby"
3
4
  end
@@ -1,6 +1,6 @@
1
+ # NOTE: run bin/format-filters after changing this file
1
2
  opal_unsupported_filter "Literal Regexp" do
2
- # Safari and WebKit do not support lookbehind, but may in the future see https://github.com/WebKit/WebKit/pull/7109
3
3
  fails "Literal Regexps handles a lookbehind with ss characters"
4
- fails "Literal Regexps supports (?<= ) (positive lookbehind)"
5
4
  fails "Literal Regexps supports (?<! ) (negative lookbehind)"
5
+ fails "Literal Regexps supports (?<= ) (positive lookbehind)"
6
6
  end
@@ -1,5 +1,6 @@
1
1
  # NOTE: run bin/format-filters after changing this file
2
2
  opal_unsupported_filter "Hash" do
3
+ fails "Hash#[] compares key via hash" # Mock '0' expected to receive hash("any_args") exactly 1 times but received it 0 times (performance optimization)
3
4
  fails "Hash#[]= duplicates and freezes string keys" # NotImplementedError: String#<< not supported. Mutable String methods are not supported in Opal.
4
5
  fails "Hash#[]= duplicates string keys using dup semantics" # TypeError: can't define singleton
5
6
  fails "Hash#assoc only returns the first matching key-value pair for identity hashes" # Expected 1 == 2 to be truthy but was false
@@ -10,5 +11,4 @@ opal_unsupported_filter "Hash" do
10
11
  fails "Hash#to_proc the returned proc passed as a block to instance_exec always retrieves the original hash's values" # Expected nil == 1 to be truthy but was false
11
12
  fails "Hash#to_proc the returned proc raises ArgumentError if not passed exactly one argument" # Expected ArgumentError but no exception was raised (nil was returned)
12
13
  fails "Hash#to_s does not raise if inspected result is not default external encoding" # Mock 'utf_16be' expected to receive inspect("any_args") exactly 1 times but received it 0 times
13
- fails "Hash#[] compares key via hash" # Mock '0' expected to receive hash("any_args") exactly 1 times but received it 0 times (performance optimization)
14
14
  end
@@ -214,6 +214,10 @@ RSpec.describe Opal::Compiler do
214
214
  expect_compiled("foo = 42 if Test > 4").to include("if ($truthy($rb_gt($$('Test'), 4))) ")
215
215
  end
216
216
 
217
+ it 'adds nil check for self' do
218
+ expect_compiled("foo = 42 if self > 4").to include("if ($truthy($rb_gt(self, 4))) ")
219
+ end
220
+
217
221
  it 'converts each == call inside if to an $eqeq wrapper, which does a truthy check' do
218
222
  expect_compiled('foo = 42 if 2 == 3').to include("if ($eqeq(2, 3))")
219
223
  expect_compiled('foo = 42 if 2.5 == 3.5').to include("if ($eqeq(2.5, 3.5))")
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Class#clone" do
4
+ it "should copy an instance method including super call" do
5
+ parent = Class.new do
6
+ def hello
7
+ "hello"
8
+ end
9
+ end
10
+ child = Class.new(parent) do
11
+ def hello
12
+ super + " world"
13
+ end
14
+ end
15
+
16
+ child.clone.new.hello.should == "hello world"
17
+ end
18
+
19
+ it "retains an included module in the ancestor chain" do
20
+ klass = Class.new
21
+ mod = Module.new do
22
+ def hello
23
+ "hello"
24
+ end
25
+ end
26
+
27
+ klass.include(mod)
28
+ klass.clone.new.hello.should == "hello"
29
+ end
30
+
31
+ it "copies a method with a block argument defined by define_method" do
32
+ klass = Class.new
33
+ klass.define_method(:add_one) { |&block| block.call + 1 }
34
+ klass.clone.new.add_one { 1 }.should == 2
35
+ end
36
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Module#define_method" do
4
+ describe "when passed an UnboundMethod object" do
5
+ it "defines a method taking a block" do
6
+ klass = Class.new do
7
+ def foo = yield :bar
8
+ end
9
+ klass.define_method(:baz, klass.instance_method(:foo))
10
+ klass.new.baz { |a| a }.should == :bar
11
+ end
12
+ end
13
+
14
+ describe "when called inside a def" do
15
+ it "returns correctly" do
16
+ klass = Class.new do
17
+ def self.my_method_definer
18
+ define_method(:a) do
19
+ return :foo
20
+ :bar
21
+ end
22
+ end
23
+ end
24
+
25
+ klass.my_method_definer
26
+ klass.new.a.should == :foo
27
+ end
28
+ end
29
+ end
@@ -50,9 +50,3 @@ describe "Numeric#object_id" do
50
50
  -1.object_id.should == -1
51
51
  end
52
52
  end
53
-
54
- describe "String#object_id" do
55
- it "returns the primitive string version of self" do
56
- `#{"hello".object_id} === "hello".toString()`.should be_true
57
- end
58
- end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Predefined global $!" do
4
+ it "should be set to the new exception after a throwing rescue" do
5
+ outer = StandardError.new 'outer'
6
+ inner = StandardError.new 'inner'
7
+
8
+ begin
9
+ begin
10
+ raise outer
11
+ rescue
12
+ $!.should == outer
13
+ raise inner
14
+ end
15
+ rescue
16
+ $!.should == inner
17
+ end
18
+ $!.should == nil
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ fixture = Class.new do
4
+ def single
5
+ yield 1
6
+ yield 2
7
+ end
8
+
9
+ def multiple
10
+ yield 1, 2
11
+ yield 3, 4
12
+ end
13
+ end
14
+
15
+ describe "The yield call" do
16
+ before :each do
17
+ ScratchPad.record []
18
+ @y = fixture.new
19
+ end
20
+
21
+ describe "taking a single argument" do
22
+ it "can yield to a lambda with return" do
23
+ lambda = -> i {
24
+ ScratchPad << i
25
+ return
26
+ }
27
+ @y.single(&lambda)
28
+ ScratchPad.recorded.should == [1, 2]
29
+ end
30
+ end
31
+
32
+ describe "taking multiple arguments" do
33
+ it "can yield to a lambda with return" do
34
+ lambda = -> i, j {
35
+ ScratchPad << i
36
+ ScratchPad << j
37
+ return
38
+ }
39
+ @y.multiple(&lambda)
40
+ ScratchPad.recorded.should == [1, 2, 3, 4]
41
+ end
42
+ end
43
+ end
data/spec/ruby_specs CHANGED
@@ -37,8 +37,6 @@ ruby/core/comparable
37
37
  ruby/core/complex
38
38
  !ruby/core/complex/marshal_dump_spec
39
39
 
40
- ruby/core/data
41
-
42
40
  ruby/core/enumerable
43
41
  ruby/core/enumerator
44
42
  ruby/core/enumerator/arithmetic_sequence
@@ -179,6 +177,7 @@ ruby/language
179
177
  ruby/library/base64
180
178
  ruby/library/bigdecimal
181
179
  !ruby/library/bigdecimal/util_spec
180
+ ruby/library/cgi
182
181
  ruby/library/date
183
182
  ruby/library/datetime
184
183
  ruby/library/delegate/delegate_class
data/stdlib/bigdecimal.rb CHANGED
@@ -19,6 +19,8 @@ def BigDecimal.new(*args, **kwargs)
19
19
  end
20
20
 
21
21
  class BigDecimal < Numeric
22
+ VERSION = '0'
23
+
22
24
  ROUND_MODE = 256
23
25
 
24
26
  # NOTE: the numeric values of the ROUND_* constants
@@ -0,0 +1,89 @@
1
+ # backtick_javascript: true
2
+
3
+ # This file contains parts of https://github.com/ruby/ruby/blob/master/lib/cgi/util.rb
4
+ # licensed under a Ruby license.
5
+
6
+ class CGI
7
+ module Util
8
+ # URL-encode a string into application/x-www-form-urlencoded.
9
+ # Space characters (+" "+) are encoded with plus signs (+"+"+)
10
+ # url_encoded_string = CGI.escape("'Stop!' said Fred")
11
+ # # => "%27Stop%21%27+said+Fred"
12
+ def escape(c)
13
+ `encodeURI(c)`
14
+ end
15
+
16
+ # URL-decode an application/x-www-form-urlencoded string with encoding(optional).
17
+ # string = CGI.unescape("%27Stop%21%27+said+Fred")
18
+ # # => "'Stop!' said Fred"
19
+ def unescape(c)
20
+ `decodeURI(c)`
21
+ end
22
+
23
+ # URL-encode a string following RFC 3986
24
+ # Space characters (+" "+) are encoded with (+"%20"+)
25
+ # url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred")
26
+ # # => "%27Stop%21%27%20said%20Fred"
27
+ def escapeURIComponent(c)
28
+ `encodeURIComponent(c)`
29
+ end
30
+
31
+ # URL-decode a string following RFC 3986 with encoding(optional).
32
+ # string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
33
+ # # => "'Stop!'+said Fred"
34
+ def unescapeURIComponent(c)
35
+ `decodeURIComponent(c)`
36
+ end
37
+
38
+ # The set of special characters and their escaped values
39
+ TABLE_FOR_ESCAPE_HTML__ = {
40
+ "'" => '&#39;',
41
+ '&' => '&amp;',
42
+ '"' => '&quot;',
43
+ '<' => '&lt;',
44
+ '>' => '&gt;',
45
+ }
46
+
47
+ # Escape special characters in HTML, namely '&\"<>
48
+ # CGI.escapeHTML('Usage: foo "bar" <baz>')
49
+ # # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
50
+ def escapeHTML(string)
51
+ string.gsub(/['&"<>]/, TABLE_FOR_ESCAPE_HTML__)
52
+ end
53
+
54
+ # Unescape a string that has been HTML-escaped
55
+ # CGI.unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
56
+ # # => "Usage: foo \"bar\" <baz>"
57
+ def unescapeHTML(string)
58
+ string.gsub(/&(apos|amp|quot|gt|lt|\#[0-9]+|\#[xX][0-9A-Fa-f]+);/) do
59
+ match = ::Regexp.last_match(1)
60
+ case match
61
+ when 'apos' then "'"
62
+ when 'amp' then '&'
63
+ when 'quot' then '"'
64
+ when 'gt' then '>'
65
+ when 'lt' then '<'
66
+ when /\A#0*(\d+)\z/
67
+ n = ::Regexp.last_match(1).to_i
68
+ n.chr('utf-8')
69
+ when /\A#x([0-9a-f]+)\z/i
70
+ n = ::Regexp.last_match(1).hex
71
+ n.chr('utf-8')
72
+ else
73
+ "&#{match};"
74
+ end
75
+ end
76
+ end
77
+
78
+ # Synonym for CGI.escapeHTML(str)
79
+ alias escape_html escapeHTML
80
+
81
+ # Synonym for CGI.unescapeHTML(str)
82
+ alias unescape_html unescapeHTML
83
+
84
+ alias h escapeHTML
85
+ end
86
+
87
+ include Util
88
+ extend Util
89
+ end
data/stdlib/cgi.rb CHANGED
@@ -1,14 +1 @@
1
- class CGI
2
- module Util
3
- def escapeURIComponent(c)
4
- `encodeURI(c)`
5
- end
6
-
7
- def unescapeURIComponent(c)
8
- `decodeURI(c)`
9
- end
10
- end
11
-
12
- include Util
13
- extend Util
14
- end
1
+ require 'cgi/util'