Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Run specific Time.at specs
  • Loading branch information
adambeynon committed Dec 9, 2013
1 parent b24f7e8 commit 505176f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions opal/corelib/time.rb
Expand Up @@ -242,6 +242,14 @@ def zone
}
end

def getgm
%x{
var result = new Date(self.getTime());
result.tz_offset = 0;
return result;
}
end

def gmt?
`self.tz_offset == 0`
end
Expand Down
21 changes: 21 additions & 0 deletions spec/opal/filters/bugs/time.rb
@@ -1,4 +1,25 @@
opal_filter "Time" do
fails "Time.at passed [Time, Integer] raises a TypeError"
fails "Time.at passed [Integer, String] raises a TypeError"
fails "Time.at passed [Integer, nil] raises a TypeError"
fails "Time.at with a second argument that responds to #to_r coerces using #to_r"
fails "Time.at with a second argument that responds to #to_int coerces using #to_int"
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"
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"
fails "Time.at passed non-Time, non-Numeric with an argument that responds to #to_r coerces using #to_r"
fails "Time.at passed non-Time, non-Numeric with an argument that responds to #to_int coerces using #to_int"
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"
fails "Time.at passed non-Time, non-Numeric raises a TypeError with a nil argument"
fails "Time.at passed non-Time, non-Numeric raises a TypeError with a String argument"
fails "Time.at passed Time returns a subclass instance"
fails "Time.at passed Time returns a UTC time if the argument is UTC"
fails "Time.at passed Time creates a new time object with the value given by time"
fails "Time.at passed Numeric returns a subclass instance on a Time subclass"
fails "Time.at passed Numeric returns a Time object representing the given number of Float seconds since 1970-01-01 00:00:00 UTC"
fails "Time.at passed Numeric returns a Time object representing the given number of Integer seconds since 1970-01-01 00:00:00 UTC"

fails "Time#getgm returns a new time which is the utc representation of time"

fails "Time.gm ignores fractional seconds if a passed fractional number of microseconds"
fails "Time.gm ignores fractional seconds if a passed whole number of microseconds"
fails "Time.gm handles fractional microseconds as a Rational"
Expand Down
2 changes: 2 additions & 0 deletions spec/opal/rubyspecs
Expand Up @@ -323,10 +323,12 @@ core/struct/new_spec
core/class/new_spec

core/time/asctime_spec
core/time/at_spec
core/time/ctime_spec
core/time/day_spec
core/time/eql_spec
core/time/friday_spec
core/time/getgm_spec
core/time/gm_spec
core/time/gmt_offset_spec
core/time/hour_spec
Expand Down

0 comments on commit 505176f

Please sign in to comment.