本文整理汇总了Python中pycket.test.testhelper.run_fix函数的典型用法代码示例。如果您正苦于以下问题:Python run_fix函数的具体用法?Python run_fix怎么用?Python run_fix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_fix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_cons
def test_cons():
run_fix ("(car (cons 1 2))", 1)
run_fix ("(cdr (cons 1 2))", 2)
with pytest.raises(SchemeException):
run("(car 1)", None)
with pytest.raises(SchemeException):
run("(car 1 2)", None)
开发者ID:rrnewton,项目名称:pycket,代码行数:7,代码来源:test_basic.py
示例2: test_cons
def test_cons():
run_fix ("(car (cons 1 2))", 1)
run_fix ("(cdr (cons 1 2))", 2)
with pytest.raises(Exception):
run("(car 1)", None, expect_to_fail=True)
with pytest.raises(Exception):
run("(car 1 2)", None, expect_to_fail=True)
开发者ID:pycket,项目名称:pycket,代码行数:7,代码来源:test_basic.py
示例3: test_begin0
def test_begin0():
run_fix("(begin0 1 2)", 1)
run_fix("(begin0 1)", 1)
run_fix("(begin0 1 2 3)", 1)
v = run_values("(begin0 (values #t #f) 2 3)")
assert v == [w_true, w_false]
run_fix("(let ([x 1]) (begin0 x (set! x 2)))", 1)
run_fix("(let ([x 10]) (begin0 (set! x 0) (set! x (+ x 1))) x)", 1)
开发者ID:rrnewton,项目名称:pycket,代码行数:8,代码来源:test_basic.py
示例4: test_mcons
def test_mcons():
run_fix ("(mcar (mcons 1 2))", 1)
run_fix ("(mcdr (mcons 1 2))", 2)
run_fix ("(unsafe-mcar (mcons 1 2))", 1)
run_fix ("(unsafe-mcdr (mcons 1 2))", 2)
with pytest.raises(SchemeException):
run("(mcar 1)", None)
with pytest.raises(SchemeException):
run("(mcar 1 2)", None)
开发者ID:magnusmorton,项目名称:pycket,代码行数:9,代码来源:test_basic.py
示例5: test_basic_hl
def test_basic_hl(self):
run_fix("(car (cons 1 2))", 1)
run_fix("(cdr (cons 1 2))", 2)
run_fix("(car (list 1))", 1)
run_fix("(car (cdr (list 1 2)))", 2)
run("(equal? (cons 1 2) (cons 1 2))", w_true)
run("(equal? (cons 1 2) (cons 2 2))", w_false)
run("(equal? (cons 1 2) 'barf)", w_false)
run("(let ((x (cons 1 2))) (equal? x x))", w_true)
run("(equal? (cons 1 (cons 2 3)) (cons 1 (cons 2 3)))", w_true)
run("(equal? (cons 1 (cons 2 3)) (cons 1 (cons 3 3)))", w_false)
run("(equal? (cons 1 (cons 2 3)) (cons 1 (cons 2 4)))", w_false)
开发者ID:8l,项目名称:pycket,代码行数:12,代码来源:test_conses.py
示例6: test_vec_imp
def test_vec_imp():
assert isinstance(run('(impersonate-vector (vector 1) values values)'), W_ImpVector)
run('(vector? (chaperone-vector \'#(0 (2 2 2 2) "Anna") values values))', w_true)
run_fix("(let ([v (impersonate-vector (vector 1 2 3) values values)]) (vector-length v))", 3)
run("(let ([v (impersonate-vector (vector 1 2 3) (lambda (x y z) z) (lambda (x y z) z))]) (vector-set! v 0 0))", w_void)
run_fix("(let ([v (impersonate-vector (vector 1 2 3) (lambda (x y z) z) (lambda (x y z) z))]) (vector-set! v 0 0) (vector-length v))", 3)
run_fix("(let ([v (impersonate-vector (vector 1 2 3) (lambda (x y z) z) (lambda (x y z) z))]) (vector-set! v 0 0) (vector-ref v 0))", 0)
开发者ID:magnusmorton,项目名称:pycket,代码行数:7,代码来源:test_vector.py
示例7: test_vec
def test_vec():
assert isinstance(run('(vector 1)'), W_Vector)
run('(vector? \'#(0 (2 2 2 2) "Anna"))', w_true)
run("(vector? '#())", w_true)
run_fix("(let ([v (vector 1 2 3)]) (vector-length v))", 3)
run("(let ([v (vector 1 2 3)]) (vector-set! v 0 0))", w_void)
run_fix("(let ([v (vector 1 2 3)]) (vector-set! v 0 0) (vector-length v))", 3)
run_fix("(let ([v (vector 1 2 3)]) (vector-set! v 0 0) (vector-ref v 0))", 0)
开发者ID:magnusmorton,项目名称:pycket,代码行数:8,代码来源:test_vector.py
示例8: test_vec
def test_vec():
assert isinstance(run('(vector 1)'), W_Vector)
#run('(vector? (quote #(0 (2 2 2 2)) "Anna"))', w_true)
#run("(vector? (quote #())", w_true)
run_fix("(let-values ([(v) (vector 1 2 3)]) (vector-length v))", 3)
run("(let-values ([(v) (vector 1 2 3)]) (vector-set! v 0 0))", w_void)
run_fix("(let-values ([(v) (vector 1 2 3)]) (vector-set! v 0 0) (vector-length v))", 3)
run_fix("(let-values ([(v) (vector 1 2 3)]) (vector-set! v 0 0) (vector-ref v 0))", 0)
开发者ID:pycket,项目名称:pycket,代码行数:8,代码来源:test_vector.py
示例9: test_fib
def test_fib():
Y = """
(lambda (f)
((lambda (x) (x x))
(lambda (g)
(f (lambda (z) ((g g) z))))))
"""
fac = """
(lambda (f)
(lambda (x)
(if (< x 2)
1
(* x (f (- x 1))))))
"""
fib = """
(lambda (f)
(lambda (x)
(if (< x 2)
x
(+ (f (- x 1)) (f (- x 2))))))
"""
run_fix("((%s %s) 2)"%(Y,fib), 1)
run_fix("((%s %s) 2)"%(Y,fac), 2)
开发者ID:rrnewton,项目名称:pycket,代码行数:24,代码来源:test_basic.py
示例10: test_reclambda
def test_reclambda():
run_fix("((letrec ([c (lambda (n) (if (< n 0) 1 (c (- n 1))))]) c) 10)", 1)
run_fix("""
((letrec ([c (lambda (n) (let ([ind (lambda (n) (display n) (if (< n 0) 1 (c (- n 1))))]) (ind n)))]) c) 10)""", 1)
run_fix("""
(let ()
(define (nested n)
(let countdown ([i n]) (if (< i 0) 1 (countdown (- i 1))))
(if (< n 0) 1 (nested (- n 1))))
(nested 10))""", 1)
开发者ID:rrnewton,项目名称:pycket,代码行数:10,代码来源:test_basic.py
示例11: test_reclambda
def test_reclambda():
run_fix("((letrec-values ([(c) (lambda (n) (if (< n 0) 1 (c (- n 1))))]) c) 10)", 1)
run_fix("""
((letrec-values ([(c) (lambda (n) (let-values ([(ind) (lambda (n) (begin (display n) (if (< n 0) 1 (c (- n 1)))))]) (ind n)))]) c) 10)""", 1)
run_fix("""
(letrec-values ([(nested) (lambda (n)
(begin
(letrec-values ([(countdown) (lambda (i) (if (< i 0) 1 (countdown (- i 1))))]) (countdown n))
(if (< n 0) 1 (nested (- n 1)))))])
(nested 10))""", 1)
开发者ID:pycket,项目名称:pycket,代码行数:10,代码来源:test_basic.py
示例12: test_values
def test_values():
run_fix("(values 1)", 1)
run_fix("(let () (values 1 2) (values 3))", 3)
prog = "(let () (call/cc (lambda (k) (k 1 2))) 3)"
run_fix(prog, 3)
v = run_values("(values #t #f)")
assert [w_true, w_false] == v
run_fix("(call-with-values (lambda () (values 1 2)) (lambda (a b) (+ a b)))", 3)
run_fix("(call-with-values (lambda () (values 1 2)) +)", 3)
run_fix("(call-with-values (lambda () (values)) (lambda () 0))", 0)
run_fix("(call-with-values (lambda () (values 1)) (lambda (x) x))", 1)
run_fix("(call-with-values (lambda () (values 1)) values)", 1)
run_fix("(call-with-values (lambda () 1) values)", 1)
run_fix("""
(call-with-values (lambda () (time-apply (lambda () (+ 1 2)) '()))
(lambda (result t r gc) (and (fixnum? t) (fixnum? r) (fixnum? gc)
(car result))))
""", 3)
开发者ID:rrnewton,项目名称:pycket,代码行数:18,代码来源:test_basic.py
示例13: test_letrec
def test_letrec():
run_fix("(letrec ([x 1]) x)", 1)
run_fix("(letrec ([x 1] [y 2]) y)", 2)
run_fix("(letrec ([x 1] [y 2]) (+ x y))", 3)
run_fix("(let ([x 0]) (letrec ([x 1] [y x]) (+ x y)))", 2)
run_fix("(letrec ([x (lambda (z) x)]) 2)", 2)
开发者ID:rrnewton,项目名称:pycket,代码行数:6,代码来源:test_basic.py
示例14: test_arith_minus_one_arg_bug
def test_arith_minus_one_arg_bug():
run_fix("(- 1)", -1)
开发者ID:rrnewton,项目名称:pycket,代码行数:2,代码来源:test_basic.py
示例15: test_arith
def test_arith():
run_fix("(+ 1 2)", 3)
run_fix("(* 1 2)", 2)
run_fix("(- 1 2)", -1)
run_fix("(* -1 2)", -2)
开发者ID:rrnewton,项目名称:pycket,代码行数:5,代码来源:test_basic.py
示例16: test_curry
def test_curry():
prog = "(((lambda (y) (lambda (x) (+ x y))) 2) 3)"
run_fix(prog, 5)
开发者ID:rrnewton,项目名称:pycket,代码行数:3,代码来源:test_basic.py
示例17: test_call
def test_call():
prog = "((lambda (x) (+ x 1)) 2)"
run_fix(prog, 3)
开发者ID:rrnewton,项目名称:pycket,代码行数:3,代码来源:test_basic.py
示例18: test_thunk2
def test_thunk2():
prog = "((lambda () 1 2))"
run_fix(prog, 2)
开发者ID:rrnewton,项目名称:pycket,代码行数:3,代码来源:test_basic.py
示例19: test_thunk
def test_thunk():
prog = "((lambda () 1))"
run_fix(prog, 1)
开发者ID:rrnewton,项目名称:pycket,代码行数:3,代码来源:test_basic.py
示例20: test_arithmetic
def test_arithmetic():
run_fix("(+ )", 0)
run_fix("(+ 1)", 1)
run_fix("(+ 2 3)", 5)
run_fix("(+ 2 3 4)", 9)
with pytest.raises(SchemeException):
run_fix("(- )", 0)
run_fix("(- 1)", -1)
run_fix("(- 2 3)", -1)
run_fix("(- 2 3 4)", -5)
run_fix("(* )", 1)
run_fix("(* 2)", 2)
run_fix("(* 2 3)", 6)
run_fix("(* 2 3 4)", 24)
with pytest.raises(SchemeException):
run_flo("(/ )", 0)
run_flo("(/ 2.0)", 0.5)
run_flo("(/ 2. 3.)", 2. / 3.)
run_flo("(/ 2. 3. 4.)", 2. / 3. / 4.)
开发者ID:rrnewton,项目名称:pycket,代码行数:22,代码来源:test_basic.py
注:本文中的pycket.test.testhelper.run_fix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论