def test_set_car_cdr(): cons = V(VT.CONS, Cons(V(VT.NUMBER, 1), V(VT.NUMBER, 2))) handle('set_car', [cons, V(VT.BOOLEAN, True)]) assert cons.value.car == V(VT.BOOLEAN, True) handle('set_cdr', [cons, V(VT.BOOLEAN, False)]) assert cons.value.cdr == V(VT.BOOLEAN, False)
def test_concat(test_case): conses = [V.list_to_cons(l) for l in test_case] expected = [] for sublist in test_case: expected.extend(sublist) assert V.list_to_cons(expected) == handle('concat', conses)
def test_boolean(op, test_case, expected): assert handle(op, test_case) == V(VT.BOOLEAN, expected)
def test_cons(op, test_case, expected): assert handle(op, test_case) == expected
def test_numerical(op, test_case, expected): args = [V(VT.NUMBER, a) for a in test_case] actual_result = handle(op, args) assert actual_result == V(VT.NUMBER, expected)