def test_kwswitch(): i = Literal() ab = scope.kwswitch(i, k1="a", k2="b", err=scope.Raise(Exception)) assert rec_eval(ab, memo={i: "k1"}) == "a" assert rec_eval(ab, memo={i: "k2"}) == "b" assert_raises(Exception, rec_eval, ab, memo={i: "err"})
def test_kwswitch(): i = Literal() ab = scope.kwswitch(i, k1='a', k2='b', err=scope.Raise(Exception)) assert rec_eval(ab, memo={i: 'k1'}) == 'a' assert rec_eval(ab, memo={i: 'k2'}) == 'b' assert_raises(Exception, rec_eval, ab, memo={i: 'err'})
def test_switch_and_Raise(): i = Literal() ab = scope.switch(i, "a", "b", scope.Raise(Exception)) assert rec_eval(ab, memo={i: 0}) == "a" assert rec_eval(ab, memo={i: 1}) == "b" assert_raises(Exception, rec_eval, ab, memo={i: 2})
def test_switch_and_Raise(): i = Literal() ab = scope.switch(i, 'a', 'b', scope.Raise(Exception)) assert rec_eval(ab, memo={i: 0}) == 'a' assert rec_eval(ab, memo={i: 1}) == 'b' assert_raises(Exception, rec_eval, ab, memo={i: 2})