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)))
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)
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'))
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"))
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"))
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")
def test_against_str(self): x = keyword('x') self.assertFalse(x is 'x') self.assertNotEqual(x, 'x') self.assertNotEqual('x', x)
def test_against_symbol(self): xk = keyword("x") xs = symbol("x") self.assertFalse(xk is xs) self.assertNotEqual(xk, xs) self.assertNotEqual(xs, xk)
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)))
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"))
"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]
def test_repr_str(self): x = keyword('x') self.assertEqual(repr(x), "<keyword 'x'>") self.assertEqual(str(x), 'x')
"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]