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