summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-08-13 23:11:34 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-08-13 23:15:52 +0900
commitc095736002e72d8f00c2c09b0295d2630e4375c7 (patch)
treedb5fa3e822f22fbfa79c25062842823f6637241e
parent14206a75a37020a3a4926b1289a1f07277b78578 (diff)
downloadmruby-c095736002e72d8f00c2c09b0295d2630e4375c7.tar.gz
mruby-c095736002e72d8f00c2c09b0295d2630e4375c7.zip
Try to fix a fragile `File#mtime` test.
-rw-r--r--mrbgems/mruby-io/src/file.c4
-rw-r--r--mrbgems/mruby-io/test/file.rb8
2 files changed, 4 insertions, 8 deletions
diff --git a/mrbgems/mruby-io/src/file.c b/mrbgems/mruby-io/src/file.c
index ca21256cc..e65741061 100644
--- a/mrbgems/mruby-io/src/file.c
+++ b/mrbgems/mruby-io/src/file.c
@@ -345,11 +345,7 @@ mrb_file_mtime(mrb_state *mrb, mrb_value self)
fd = (int)mrb_fixnum(mrb_io_fileno(mrb, self));
if (fstat(fd, &st) == -1)
return mrb_false_value();
-#ifndef MRB_WITHOUT_FLOAT
- return mrb_funcall(mrb, obj, "at", 1, mrb_float_value(mrb, st.st_mtime));
-#else
return mrb_funcall(mrb, obj, "at", 1, mrb_fixnum_value(st.st_mtime));
-#endif
}
mrb_value
diff --git a/mrbgems/mruby-io/test/file.rb b/mrbgems/mruby-io/test/file.rb
index ab4678fe9..ca285f5bd 100644
--- a/mrbgems/mruby-io/test/file.rb
+++ b/mrbgems/mruby-io/test/file.rb
@@ -73,12 +73,12 @@ assert('File#mtime') do
skip "File#mtime require Time"
end
begin
- now = Time.now.to_i
- mt = 0
File.open("#{$mrbtest_io_wfname}.mtime", 'w') do |f|
- mt = f.mtime.to_i
+ assert_equal Time, f.mtime.class
+ File.open("#{$mrbtest_io_wfname}.mtime", 'r') do |f2|
+ assert_equal true, f.mtime == f2.mtime
+ end
end
- assert_equal true, mt >= now
ensure
File.delete("#{$mrbtest_io_wfname}.mtime")
end