Have been trouble debugging this Ruby unit test, but can't figure what I'm doing wrong. Here is the code:
My problem is with the best_sentence_choice method; here is what Textmate is returning to me:
require 'test/unit.rb'
require 'wordplay.rb'
class TestWordPlay < Test::Unit::TestCase
def test_sentences
assert_equal(["a", "b", "c d", "e f g"], "a.b. c d. e f g".sentences)
test_text = %q{Hello. This is a test
of sentence separation. This is the end of the test.}
assert_equal("This is the end of the test", test_text.sentences[2])
end
def test_words
assert_equal(%w{this is a test}, "this is a test".words)
assert_equal(%w{these are mostly words}, "these are, mostly, words".words)
end
# Testing best sentence choice
def test_sentence_choice
assert_equal('This is a great test')
WordPlay.best_sentence(['This is a test', 'This is another test', 'This is a great test']
%w{test great this}))
assert_equal('This is a great tes开发者_StackOverflow社区t', WordPlay.best_sentence(['This is a great test'],
%w{'still the best'}))
end
end
Here is what Textmate is returning:
/Users/pdenlinger/ruby/wordplaylib/wordplaytest.rb:23: syntax error, unexpected tQWORDS_BEG, expecting ')'
%w{test great this}))
^
/Users/pdenlinger/ruby/wordplaylib/wordplaytest.rb:23: syntax error, unexpected ')', expecting kEND
%w{test great this}))
^
Can you help? Thank you!
On this line
WordPlay.best_sentence(['This is a test', 'This is another test', 'This is a great test'] %w{test great this}))
you don't seem to have a comma after the first argument. Then there are two closing parentheses but you have only one opening parentesis.
Please consider editing your question to make the code more readable (hint: if a line starts with 4 spaces and is preceded by an empty line, it'll look like code).
精彩评论