From: Dossy Date: 2002-07-24T03:09:59+09:00 Subject: Re: Strings and member-operators On 2002.07.24, Tom Sawyer wrote: > uh, not without the test suite...but i still had the old message so i > went back and looked at the test suite code and figured it out. jeez. > two simple bloopers a -1 was supposed to be a -2 and i wan't returning > str on a non-match. does this pass now? > > return str[0..0] + str[-1..-1] == '""' ? str[1..-2].strip : str > > i was just trying to do it without regexp. It still doesn't make the tests pass: Loaded suite tc_ts_strip_quotes Started... .... Failure occurred in test_strip_whitespace(StripQuotesTest) [tc_ts_strip_quotes.rb:20]: didn't strip trailing whitespace. Expected but was Finished in 0.003761 seconds. 3 runs, 6 assertions, 1 failures, 0 errors Here's the failed test case, to save you some time: def test_strip_whitespace assert_equal("foo", "foo ".stripQuotes, "didn't strip trailing whitespace") assert_equal("foo", " foo".stripQuotes, "didn't strip leading whitespace") assert_equal("foo", " foo ".stripQuotes, "didn't strip leading and trailing whitespace") assert_equal("foo", "\" foo \"".stripQuotes, "didn't strip leading and trailing whitespace inside double quotes") assert_equal("\"foo\"", " \"foo\" ".stripQuotes, "incorrectly stripped double quotes") end Specifically, it was this one: assert_equal("foo", "foo ".stripQuotes, "didn't strip trailing whitespace") -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)