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