resources/mruby/mrbgems/mruby-io/test/file.rb in esruby-0.0.9 vs resources/mruby/mrbgems/mruby-io/test/file.rb in esruby-0.0.10

- old
+ new

@@ -52,20 +52,36 @@ assert_equal '', File.extname('foo/.bar') assert_equal '', File.extname('foo.txt/bar') assert_equal '', File.extname('.foo') end -assert('IO#flock') do +assert('File#flock') do f = File.open $mrbtest_io_rfname begin assert_equal(f.flock(File::LOCK_SH), 0) assert_equal(f.flock(File::LOCK_UN), 0) assert_equal(f.flock(File::LOCK_EX | File::LOCK_NB), 0) assert_equal(f.flock(File::LOCK_UN), 0) rescue NotImplementedError => e skip e.message ensure f.close + end +end + +assert('File#mtime') do + unless Object.const_defined?(:Time) + skip "File#mtime require Time" + end + begin + now = Time.now.to_i + mt = 0 + File.open('mtime-test', 'w') do |f| + mt = f.mtime.to_i + end + assert_equal true, mt >= now + ensure + File.delete('mtime-test') end end assert('File.join') do assert_equal "", File.join()