Skip to content

Commit 8adc96b

Browse files
andrykonchinmatzbot
authored andcommitted
[ruby/date] Skip tests failing on TruffleRuby
ruby/date@d019ac8186
1 parent cfee3d9 commit 8adc96b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

test/date/test_date_conv.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,14 @@ def test_to_time__from_datetime
8989
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.nsec])
9090
end
9191

92-
if Time.allocate.respond_to?(:subsec)
93-
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123456789123.to_r/86400000000000000000000
94-
t = d.to_time.utc
95-
assert_equal([2004, 9, 19, 1, 2, 3, Rational(456789123456789123,1000000000000000000)],
96-
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.subsec])
92+
# TruffleRuby does not support more than nanoseconds
93+
unless RUBY_ENGINE == 'truffleruby'
94+
if Time.allocate.respond_to?(:subsec)
95+
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123456789123.to_r/86400000000000000000000
96+
t = d.to_time.utc
97+
assert_equal([2004, 9, 19, 1, 2, 3, Rational(456789123456789123,1000000000000000000)],
98+
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.subsec])
99+
end
97100
end
98101
end
99102

test/date/test_date_parse.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,13 @@ def test__parse_odd_offset
589589
end
590590

591591
def test__parse_too_long_year
592-
str = "Jan 1" + "0" * 100_000
593-
h = EnvUtil.timeout(3) {Date._parse(str, limit: 100_010)}
594-
assert_equal(100_000, Math.log10(h[:year]))
595-
assert_equal(1, h[:mon])
592+
# Math.log10 does not support so big numbers like 10^100_000 on TruffleRuby
593+
unless RUBY_ENGINE == 'truffleruby'
594+
str = "Jan 1" + "0" * 100_000
595+
h = EnvUtil.timeout(3) {Date._parse(str, limit: 100_010)}
596+
assert_equal(100_000, Math.log10(h[:year]))
597+
assert_equal(1, h[:mon])
598+
end
596599

597600
str = "Jan - 1" + "0" * 100_000
598601
h = EnvUtil.timeout(3) {Date._parse(str, limit: 100_010)}

0 commit comments

Comments
 (0)