Пример #1
0
 def test_parse_simple_list(self):
     source = '(foo 1 2)'
     tokens = ['foo', '1', '2']
     assert_equals(tokens, parse(source))
Пример #2
0
 def test_parse_quote_tick_on_list(self):
     assert_equals(["quote", ["foo", "bar"]], parse("'(foo bar)"))
     assert_equals(["quote", []], parse("'()"))
Пример #3
0
 def test_parse_on_simple_list(self):
     program = '(foo bar)'
     assert_equals(['foo', 'bar'], parse(program))
Пример #4
0
 def test_parse_quote_tick_on_atom(self):
     assert_equals(["quote", "foo"], parse("'foo"))
     assert_equals(["quote", "+"], parse("'+"))
     assert_equals(["quote", "1"], parse("'1"))
Пример #5
0
 def test_expand_single_quoted_list(self):
     assert_equals(["foo", ["quote", ["+", "1", "2"]]],
                   parse("(foo '(+ 1 2))"))
     assert_equals(["foo", ["quote", ["#t", "#f"]]],
                   parse("(foo '(#t #f))"))
Пример #6
0
 def test_parse_exception_missing_paren(self):
     with assert_raises_regexp(SyntaxError, 'Unbalanced expression'):
         parse('(foo (bar x y)')
Пример #7
0
 def test_expand_single_quoted_symbol(self):
     assert_equals(["foo", ["quote", "bar"]], parse("(foo 'bar)"))
     assert_equals(["foo", ["quote", "t"]], parse("(foo 't)"))
     assert_equals(["foo", ["quote", "+"]], parse("(foo '+)"))
Пример #8
0
 def test_parse_quote_tick_on_atom(self):
     assert_equals(["quote", "foo"], parse("'foo"))
     assert_equals(["quote", "+"], parse("'+"))
     assert_equals(["quote", "1"], parse("'1"))
Пример #9
0
 def test_nested_quotes(self):
     assert_equals(["quote", ["quote", "foo"]], parse("''foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Пример #10
0
 def test_expand_single_quoted_symbol(self):
     assert_equals(["foo", ["quote", "bar"]], parse("(foo 'bar)"))
     assert_equals(["foo", ["quote", "t"]], parse("(foo 't)"))
     assert_equals(["foo", ["quote", "+"]], parse("(foo '+)"))
Пример #11
0
 def test_expand_quotes_with_only_symbols(self):
     assert_equals(["quote", "foo"], parse("'foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Пример #12
0
 def test_parse_exception_extra_paren(self):
     with assert_raises_regexp(SyntaxError, 'Expected EOF'):
         parse('(foo (bar x y)))')
Пример #13
0
 def test_parse_exception_missing_paren(self):
     with assert_raises_regexp(SyntaxError, 'Unbalanced expression'):
         parse('(foo (bar x y)')
Пример #14
0
 def test_parse_on_nested_list(self):
     program = '(foo (bar x y) (baz x))'
     ast = ['foo', 
             ['bar', 'x', 'y'], 
             ['baz', 'x']]
     assert_equals(ast, parse(program))
Пример #15
0
 def test_parse_on_simple_list(self):
     program = '(foo bar)'
     assert_equals(['foo', 'bar'], parse(program))
Пример #16
0
 def test_expand_single_quoted_list(self):
     assert_equals(["foo", ["quote", ["+", "1", "2"]]], parse("(foo '(+ 1 2))"))
     assert_equals(["foo", ["quote", ["#t", "#f"]]], parse("(foo '(#t #f))"))
Пример #17
0
 def test_parse_on_nested_list(self):
     program = '(foo (bar x y) (baz x))'
     ast = ['foo', ['bar', 'x', 'y'], ['baz', 'x']]
     assert_equals(ast, parse(program))
Пример #18
0
 def test_expand_quotes_with_lists(self):
     assert_equals(["quote", ["foo", "bar"]], parse("'(foo bar)"))
     assert_equals(["quote", ["quote", ["quote", ["foo", "bar"]]]], 
         parse("'''(foo bar)"))
Пример #19
0
 def test_parse_exception_extra_paren(self):
     with assert_raises_regexp(SyntaxError, 'Expected EOF'):
         parse('(foo (bar x y)))')
Пример #20
0
 def test_parse_single_atom(self):
     assert_equals('foo', parse('foo'))
Пример #21
0
 def test_expand_quotes_with_only_symbols(self):
     assert_equals(["quote", "foo"], parse("'foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Пример #22
0
 def test_parse_quote_tick_on_list(self):
     assert_equals(["quote", ["foo", "bar"]], parse("'(foo bar)"))
     assert_equals(["quote", []], parse("'()"))
Пример #23
0
 def test_nested_quotes(self):
     assert_equals(["quote", ["quote", "foo"]], parse("''foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Пример #24
0
 def test_nested_quotes_on_lists(self):
     assert_equals(["quote", ["quote", ["foo", "bar"]]], parse("''(foo bar)"))
Пример #25
0
 def test_expand_quotes_with_lists(self):
     assert_equals(["quote", ["foo", "bar"]], parse("'(foo bar)"))
     assert_equals(["quote", ["quote", ["quote", ["foo", "bar"]]]],
                   parse("'''(foo bar)"))
Пример #26
0
 def test_parse_single_atom(self):
     assert_equals('foo', parse('foo'))
Пример #27
0
 def test_nested_quotes_on_lists(self):
     assert_equals(["quote", ["quote", ["foo", "bar"]]],
                   parse("''(foo bar)"))
Пример #28
0
 def test_parse_simple_list(self):
     source = '(foo 1 2)'
     tokens = ['foo', '1', '2']
     assert_equals(tokens, parse(source))