From: "Morris, Chris" Date: 2002-04-27T01:01:14+09:00 Subject: RE: expand_path and overlap > Hmmm, it apparently passes. Only 4th test failed. For me, the 1st test still fails: 1.6.6 i586-mswin32 Loaded suite S:\SF-scrapware\scrapware\clwiki\collapse_path Started... .. Failure occurred in test_collapse_path(TC_collapse_path) [S:\SF-scrapware\scrapw are\clwiki\collapse_path.rb:14]: Expected but was Finished in 0.041 seconds. 1 runs, 1 assertions, 1 failures, 0 errors --snip-- def collapse_path(path, base) head, = path.split("/", 2) base.rindex(%r"(\A|.*/)#{Regexp.quote(head)}(?:/|\z)") ($1 or base.sub(%r|[^/]\z|, '\&/')) + path end if $0 == __FILE__ require "test/unit" puts RUBY_VERSION, RUBY_PLATFORM class TC_collapse_path < Test::Unit::TestCase def test_collapse_path assert_equal("/a/b/c", collapse_path("b/c", "/a/b/c/d/e")) assert_equal("/a/b", collapse_path("b", "/a/b/c/d/e")) assert_equal("/a/b/c/f", collapse_path("b/c/f", "/a/b/c/d/e")) assert_equal("/a/b/c/d/e/m/n/o", collapse_path("m/n/o", "/a/b/c/d/e")) assert_equal("/a/b/c/a/b/d", collapse_path("a/b/d", "/a/b/c/a/b/c")) end end end