test/tc/temp.rb in rio-0.4.2 vs test/tc/temp.rb in rio-0.5.1

- old
+ new

@@ -24,66 +24,78 @@ [:scheme,:opaque,:path,:fspath,:to_s,:to_url,:to_uri].each do |sym| puts "#{sym}: #{ario.__send__(sym)}" end end + def test_tempfile + str = "Hello World\n" + src = rio(?").print!(str) + ans = rio(?") + + tmp = rio(??) + tmp < src + assert_equal(str,tmp.rewind.contents) + tmp.rewind > ans + assert_equal(str,ans.contents) + end + + def test_new + # $trace_states = true + #p 'HERRRRRRRRRRRRRRRRRRRRRR' tmp = rio(??) assert_equal('temp',tmp.scheme) - assert_equal(::Dir::tmpdir,tmp.dirname.to_s) + dn = tmp.dirname + #p "DN=",dn,'TMP=',tmp + assert_equal(::Dir::tmpdir,dn.to_s) + #p tmp assert_match(/^rio/,tmp.filename.to_s) end def test_dir tmp = rio(??).mkdir - assert(tmp.dir?) - assert_equal('file',tmp.scheme) assert_equal(::Dir::tmpdir,tmp.dirname.to_s) assert_match(/^rio/,tmp.filename.to_s) + #p tmp + assert(tmp.dir?) tmp.close end def test_dir_chdir + # $trace_states = true rio(??).chdir { |tmp| assert(tmp.dir?) - assert_equal('path',tmp.scheme) + #assert_equal('path',tmp.scheme) + #assert_equal('./',tmp.dirname.to_s) + assert_nil(tmp.scheme) assert_equal('.',tmp.dirname.to_s) assert_equal('.',tmp.filename.to_s) tmp.close } end -# def test_dir_chdir2 -# tmp = rio(??).chdir -# assert(tmp.dir?) -# assert_equal('path',tmp.scheme) -# assert_equal('.',tmp.dirname.to_s) -# assert_equal('.',tmp.filename.to_s) -# tmp.close -# end + def test_dir_mkdir tmp = rio(??).mkdir - assert(tmp.dir?) - assert_equal('file',tmp.scheme) assert_equal(::Dir::tmpdir,tmp.dirname.to_s) assert_match(/^rio/,tmp.filename.to_s) + assert(tmp.dir?) tmp.close end def test_file tmp = rio(??).file - assert(tmp.file?) - assert_equal('file',tmp.scheme) assert_equal(::Dir::tmpdir,tmp.dirname.to_s) assert_match(/^rio/,tmp.filename.to_s) + assert(tmp.file?) tmp.close end def test_dir_prefix tmp = rio(??,'zippy').mkdir - assert(tmp.dir?) assert_match(/^zippy/,tmp.filename.to_s) assert_equal(::Dir::tmpdir,tmp.dirname.to_s) + assert(tmp.dir?) tmp.close end def test_file_prefix tmp = rio(??,'zippy').file @@ -95,54 +107,56 @@ def test_dir_tmpdir rio('riotmpdir').delete!.mkdir tmp = rio(??,'zippy','riotmpdir').mkdir assert_match(/^zippy/,tmp.filename.to_s) - assert_match('riotmpdir',tmp.dirname.to_s) + assert_equal('riotmpdir',tmp.dirname.to_s) tmp.close end def test_file_tmpdir rio('riotmpdir').delete!.mkdir tmp = rio(??,'zippy','riotmpdir').file assert_match(/^zippy/,tmp.filename.to_s) - assert_match('riotmpdir',tmp.dirname.to_s) + assert_equal('riotmpdir',tmp.dirname.filename.to_s) tmp.close end def test_dir_prefix_url + #$trace_states = true + tmp = rio('temp:zippy').mkdir - assert_match(/^zippy/,tmp.filename.to_s) + assert_match(/^zippy/,tmp.path.to_s) tmp.close end def test_file_prefix_url - tmp = rio('temp:zippy').file + tmp = rio('temp:?zippy').file assert_match(/^zippy/,tmp.filename.to_s) tmp.close end def test_dir_tmpdir_url rio('riotmpdir').delete!.mkdir - tmp = rio('temp:riotmpdir/zippy').mkdir + tmp = rio('temp:riotmpdir?zippy').mkdir assert(tmp.dir?) assert_match(/^zippy/,tmp.filename.to_s) - assert_match('riotmpdir',tmp.dirname.to_s) + assert_equal('riotmpdir',tmp.dirname.to_s) tmp.close end def test_file_tmpdir_url rio('riotmpdir').delete!.mkdir - tmp = rio('temp:riotmpdir/zippy').file + tmp = rio('temp:riotmpdir?zippy').file assert(tmp.file?) assert_match(/^zippy/,tmp.filename.to_s) - assert_match('riotmpdir',tmp.dirname.to_s) + assert_equal('riotmpdir',tmp.dirname.filename.to_s) tmp.close end def test_file_write rio('riotmpdir').delete!.mkdir - tmp = rio('temp:riotmpdir/zippy') + tmp = rio('temp:riotmpdir?zippy') tmp.puts("Hello Tempfile") assert(tmp.file?) assert(tmp.open?) tmp.close end