Exemplo n.º 1
0
Arquivo: if_.py Projeto: kdps/cell
def if_(env, t, then_fn, else_fn):
    if t[0] != "number":
        raise Exception(
            ("Only numbers may be passed to an if, but I was passed '%s'") %
            str(t))
    to_call = then_fn if t[1] != 0 else else_fn
    return eval_expr(("call", to_call, []), env)
Exemplo n.º 2
0
def if_(env, t, then_fn, else_fn):
    if t[0] != "number":
        raise Exception(
            (
                "Only numbers may be passed to an if, but I was passed '%s'"
            ) % str(t)
        )
    to_call = then_fn if t[1] != 0 else else_fn
    return eval_expr(("call", to_call, []), env)
Exemplo n.º 3
0
def None_evaluates_to_None():
    assert_that(eval_expr(("none", ), Env()), equals(("none", )))
Exemplo n.º 4
0
 def dumb_if_equal(env, val1, val2, then_fn, else_fn):
     if val1 == val2:
         ret = then_fn
     else:
         ret = else_fn
     return eval_expr(("call", ret, []), env)
Exemplo n.º 5
0
def None_evaluates_to_None():
    assert_that(eval_expr(("none",), Env()), equals(("none", )))
Exemplo n.º 6
0
 def dumb_if_equal(env, val1, val2, then_fn, else_fn):
     if val1 == val2:
         ret = then_fn
     else:
         ret = else_fn
     return eval_expr(("call", ret, []), env)