Commit 09b9c776 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2207 from take-cheeze/time_def

Remove `Time` defined check in mruby-time gem test.
parents c7ef2205 f0154d6e
## ##
# Time ISO Test # Time ISO Test
if Object.const_defined?(:Time) assert('Time.new', '15.2.3.3.3') do
assert('Time.new', '15.2.3.3.3') do Time.new.class == Time
Time.new.class == Time end
end
assert('Time', '15.2.19') do
Time.class == Class
end
assert('Time superclass', '15.2.19.2') do assert('Time', '15.2.19') do
Time.superclass == Object Time.class == Class
end end
assert('Time.at', '15.2.19.6.1') do assert('Time superclass', '15.2.19.2') do
Time.at(1300000000.0) Time.superclass == Object
end end
assert('Time.gm', '15.2.19.6.2') do assert('Time.at', '15.2.19.6.1') do
Time.gm(2012, 12, 23) Time.at(1300000000.0)
end end
assert('Time.local', '15.2.19.6.3') do assert('Time.gm', '15.2.19.6.2') do
Time.local(2012, 12, 23) Time.gm(2012, 12, 23)
end end
assert('Time.mktime', '15.2.19.6.4') do assert('Time.local', '15.2.19.6.3') do
Time.mktime(2012, 12, 23) Time.local(2012, 12, 23)
end end
assert('Time.now', '15.2.19.6.5') do assert('Time.mktime', '15.2.19.6.4') do
Time.now.class == Time Time.mktime(2012, 12, 23)
end end
assert('Time.utc', '15.2.19.6.6') do assert('Time.now', '15.2.19.6.5') do
Time.utc(2012, 12, 23) Time.now.class == Time
end end
assert('Time#+', '15.2.19.7.1') do assert('Time.utc', '15.2.19.6.6') do
t1 = Time.at(1300000000.0) Time.utc(2012, 12, 23)
t2 = t1.+(60) end
t2.utc.asctime == "Sun Mar 13 07:07:40 UTC 2011" assert('Time#+', '15.2.19.7.1') do
end t1 = Time.at(1300000000.0)
t2 = t1.+(60)
assert('Time#-', '15.2.19.7.2') do t2.utc.asctime == "Sun Mar 13 07:07:40 UTC 2011"
t1 = Time.at(1300000000.0) end
t2 = t1.-(60)
t2.utc.asctime == "Sun Mar 13 07:05:40 UTC 2011" assert('Time#-', '15.2.19.7.2') do
end t1 = Time.at(1300000000.0)
t2 = t1.-(60)
assert('Time#<=>', '15.2.19.7.3') do t2.utc.asctime == "Sun Mar 13 07:05:40 UTC 2011"
t1 = Time.at(1300000000.0) end
t2 = Time.at(1400000000.0)
t3 = Time.at(1500000000.0)
t2.<=>(t1) == 1 and assert('Time#<=>', '15.2.19.7.3') do
t2.<=>(t2) == 0 and t1 = Time.at(1300000000.0)
t2.<=>(t3) == -1 and t2 = Time.at(1400000000.0)
t2.<=>(nil) == nil t3 = Time.at(1500000000.0)
end
assert('Time#asctime', '15.2.19.7.4') do t2.<=>(t1) == 1 and
Time.at(1300000000.0).utc.asctime == "Sun Mar 13 07:06:40 UTC 2011" t2.<=>(t2) == 0 and
end t2.<=>(t3) == -1 and
t2.<=>(nil) == nil
end
assert('Time#ctime', '15.2.19.7.5') do assert('Time#asctime', '15.2.19.7.4') do
Time.at(1300000000.0).utc.ctime == "Sun Mar 13 07:06:40 UTC 2011" Time.at(1300000000.0).utc.asctime == "Sun Mar 13 07:06:40 UTC 2011"
end end
assert('Time#day', '15.2.19.7.6') do assert('Time#ctime', '15.2.19.7.5') do
Time.gm(2012, 12, 23).day == 23 Time.at(1300000000.0).utc.ctime == "Sun Mar 13 07:06:40 UTC 2011"
end end
assert('Time#dst?', '15.2.19.7.7') do assert('Time#day', '15.2.19.7.6') do
not Time.gm(2012, 12, 23).utc.dst? Time.gm(2012, 12, 23).day == 23
end end
assert('Time#getgm', '15.2.19.7.8') do assert('Time#dst?', '15.2.19.7.7') do
Time.at(1300000000.0).getgm.asctime == "Sun Mar 13 07:06:40 UTC 2011" not Time.gm(2012, 12, 23).utc.dst?
end end
assert('Time#getlocal', '15.2.19.7.9') do assert('Time#getgm', '15.2.19.7.8') do
t1 = Time.at(1300000000.0) Time.at(1300000000.0).getgm.asctime == "Sun Mar 13 07:06:40 UTC 2011"
t2 = Time.at(1300000000.0) end
t3 = t1.getlocal
t1 == t3 and t3 == t2.getlocal assert('Time#getlocal', '15.2.19.7.9') do
end t1 = Time.at(1300000000.0)
t2 = Time.at(1300000000.0)
t3 = t1.getlocal
assert('Time#getutc', '15.2.19.7.10') do t1 == t3 and t3 == t2.getlocal
Time.at(1300000000.0).getutc.asctime == "Sun Mar 13 07:06:40 UTC 2011" end
end
assert('Time#gmt?', '15.2.19.7.11') do assert('Time#getutc', '15.2.19.7.10') do
Time.at(1300000000.0).utc.gmt? Time.at(1300000000.0).getutc.asctime == "Sun Mar 13 07:06:40 UTC 2011"
end end
# ATM not implemented assert('Time#gmt?', '15.2.19.7.11') do
# assert('Time#gmt_offset', '15.2.19.7.12') do Time.at(1300000000.0).utc.gmt?
end
assert('Time#gmtime', '15.2.19.7.13') do # ATM not implemented
Time.at(1300000000.0).gmtime # assert('Time#gmt_offset', '15.2.19.7.12') do
end
# ATM not implemented assert('Time#gmtime', '15.2.19.7.13') do
# assert('Time#gmtoff', '15.2.19.7.14') do Time.at(1300000000.0).gmtime
end
assert('Time#hour', '15.2.19.7.15') do # ATM not implemented
Time.gm(2012, 12, 23, 7, 6).hour == 7 # assert('Time#gmtoff', '15.2.19.7.14') do
end
# ATM doesn't really work assert('Time#hour', '15.2.19.7.15') do
# assert('Time#initialize', '15.2.19.7.16') do Time.gm(2012, 12, 23, 7, 6).hour == 7
end
assert('Time#initialize_copy', '15.2.19.7.17') do # ATM doesn't really work
time_tmp_2 = Time.at(7.0e6) # assert('Time#initialize', '15.2.19.7.16') do
time_tmp_2.clone == time_tmp_2
end
assert('Time#localtime', '15.2.19.7.18') do assert('Time#initialize_copy', '15.2.19.7.17') do
t1 = Time.at(1300000000.0) time_tmp_2 = Time.at(7.0e6)
t2 = Time.at(1300000000.0) time_tmp_2.clone == time_tmp_2
end
t1.localtime assert('Time#localtime', '15.2.19.7.18') do
t1 == t2.getlocal t1 = Time.at(1300000000.0)
end t2 = Time.at(1300000000.0)
assert('Time#mday', '15.2.19.7.19') do t1.localtime
Time.gm(2012, 12, 23).mday == 23 t1 == t2.getlocal
end end
assert('Time#min', '15.2.19.7.20') do assert('Time#mday', '15.2.19.7.19') do
Time.gm(2012, 12, 23, 7, 6).min == 6 Time.gm(2012, 12, 23).mday == 23
end end
assert('Time#mon', '15.2.19.7.21') do assert('Time#min', '15.2.19.7.20') do
Time.gm(2012, 12, 23).mon == 12 Time.gm(2012, 12, 23, 7, 6).min == 6
end end
assert('Time#month', '15.2.19.7.22') do assert('Time#mon', '15.2.19.7.21') do
Time.gm(2012, 12, 23).month == 12 Time.gm(2012, 12, 23).mon == 12
end end
assert('Times#sec', '15.2.19.7.23') do assert('Time#month', '15.2.19.7.22') do
Time.gm(2012, 12, 23, 7, 6, 40).sec == 40 Time.gm(2012, 12, 23).month == 12
end end
assert('Time#to_f', '15.2.19.7.24') do assert('Times#sec', '15.2.19.7.23') do
Time.at(1300000000.0).to_f == 1300000000.0 Time.gm(2012, 12, 23, 7, 6, 40).sec == 40
end end
assert('Time#to_i', '15.2.19.7.25') do assert('Time#to_f', '15.2.19.7.24') do
Time.at(1300000000.0).to_i == 1300000000 Time.at(1300000000.0).to_f == 1300000000.0
end end
assert('Time#usec', '15.2.19.7.26') do assert('Time#to_i', '15.2.19.7.25') do
Time.at(1300000000.0).usec == 0 Time.at(1300000000.0).to_i == 1300000000
end end
assert('Time#utc', '15.2.19.7.27') do assert('Time#usec', '15.2.19.7.26') do
Time.at(1300000000.0).utc Time.at(1300000000.0).usec == 0
end end
assert('Time#utc?', '15.2.19.7.28') do assert('Time#utc', '15.2.19.7.27') do
Time.at(1300000000.0).utc.utc? Time.at(1300000000.0).utc
end end
# ATM not implemented assert('Time#utc?', '15.2.19.7.28') do
# assert('Time#utc_offset', '15.2.19.7.29') do Time.at(1300000000.0).utc.utc?
end
assert('Time#wday', '15.2.19.7.30') do # ATM not implemented
Time.gm(2012, 12, 23).wday == 0 # assert('Time#utc_offset', '15.2.19.7.29') do
end
assert('Time#yday', '15.2.19.7.31') do assert('Time#wday', '15.2.19.7.30') do
Time.gm(2012, 12, 23).yday == 358 Time.gm(2012, 12, 23).wday == 0
end end
assert('Time#year', '15.2.19.7.32') do assert('Time#yday', '15.2.19.7.31') do
Time.gm(2012, 12, 23).year == 2012 Time.gm(2012, 12, 23).yday == 358
end end
assert('Time#zone', '15.2.19.7.33') do assert('Time#year', '15.2.19.7.32') do
Time.at(1300000000.0).utc.zone == 'UTC' Time.gm(2012, 12, 23).year == 2012
end end
# Not ISO specified assert('Time#zone', '15.2.19.7.33') do
Time.at(1300000000.0).utc.zone == 'UTC'
end
assert('Time#to_s') do # Not ISO specified
Time.at(1300000000.0).utc.to_s == "Sun Mar 13 07:06:40 UTC 2011"
end
assert('Time#inspect') do assert('Time#to_s') do
Time.at(1300000000.0).utc.inspect == "Sun Mar 13 07:06:40 UTC 2011" Time.at(1300000000.0).utc.to_s == "Sun Mar 13 07:06:40 UTC 2011"
end end
assert('day of week methods') do assert('Time#inspect') do
t = Time.gm(2012, 12, 24) Time.at(1300000000.0).utc.inspect == "Sun Mar 13 07:06:40 UTC 2011"
assert_false t.sunday?
assert_true t.monday?
assert_false t.tuesday?
assert_false t.wednesday?
assert_false t.thursday?
assert_false t.friday?
assert_false t.saturday?
end
end end
assert('day of week methods') do
t = Time.gm(2012, 12, 24)
assert_false t.sunday?
assert_true t.monday?
assert_false t.tuesday?
assert_false t.wednesday?
assert_false t.thursday?
assert_false t.friday?
assert_false t.saturday?
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment