def test_directions(): assert_equal(lexicon.scan("north"), [('direction', 'north')]) result = lexicon.scan("north south east") assert_equal(result, [('direction', 'north'), ('direction', 'south'), ('direction', 'east')])
def test_numbers(): assert_equal(lexicon.scan("1234"), [('number', 1234)]) result = lexicon.scan("3 91234") assert_equal(result, [('number', 3), ('number', 91234)])
def test_errors(): assert_equal(lexicon.scan("ASDFDFASDF"), [('error', 'asdfdfasdf')]) result = lexicon.scan("spot IAS troi") assert_equal(result, [('noun', 'spot'), ('error', 'ias'), ('noun', 'troi')])
def test_stops(): assert_equal(lexicon.scan("the"), [('stop', 'the')]) result = lexicon.scan("the in of") assert_equal(result, [('stop', 'the'), ('stop', 'in'), ('stop', 'of')])
def test_nouns(): assert_equal(lexicon.scan("troi"), [('noun', 'troi')]) result = lexicon.scan("troi panties") assert_equal(result, [('noun', 'troi'), ('noun', 'panties')])
def test_bad_sentence(): t_list = lexicon.scan("riker north the") assert_raises(parser.ParserError, parser.parse_sentence, t_list)
def test_verbs(): assert_equal(lexicon.scan("go"), [('verb', 'go')]) result = lexicon.scan("go kill eat") assert_equal(result, [('verb', 'go'), ('verb', 'kill'), ('verb', 'eat')])
def test_stops(): t_list = lexicon.scan("kill the riker") result = parser.parse_sentence(t_list) assert_equal(result.subject, 'player') assert_equal(result.verb, 'kill') assert_equal(result.object, 'riker')
def test_direction_sentence(): t_list = lexicon.scan("go north") result = parser.parse_sentence(t_list) assert_equal(result.subject, 'player') assert_equal(result.object, 'north') assert_equal(result.verb, 'go')