opal 1.8.0.alpha1 → 1.8.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +1 -0
  3. data/README.md +7 -7
  4. data/UNRELEASED.md +14 -0
  5. data/docs/releasing.md +8 -16
  6. data/lib/opal/cli_runners/chrome.rb +5 -1
  7. data/lib/opal/nodes/closure.rb +15 -7
  8. data/lib/opal/nodes/defined.rb +1 -1
  9. data/lib/opal/nodes/literal.rb +10 -6
  10. data/lib/opal/nodes/rescue.rb +1 -1
  11. data/lib/opal/simple_server.rb +2 -2
  12. data/lib/opal/version.rb +1 -1
  13. data/opal/corelib/array.rb +39 -21
  14. data/opal/corelib/class.rb +26 -8
  15. data/opal/corelib/complex.rb +1 -1
  16. data/opal/corelib/constants.rb +2 -2
  17. data/opal/corelib/enumerator/arithmetic_sequence.rb +1 -1
  18. data/opal/corelib/error.rb +10 -0
  19. data/opal/corelib/hash.rb +30 -18
  20. data/opal/corelib/kernel.rb +0 -1
  21. data/opal/corelib/module.rb +44 -5
  22. data/opal/corelib/number.rb +28 -1
  23. data/opal/corelib/range.rb +1 -1
  24. data/opal/corelib/rational.rb +1 -1
  25. data/opal/corelib/runtime.js +124 -42
  26. data/opal/corelib/string.rb +36 -8
  27. data/opal/corelib/struct.rb +1 -1
  28. data/opal/corelib/time.rb +1 -1
  29. data/spec/filters/bugs/array.rb +58 -0
  30. data/spec/filters/bugs/basicobject.rb +7 -0
  31. data/spec/filters/bugs/bigdecimal.rb +1 -2
  32. data/spec/filters/bugs/binding.rb +1 -0
  33. data/spec/filters/bugs/class.rb +2 -3
  34. data/spec/filters/bugs/complex.rb +3 -0
  35. data/spec/filters/bugs/date.rb +5 -2
  36. data/spec/filters/bugs/datetime.rb +1 -0
  37. data/spec/filters/bugs/delegate.rb +1 -2
  38. data/spec/filters/bugs/encoding.rb +1 -1
  39. data/spec/filters/bugs/enumerable.rb +11 -0
  40. data/spec/filters/bugs/enumerator.rb +15 -2
  41. data/spec/filters/bugs/exception.rb +9 -4
  42. data/spec/filters/bugs/file.rb +2 -0
  43. data/spec/filters/bugs/float.rb +1 -0
  44. data/spec/filters/bugs/freeze.rb +5 -49
  45. data/spec/filters/bugs/hash.rb +1 -0
  46. data/spec/filters/bugs/integer.rb +5 -6
  47. data/spec/filters/bugs/kernel.rb +12 -5
  48. data/spec/filters/bugs/language.rb +33 -15
  49. data/spec/filters/bugs/marshal.rb +63 -4
  50. data/spec/filters/bugs/method.rb +2 -10
  51. data/spec/filters/bugs/module.rb +18 -7
  52. data/spec/filters/bugs/objectspace.rb +2 -0
  53. data/spec/filters/bugs/pathname.rb +1 -0
  54. data/spec/filters/bugs/proc.rb +4 -2
  55. data/spec/filters/bugs/random.rb +0 -3
  56. data/spec/filters/bugs/range.rb +1 -1
  57. data/spec/filters/bugs/rational.rb +2 -0
  58. data/spec/filters/bugs/refinement.rb +19 -0
  59. data/spec/filters/bugs/regexp.rb +27 -5
  60. data/spec/filters/bugs/ruby-32.rb +0 -4
  61. data/spec/filters/bugs/set.rb +10 -2
  62. data/spec/filters/bugs/singleton.rb +0 -2
  63. data/spec/filters/bugs/string.rb +140 -1
  64. data/spec/filters/bugs/struct.rb +15 -5
  65. data/spec/filters/bugs/time.rb +56 -2
  66. data/spec/filters/bugs/trace_point.rb +1 -0
  67. data/spec/filters/bugs/unboundmethod.rb +4 -9
  68. data/spec/filters/bugs/warnings.rb +0 -1
  69. data/spec/filters/platform/firefox/exception.rb +3 -3
  70. data/spec/filters/platform/firefox/kernel.rb +1 -0
  71. data/spec/filters/platform/safari/exception.rb +2 -2
  72. data/spec/filters/platform/safari/float.rb +1 -0
  73. data/spec/filters/platform/safari/kernel.rb +1 -0
  74. data/spec/filters/platform/safari/literal_regexp.rb +2 -2
  75. data/spec/filters/unsupported/hash.rb +1 -1
  76. data/spec/lib/compiler_spec.rb +4 -0
  77. data/spec/opal/core/class/clone_spec.rb +36 -0
  78. data/spec/opal/core/object_id_spec.rb +0 -6
  79. data/spec/opal/language/predefined_spec.rb +20 -0
  80. data/spec/opal/language/yield_spec.rb +43 -0
  81. data/spec/ruby_specs +0 -2
  82. data/stdlib/bigdecimal.rb +2 -0
  83. data/stdlib/delegate.rb +3 -4
  84. data/stdlib/pathname.rb +1 -1
  85. data/stdlib/promise/v2.rb +22 -7
  86. data/stdlib/stringio.rb +2 -0
  87. data/tasks/testing.rake +15 -11
  88. data/test/opal/promisev2/test_always.rb +14 -0
  89. data/test/opal/unsupported_and_bugs.rb +0 -8
  90. metadata +10 -6
@@ -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
@@ -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
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
data/stdlib/delegate.rb CHANGED
@@ -52,10 +52,9 @@ class Delegator < BasicObject
52
52
  kernel = ::Kernel.dup
53
53
  kernel.class_eval do
54
54
  alias_method :__raise__, :raise
55
- # somehow this doesn't work in Opal:
56
- # %i[to_s inspect !~ === <=> hash].each do |m|
57
- # undef_method m
58
- # end
55
+ %i[to_s inspect !~ === <=> hash].each do |m|
56
+ undef_method m
57
+ end
59
58
  private_instance_methods.each do |m|
60
59
  if /\Ablock_given\?\z|\Aiterator\?\z|\A__.*__\z/ =~ m
61
60
  next
data/stdlib/pathname.rb CHANGED
@@ -77,7 +77,7 @@ class Pathname
77
77
  end
78
78
 
79
79
  def hash
80
- @path
80
+ @path.hash
81
81
  end
82
82
 
83
83
  def expand_path
data/stdlib/promise/v2.rb CHANGED
@@ -144,6 +144,7 @@ class PromiseV2 < `Promise`
144
144
  `Promise.resolve(#{value})`.tap do |prom|
145
145
  prom.instance_variable_set(:@type, :resolve)
146
146
  prom.instance_variable_set(:@realized, :resolve)
147
+ prom.instance_variable_set(:@value_set, true)
147
148
  prom.instance_variable_set(:@value, value)
148
149
  end
149
150
  end
@@ -152,6 +153,7 @@ class PromiseV2 < `Promise`
152
153
  `Promise.reject(#{value})`.tap do |prom|
153
154
  prom.instance_variable_set(:@type, :reject)
154
155
  prom.instance_variable_set(:@realized, :reject)
156
+ prom.instance_variable_set(:@value_set, true)
155
157
  prom.instance_variable_set(:@value, value)
156
158
  end
157
159
  end
@@ -199,6 +201,7 @@ class PromiseV2 < `Promise`
199
201
  def resolve(value = nil)
200
202
  nativity_check!
201
203
  raise ArgumentError, 'this promise was already resolved' if @realized
204
+ @value_set = true
202
205
  @value = value
203
206
  @realized = :resolve
204
207
  @resolve_proc.call(value)
@@ -208,6 +211,7 @@ class PromiseV2 < `Promise`
208
211
  def reject(value = nil)
209
212
  nativity_check!
210
213
  raise ArgumentError, 'this promise was already resolved' if @realized
214
+ @value_set = true
211
215
  @value = value
212
216
  @realized = :reject
213
217
  @reject_proc.call(value)
@@ -218,6 +222,7 @@ class PromiseV2 < `Promise`
218
222
  prom = nil
219
223
  blk = gen_tracing_proc(block) do |val|
220
224
  prom.instance_variable_set(:@realized, :resolve)
225
+ prom.instance_variable_set(:@value_set, true)
221
226
  prom.instance_variable_set(:@value, val)
222
227
  end
223
228
  prom = `self.then(#{blk})`
@@ -236,6 +241,7 @@ class PromiseV2 < `Promise`
236
241
  prom = nil
237
242
  blk = gen_tracing_proc(block) do |val|
238
243
  prom.instance_variable_set(:@realized, :resolve)
244
+ prom.instance_variable_set(:@value_set, true)
239
245
  prom.instance_variable_set(:@value, val)
240
246
  end
241
247
  prom = `self.catch(#{blk})`
@@ -254,9 +260,10 @@ class PromiseV2 < `Promise`
254
260
  prom = nil
255
261
  blk = gen_tracing_proc(block) do |val|
256
262
  prom.instance_variable_set(:@realized, :resolve)
263
+ prom.instance_variable_set(:@value_set, true)
257
264
  prom.instance_variable_set(:@value, val)
258
265
  end
259
- prom = `self.finally(#{blk})`
266
+ prom = `self.finally(function() { return blk(self.$value_internal()); })`
260
267
  prom.instance_variable_set(:@prev, self)
261
268
  prom.instance_variable_set(:@type, :always)
262
269
  (@next ||= []) << prom
@@ -312,11 +319,7 @@ class PromiseV2 < `Promise`
312
319
 
313
320
  def value
314
321
  if resolved?
315
- if PromiseV2 === @value
316
- @value.value
317
- else
318
- @value
319
- end
322
+ value_internal
320
323
  end
321
324
  end
322
325
 
@@ -366,7 +369,7 @@ class PromiseV2 < `Promise`
366
369
  result += " >> #{@next.inspect}"
367
370
  end
368
371
 
369
- result += ": #{@value.inspect}" if @value
372
+ result += ": #{value.inspect}"
370
373
  result += '>'
371
374
 
372
375
  result
@@ -386,4 +389,16 @@ class PromiseV2 < `Promise`
386
389
  alias resolve! resolve
387
390
  alias to_n itself
388
391
  alias to_v2 itself
392
+
393
+ private
394
+
395
+ def value_internal
396
+ if PromiseV2 === @value
397
+ @value.value
398
+ elsif @value_set
399
+ @value
400
+ elsif @prev
401
+ @prev.value
402
+ end
403
+ end
389
404
  end
data/stdlib/stringio.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  class StringIO < IO
2
+ VERSION = "0"
3
+
2
4
  def self.open(string = "", mode = nil, &block)
3
5
  io = new(string, mode)
4
6
  res = block.call(io)
data/tasks/testing.rake CHANGED
@@ -36,6 +36,7 @@ module Testing
36
36
  mspec/commands/mspec-run
37
37
  etc
38
38
  rubygems
39
+ zlib
39
40
  ]
40
41
  end
41
42
 
@@ -334,7 +335,6 @@ platforms.each do |platform|
334
335
  includes = "-Itest/cruby/test"
335
336
  files = %w[
336
337
  benchmark/test_benchmark.rb
337
- ruby/test_call.rb
338
338
  opal/test_keyword.rb
339
339
  opal/test_base64.rb
340
340
  opal/test_openuri.rb
@@ -427,17 +427,21 @@ task :smoke_test do
427
427
  begin
428
428
  require 'rspec/expectations'
429
429
  extend RSpec::Matchers
430
- expect(actual_output.lines[0]).to eq("..\n")
431
- expect(actual_output.lines[1]).to eq("\n")
432
- expect(actual_output.lines[2]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n})
433
- expect(actual_output.lines[4]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:7\n})
434
- expect(actual_output.lines[6]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:12\n})
435
- expect(actual_output.lines[7]).to eq("\n")
436
- expect(actual_output.lines[8]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$})
437
- expect(actual_output.lines[9]).to eq("2 examples, 0 failures\n")
430
+ expect(actual_output.lines[0]).to eq("\n")
431
+ expect(actual_output.lines[1]).to eq("Opal::Deprecations\n")
432
+ expect(actual_output.lines[2]).to eq("\e[32m defaults to warn\e[0m\n")
433
+ expect(actual_output.lines[3]).to eq("\e[32m can be set to raise\e[0m\n")
434
+ expect(actual_output.lines[4]).to eq("\n")
435
+
436
+ expect(actual_output.lines[5]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n})
437
+ expect(actual_output.lines[7]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:7\n})
438
+ expect(actual_output.lines[9]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:12\n})
439
+ expect(actual_output.lines[10]).to eq("\n")
440
+ expect(actual_output.lines[11]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$})
441
+ expect(actual_output.lines[12]).to eq("2 examples, 0 failures\n")
438
442
  expect([
439
- actual_output.lines[3],
440
- actual_output.lines[5],
443
+ actual_output.lines[6],
444
+ actual_output.lines[8],
441
445
  ]).to contain_exactly(
442
446
  " Opal::Deprecations defaults to warn\n",
443
447
  " Opal::Deprecations can be set to raise\n",