okay, thanks dossy. so its also suppose to strip the whitspace even when
there are no double quotes. so i need to add #strip :
return str[0…0] + str[-1…-1] == ‘“”’ ? str[1…-2].strip : str.strip
if that dosn’t work, then i’m really missing the point! anyway, it was
just a fun little exercise.
thanks for the fun!
~transami
···
On Tue, 2002-07-23 at 12:09, Dossy wrote:
On 2002.07.24, Tom Sawyer transami@transami.net 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 <foo> but was <foo > Finished in 0.003761 seconds. 3 runs, 6 assertions, 1 failures, 0 errorsHere’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") endSpecifically, 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)
–
~transami