Esempio n. 1
0
 def test_parse_simple_list(self):
     source = '(foo 1 2)'
     tokens = ['foo', '1', '2']
     assert_equals(tokens, parse(source))
Esempio n. 2
0
 def test_parse_quote_tick_on_list(self):
     assert_equals(["quote", ["foo", "bar"]], parse("'(foo bar)"))
     assert_equals(["quote", []], parse("'()"))
Esempio n. 3
0
 def test_parse_on_simple_list(self):
     program = '(foo bar)'
     assert_equals(['foo', 'bar'], parse(program))
Esempio n. 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"))
Esempio n. 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))"))
Esempio n. 6
0
 def test_parse_exception_missing_paren(self):
     with assert_raises_regexp(SyntaxError, 'Unbalanced expression'):
         parse('(foo (bar x y)')
Esempio n. 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 '+)"))
Esempio n. 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"))
Esempio n. 9
0
 def test_nested_quotes(self):
     assert_equals(["quote", ["quote", "foo"]], parse("''foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Esempio n. 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 '+)"))
Esempio n. 11
0
 def test_expand_quotes_with_only_symbols(self):
     assert_equals(["quote", "foo"], parse("'foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Esempio n. 12
0
 def test_parse_exception_extra_paren(self):
     with assert_raises_regexp(SyntaxError, 'Expected EOF'):
         parse('(foo (bar x y)))')
Esempio n. 13
0
 def test_parse_exception_missing_paren(self):
     with assert_raises_regexp(SyntaxError, 'Unbalanced expression'):
         parse('(foo (bar x y)')
Esempio n. 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))
Esempio n. 15
0
 def test_parse_on_simple_list(self):
     program = '(foo bar)'
     assert_equals(['foo', 'bar'], parse(program))
Esempio n. 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))"))
Esempio n. 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))
Esempio n. 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)"))
Esempio n. 19
0
 def test_parse_exception_extra_paren(self):
     with assert_raises_regexp(SyntaxError, 'Expected EOF'):
         parse('(foo (bar x y)))')
Esempio n. 20
0
 def test_parse_single_atom(self):
     assert_equals('foo', parse('foo'))
Esempio n. 21
0
 def test_expand_quotes_with_only_symbols(self):
     assert_equals(["quote", "foo"], parse("'foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Esempio n. 22
0
 def test_parse_quote_tick_on_list(self):
     assert_equals(["quote", ["foo", "bar"]], parse("'(foo bar)"))
     assert_equals(["quote", []], parse("'()"))
Esempio n. 23
0
 def test_nested_quotes(self):
     assert_equals(["quote", ["quote", "foo"]], parse("''foo"))
     assert_equals(["quote", ["quote", ["quote", "foo"]]], parse("'''foo"))
Esempio n. 24
0
 def test_nested_quotes_on_lists(self):
     assert_equals(["quote", ["quote", ["foo", "bar"]]], parse("''(foo bar)"))
Esempio n. 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)"))
Esempio n. 26
0
 def test_parse_single_atom(self):
     assert_equals('foo', parse('foo'))
Esempio n. 27
0
 def test_nested_quotes_on_lists(self):
     assert_equals(["quote", ["quote", ["foo", "bar"]]],
                   parse("''(foo bar)"))
Esempio n. 28
0
 def test_parse_simple_list(self):
     source = '(foo 1 2)'
     tokens = ['foo', '1', '2']
     assert_equals(tokens, parse(source))