Skip to content

Commit 505176f

Browse files
committed
Run specific Time.at specs
1 parent b24f7e8 commit 505176f

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

opal/corelib/time.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ def zone
242242
}
243243
end
244244

245+
def getgm
246+
%x{
247+
var result = new Date(self.getTime());
248+
result.tz_offset = 0;
249+
return result;
250+
}
251+
end
252+
245253
def gmt?
246254
`self.tz_offset == 0`
247255
end

spec/opal/filters/bugs/time.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
opal_filter "Time" do
2+
fails "Time.at passed [Time, Integer] raises a TypeError"
3+
fails "Time.at passed [Integer, String] raises a TypeError"
4+
fails "Time.at passed [Integer, nil] raises a TypeError"
5+
fails "Time.at with a second argument that responds to #to_r coerces using #to_r"
6+
fails "Time.at with a second argument that responds to #to_int coerces using #to_int"
7+
fails "Time.at passed [Integer, Numeric] returns a Time object representing the given number of seconds and Float microseconds since 1971-01-01 00:00:00 UTC"
8+
fails "Time.at passed [Integer, Numeric] returns a Time object representing the given number of seconds and Integer microseconds since 1970-01-01 00:00:00 UTC"
9+
fails "Time.at passed non-Time, non-Numeric with an argument that responds to #to_r coerces using #to_r"
10+
fails "Time.at passed non-Time, non-Numeric with an argument that responds to #to_int coerces using #to_int"
11+
fails "Time.at passed [Integer, Numeric] returns a Time object representing the given number of seconds and Float microseconds since 1970-01-01 00:00:00 UTC"
12+
fails "Time.at passed non-Time, non-Numeric raises a TypeError with a nil argument"
13+
fails "Time.at passed non-Time, non-Numeric raises a TypeError with a String argument"
14+
fails "Time.at passed Time returns a subclass instance"
15+
fails "Time.at passed Time returns a UTC time if the argument is UTC"
16+
fails "Time.at passed Time creates a new time object with the value given by time"
17+
fails "Time.at passed Numeric returns a subclass instance on a Time subclass"
18+
fails "Time.at passed Numeric returns a Time object representing the given number of Float seconds since 1970-01-01 00:00:00 UTC"
19+
fails "Time.at passed Numeric returns a Time object representing the given number of Integer seconds since 1970-01-01 00:00:00 UTC"
20+
21+
fails "Time#getgm returns a new time which is the utc representation of time"
22+
223
fails "Time.gm ignores fractional seconds if a passed fractional number of microseconds"
324
fails "Time.gm ignores fractional seconds if a passed whole number of microseconds"
425
fails "Time.gm handles fractional microseconds as a Rational"

spec/opal/rubyspecs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,12 @@ core/struct/new_spec
323323
core/class/new_spec
324324

325325
core/time/asctime_spec
326+
core/time/at_spec
326327
core/time/ctime_spec
327328
core/time/day_spec
328329
core/time/eql_spec
329330
core/time/friday_spec
331+
core/time/getgm_spec
330332
core/time/gm_spec
331333
core/time/gmt_offset_spec
332334
core/time/hour_spec

0 commit comments

Comments
 (0)