예제 #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))