I am currently going through Zed A. Shaw's book Learn Ruby the hard way and I am having trouble understanding exercise 48. What I don't understand is this piece of test code:
class LexiconTests < Test::Unit::TestCase
Pair = Lexicon::Pair
@@lexicon = Lexicon.new()
def test_directions()
assert_equal([Pair.new(:direction, 'north')], @@lexicon.scan("north"))
result = @@lexicon.scan("north south east")
assert_equal(result, [Pair.new(:direction, 'north'),
Pair.new(:direction, 'south'),
Pair.new(:direction, 'east')])
end
Why do we need to use Pair = Lexicon::Pair? What does this piece of code create?
Aucun commentaire:
Enregistrer un commentaire