示例#1
0
    def test_keyword_2(self):
        w = "X"
        x = keyword(w)
        y = keyword(str(x))
        z = keyword(str(y))

        self.assertEqual(x, x)
        self.assertEqual(x, y)
        self.assertEqual(x, z)
        self.assertEqual(y, x)
        self.assertEqual(y, y)
        self.assertEqual(y, z)
        self.assertEqual(z, x)
        self.assertEqual(z, y)
        self.assertEqual(z, z)

        self.assertEqual(id(x), id(y))
        self.assertEqual(id(y), id(z))

        self.assertTrue(x is y)
        self.assertTrue(y is z)

        self.assertEqual(id(w), id(str(x)))
        self.assertEqual(id(w), id(str(y)))
        self.assertEqual(id(w), id(str(z)))
示例#2
0
    def test_keyword_2(self):
        w = "X"
        x = keyword(w)
        y = keyword(str(x))
        z = keyword(str(y))

        self.assertEqual(x, x)
        self.assertEqual(x, y)
        self.assertEqual(x, z)
        self.assertEqual(y, x)
        self.assertEqual(y, y)
        self.assertEqual(y, z)
        self.assertEqual(z, x)
        self.assertEqual(z, y)
        self.assertEqual(z, z)

        self.assertEqual(id(x), id(y))
        self.assertEqual(id(y), id(z))

        self.assertTrue(x is y)
        self.assertTrue(y is z)

        self.assertEqual(id(w), id(str(x)))
        self.assertEqual(id(w), id(str(y)))
        self.assertEqual(id(w), id(str(z)))
示例#3
0
    def test_keyword(self):
        x = keyword('x')
        y = keyword('x')
        z = keyword(x)

        self.assertTrue(is_keyword(x))
        self.assertIsInstance(x, keyword)

        self.assertEqual(x, x)
        self.assertEqual(x, y)
        self.assertEqual(x, z)
        self.assertEqual(y, x)
        self.assertEqual(y, y)
        self.assertEqual(y, z)
        self.assertEqual(z, x)
        self.assertEqual(z, y)
        self.assertEqual(z, z)

        self.assertEqual(id(x), id(y))
        self.assertEqual(id(y), id(z))

        self.assertTrue(x is y)
        self.assertTrue(y is z)

        w = keyword('w')

        self.assertNotEqual(x, w)
        self.assertNotEqual(w, x)
        self.assertFalse(x is w)
示例#4
0
    def test_keyword(self):
        x = keyword('x')
        y = keyword('x')
        z = keyword(x)

        self.assertTrue(is_keyword(x))
        self.assertIsInstance(x, keyword)

        self.assertEqual(x, x)
        self.assertEqual(x, y)
        self.assertEqual(x, z)
        self.assertEqual(y, x)
        self.assertEqual(y, y)
        self.assertEqual(y, z)
        self.assertEqual(z, x)
        self.assertEqual(z, y)
        self.assertEqual(z, z)

        self.assertEqual(id(x), id(y))
        self.assertEqual(id(y), id(z))

        self.assertTrue(x is y)
        self.assertTrue(y is z)

        w = keyword('w')

        self.assertNotEqual(x, w)
        self.assertNotEqual(w, x)
        self.assertFalse(x is w)
示例#5
0
    def test_len(self):
        empty = keyword('')
        short = keyword('1')
        more = keyword('sibilant')

        self.assertEqual(len(empty), len(''))
        self.assertEqual(len(short), len('1'))
        self.assertEqual(len(more), len('sibilant'))
示例#6
0
    def test_keyword(self):
        src = ":tacos"
        stmt, env = compile_expr(src)
        self.assertIs(stmt(), keyword("tacos"))

        src = "tacos:"
        stmt, env = compile_expr(src)
        self.assertIs(stmt(), keyword("tacos"))

        src = ":tacos:"
        stmt, env = compile_expr(src)
        self.assertIs(stmt(), keyword("tacos"))
示例#7
0
    def test_keyword(self):
        src = ":tacos"
        stmt, env = compile_expr(src)
        self.assertIs(stmt(), keyword("tacos"))

        src = "tacos:"
        stmt, env = compile_expr(src)
        self.assertIs(stmt(), keyword("tacos"))

        src = ":tacos:"
        stmt, env = compile_expr(src)
        self.assertIs(stmt(), keyword("tacos"))
示例#8
0
    def test_quote_keyword(self):
        src = "':tacos"
        stmt, env = compile_expr(src, tacos=5)
        self.assertIs(stmt(), keyword("tacos"))

        src = "'tacos:"
        stmt, env = compile_expr(src, tacos=5)
        self.assertIs(stmt(), keyword("tacos"))

        src = "':tacos:"
        stmt, env = compile_expr(src, tacos=5)
        self.assertIs(stmt(), keyword("tacos"))
示例#9
0
    def test_quote_keyword(self):
        src = "':tacos"
        stmt, env = compile_expr(src, tacos=5)
        self.assertIs(stmt(), keyword("tacos"))

        src = "'tacos:"
        stmt, env = compile_expr(src, tacos=5)
        self.assertIs(stmt(), keyword("tacos"))

        src = "':tacos:"
        stmt, env = compile_expr(src, tacos=5)
        self.assertIs(stmt(), keyword("tacos"))
示例#10
0
    def test_dict(self):
        x = keyword('x')
        y = keyword('y')

        d = dict()
        d[x] = "cookies"
        d[y] = "cake"
        d['x'] = "chicken"
        d['y'] = "tuna"

        self.assertEqual(d[x], "cookies")
        self.assertEqual(d[y], "cake")
        self.assertEqual(d['x'], "chicken")
        self.assertEqual(d['y'], "tuna")
示例#11
0
    def test_dict(self):
        x = keyword('x')
        y = keyword('y')

        d = dict()
        d[x] = "cookies"
        d[y] = "cake"
        d['x'] = "chicken"
        d['y'] = "tuna"

        self.assertEqual(d[x], "cookies")
        self.assertEqual(d[y], "cake")
        self.assertEqual(d['x'], "chicken")
        self.assertEqual(d['y'], "tuna")
示例#12
0
    def test_against_str(self):
        x = keyword('x')

        self.assertFalse(x is 'x')

        self.assertNotEqual(x, 'x')
        self.assertNotEqual('x', x)
示例#13
0
    def test_against_symbol(self):
        xk = keyword("x")
        xs = symbol("x")

        self.assertFalse(xk is xs)
        self.assertNotEqual(xk, xs)
        self.assertNotEqual(xs, xk)
示例#14
0
    def test_against_str(self):
        x = keyword('x')

        self.assertFalse(x is 'x')

        self.assertNotEqual(x, 'x')
        self.assertNotEqual('x', x)
示例#15
0
    def test_simple(self):
        self.qq("`1", 1)
        self.qq("`,1", 1)

        self.qq("`tacos",
                symbol("tacos"))

        self.qq("`:tacos",
                keyword("tacos"))

        self.qq("`nil",
                symbol("nil"))

        self.qq("`()",
                nil)

        self.qq("`(1 2 3 ,4 ,5)",
                cons(1, 2, 3, 4, 5, nil))

        self.qq("`(1 2 3 ,A ,B Z)",
                cons(1, 2, 3, 4, 5, symbol("Z"), nil),
                A=4, B=5)

        self.qq("`(1 2 ,(foo 3 6))",
                cons(1, 2, [3, 4, 5], nil),
                foo=lambda a, b: list(range(a,b)))
示例#16
0
    def test_against_symbol(self):
        xk = keyword("x")
        xs = symbol("x")

        self.assertFalse(xk is xs)
        self.assertNotEqual(xk, xs)
        self.assertNotEqual(xs, xk)
示例#17
0
    def test_keyword(self):
        src = ":x"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = "x:"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = ":x:"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = ":x"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = "x:"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = ":number-1"
        col = parse_source(src)
        self.assertIs(col, keyword("number-1"))

        src = "number-1:"
        col = parse_source(src)
        self.assertIs(col, keyword("number-1"))
示例#18
0
    def test_keyword(self):
        src = ":x"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = "x:"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = ":x:"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = ":x"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = "x:"
        col = parse_source(src)
        self.assertIs(col, keyword("x"))

        src = ":number-1"
        col = parse_source(src)
        self.assertIs(col, keyword("number-1"))

        src = "number-1:"
        col = parse_source(src)
        self.assertIs(col, keyword("number-1"))
示例#19
0
    "is_compiled",
    "Special",
    "is_special",
    "Macro",
    "is_macro",
    "Alias",
    "is_alias",
    "Operator",
    "is_operator",
    "gather_formals",
    "gather_parameters",
    "env_find_compiled",
    "env_get_expander",
)

_keyword_star = keyword("*")
_keyword_starstar = keyword("**")

_symbol_attr = symbol("attr")
_symbol_nil = symbol("nil")
_symbol_None = symbol("None")
_symbol_True = symbol("True")
_symbol_False = symbol("False")
_symbol_ellipsis = symbol("...")
_symbol_keyword = symbol("keyword")
_symbol_tailcall = symbol("tailcall")
_symbol_tailcall_full = symbol("tailcall-full")
_symbol_tcr_frame = symbol("__tcr_frame_vars__")

Symbol = Union[lazygensym, symbol]
示例#20
0
 def test_repr_str(self):
     x = keyword('x')
     self.assertEqual(repr(x), "<keyword 'x'>")
     self.assertEqual(str(x), 'x')
示例#21
0
 def test_repr_str(self):
     x = keyword('x')
     self.assertEqual(repr(x), "<keyword 'x'>")
     self.assertEqual(str(x), 'x')
示例#22
0
    "UnsupportedVersion",
    "CompilerSyntaxError",
    "Mode",
    "SibilantCompiler",
    "compiler_for_version",
    "Compiled", "is_compiled",
    "Special", "is_special",
    "Macro", "is_macro",
    "Alias", "is_alias",
    "Operator", "is_operator",
    "gather_formals", "gather_parameters",
    "env_find_compiled", "env_get_expander",
)


_keyword_star = keyword("*")
_keyword_starstar = keyword("**")

_symbol_attr = symbol("attr")
_symbol_nil = symbol("nil")
_symbol_None = symbol("None")
_symbol_True = symbol("True")
_symbol_False = symbol("False")
_symbol_ellipsis = symbol("...")
_symbol_keyword = symbol("keyword")
_symbol_tailcall = symbol("tailcall")
_symbol_tailcall_full = symbol("tailcall-full")
_symbol_tcr_frame = symbol("__tcr_frame_vars__")

Symbol = Union[lazygensym, symbol]