diff options
| author | Akira Yumiyama <[email protected]> | 2013-04-07 01:55:18 +0900 |
|---|---|---|
| committer | Akira Yumiyama <[email protected]> | 2013-04-07 01:55:18 +0900 |
| commit | da557fbc82577872034cd52fe3bcf45aa13df45e (patch) | |
| tree | b1b75178887b0aae3b252d0ea56ee5bb83919876 /test | |
| parent | cc40f93ac8e9bb93ae0a7cf4893c9fd9f3926d21 (diff) | |
| download | mruby-da557fbc82577872034cd52fe3bcf45aa13df45e.tar.gz mruby-da557fbc82577872034cd52fe3bcf45aa13df45e.zip | |
add File.expand_path
Diffstat (limited to 'test')
| -rw-r--r-- | test/file.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/file.rb b/test/file.rb index f1bef32e5..8fe7636e0 100644 --- a/test/file.rb +++ b/test/file.rb @@ -73,3 +73,26 @@ end assert('File TEST CLEANUP') do assert_nil MRubyIOTestUtil.io_test_cleanup end + +assert('File.expand_path') do + assert_equal "/", File.expand_path("..", "/tmp"), "parent path with base_dir (1)" + assert_equal "/tmp", File.expand_path("..", "/tmp/mruby"), "parent path with base_dir (2)" + + assert_equal "/home", File.expand_path("/home"), "absolute" + assert_equal "/home", File.expand_path("/home", "."), "absolute with base_dir" + + assert_equal "/hoge", File.expand_path("/tmp/..//hoge") + assert_equal "/hoge", File.expand_path("////tmp/..///////hoge") + + assert_equal "/", File.expand_path("../../../..", "/") + assert_equal "/", File.expand_path(([".."] * 100).join("/")) +end + +assert('File.expand_path (with ENV)') do + skip unless Object.const_defined?(:ENV) && ENV['HOME'] + + assert_equal ENV['HOME'], File.expand_path("~/"), "home" + assert_equal ENV['HOME'], File.expand_path("~/", "/"), "home with base_dir" + + assert_equal "#{ENV['HOME']}/user", File.expand_path("user", ENV['HOME']), "relative with base_dir" +end |
