本文整理汇总了Python中pycket.test.testhelper.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的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_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
示例3: test_vec_strategies_empty
def test_vec_strategies_empty():
vec = run("(vector)")
print "First size: %s" % vec.length()
assert isinstance(vec.strategy, ObjectVectorStrategy)
vec = run("(make-vector 0)")
print "Second size: %s" % vec.length()
assert isinstance(vec.strategy, ObjectVectorStrategy)
开发者ID:8l,项目名称:pycket,代码行数:7,代码来源:test_vector.py
示例4: test_quotient
def test_quotient():
run_fix("(quotient 0 1)", 0)
run_fix("(quotient 0 -1)", 0)
run_fix("(quotient 0 2)", 0)
run_fix("(quotient 0 -2)", 0)
run_fix("(quotient 0 3)", 0)
run_fix("(quotient 1 1)", 1)
run_fix("(quotient -1 1)", -1)
run_fix("(quotient 1 -1)", -1)
run_fix("(quotient -1 -1)", 1)
run_fix("(quotient 1 2)", 0)
run_fix("(quotient -1 2)", 0)
run_fix("(quotient 1 -2)", 0)
run_fix("(quotient -1 -2)", 0)
run_fix("(quotient -1234 -10)", 123)
run_fix("(quotient 1234 1234)", 1)
big = 2 ** 70
run_fix("(quotient %s %s)" % (big, big), 1)
run_fix("(quotient %s %s)" % (-big, big), -1)
run_fix("(quotient %s %s)" % (big, -big), -1)
run_fix("(quotient %s %s)" % (-big, -big), 1)
run_fix("(quotient %s %s)" % (big+1, big), 1)
run_fix("(quotient %s %s)" % (-(big+1), big), -1)
res = run(str(big / 2))
run("(quotient %s 2)" % (big, ), res)
res = run("(quotient 8.0 2.0)")
assert isinstance(res, W_Flonum) and res.value == 4.0
res = run("(quotient 1.0 2.0)")
assert isinstance(res, W_Flonum) and res.value == 0.5
开发者ID:8l,项目名称:pycket,代码行数:30,代码来源:test_arithmetic.py
示例5: test_quotient
def test_quotient():
run_fix("(quotient 0 1)", 0)
run_fix("(quotient 0 -1)", 0)
run_fix("(quotient 0 2)", 0)
run_fix("(quotient 0 -2)", 0)
run_fix("(quotient 0 3)", 0)
run_fix("(quotient 1 1)", 1)
run_fix("(quotient -1 1)", -1)
run_fix("(quotient 1 -1)", -1)
run_fix("(quotient -1 -1)", 1)
run_fix("(quotient 1 2)", 0)
run_fix("(quotient -1 2)", 0)
run_fix("(quotient 1 -2)", 0)
run_fix("(quotient -1 -2)", 0)
run_fix("(quotient -1234 -10)", 123)
run_fix("(quotient 1234 1234)", 1)
big = 2 ** 70
run_fix("(quotient %s %s)" % (big, big), 1)
run_fix("(quotient %s %s)" % (-big, big), -1)
run_fix("(quotient %s %s)" % (big, -big), -1)
run_fix("(quotient %s %s)" % (-big, -big), 1)
run_fix("(quotient %s %s)" % (big+1, big), 1)
run_fix("(quotient %s %s)" % (-(big+1), big), -1)
res = run(str(big / 2))
run("(quotient %s 2)" % (big, ), res)
开发者ID:rrnewton,项目名称:pycket,代码行数:25,代码来源:test_arithmetic.py
示例6: 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
示例7: test_vec_strategies_dehomogenize
def test_vec_strategies_dehomogenize():
vec = run('(let ([vec (vector 1 2 3)]) (vector-set! vec 1 "Anna") vec)')
assert isinstance(vec.strategy, ObjectVectorStrategy)
vec = run('(let ([vec (make-vector 3 1)]) (vector-set! vec 1 "Anna") vec)')
assert isinstance(vec.strategy, ObjectVectorStrategy)
vec = run('(let ([vec (make-vector 3 1)]) (vector-set! vec 1 2) vec)')
assert isinstance(vec.strategy, FixnumVectorStrategy)
开发者ID:magnusmorton,项目名称:pycket,代码行数:7,代码来源: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_copy_vector_strategy_preserve
def test_copy_vector_strategy_preserve():
vec = run("(vector->immutable-vector (vector 1.0 2.0 3.0))")
assert vec.strategy is FlonumImmutableVectorStrategy.singleton
vec = run("(vector->immutable-vector (vector 1 2 3))")
assert vec.strategy is FixnumImmutableVectorStrategy.singleton
vec = run(r"(vector->immutable-vector (vector #\a #\b #\c))")
assert vec.strategy is CharacterImmutableVectorStrategy.singleton
vec = run(r"(vector->immutable-vector (vector #\a #\b #\c 1 1.0))")
assert vec.strategy is ObjectImmutableVectorStrategy.singleton
开发者ID:magnusmorton,项目名称:pycket,代码行数:9,代码来源:test_vector.py
示例10: 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
示例11: test_mcons
def test_mcons():
run_fix ("(mcar (mcons 1 2))", 1)
run_fix ("(mcdr (mcons 1 2))", 2)
if pytest.config.load_expander:
run_fix ("(begin (#%require (quote #%unsafe)) (unsafe-mcar (mcons 1 2)))", 1)
run_fix ("(begin (#%require (quote #%unsafe)) (unsafe-mcdr (mcons 1 2)))", 2)
else:
run_fix ("(unsafe-mcar (mcons 1 2))", 1)
run_fix ("(unsafe-mcdr (mcons 1 2))", 2)
with pytest.raises(Exception):
run("(mcar 1)", None, expect_to_fail=True)
with pytest.raises(Exception):
run("(mcar 1 2)", None, expect_to_fail=True)
开发者ID:pycket,项目名称:pycket,代码行数:13,代码来源:test_basic.py
示例12: 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
示例13: test_vec_strategies_stays_flonum
def test_vec_strategies_stays_flonum():
vec = run("(let ([vec (vector 1.2 1.2 1.2)]) (vector-set! vec 1 5.5) vec)")
assert isinstance(vec.strategy, FlonumVectorStrategy)
vec = run("(let ([vec (vector 1.2 1.2 1.2)]) (vector-set! vec 1 0) vec)")
# Test that we can encode the full range of signed 32-bit values in the tagged
# flonum strategy
assert isinstance(vec.strategy, FlonumTaggedVectorStrategy)
vec = run("(let ([vec (vector 1.2 1.2 1.2)]) (vector-set! vec 1 %d) vec)" % (2 ** 31 - 1))
assert isinstance(vec.strategy, FlonumTaggedVectorStrategy)
vec = run("(let ([vec (vector 1.2 1.2 1.2)]) (vector-set! vec 1 %d) vec)" % (-(2 ** 31)))
assert isinstance(vec.strategy, FlonumTaggedVectorStrategy)
# Test transitions from the constant vector strategy to the tagged flonum strategy
vec = run("(let ([vec (make-vector 10 0)]) (vector-set! vec 1 1.1) vec)")
assert isinstance(vec.strategy, FlonumTaggedVectorStrategy)
vec = run("(let ([vec (make-vector 10 %d)]) (vector-set! vec 1 1.1) vec)" % (2 ** 31 - 1))
assert isinstance(vec.strategy, FlonumTaggedVectorStrategy)
vec = run("(let ([vec (make-vector 10 %d)]) (vector-set! vec 1 1.1) vec)" % (-(2 ** 31)))
assert isinstance(vec.strategy, FlonumTaggedVectorStrategy)
开发者ID:magnusmorton,项目名称:pycket,代码行数:20,代码来源:test_vector.py
示例14: test_eq
def test_eq():
run("(eq? 'yes 'yes)", w_true)
run("(eq? 'yes 'no)", w_false)
run("(let ([v (mcons 1 2)]) (eq? v v))", w_true)
run("(eq? (mcons 1 2) (mcons 1 2))", w_false)
#run_top("(eq? (make-string 3 #\z) (make-string 3 #\z))", w_false, stdlib=True)
run("(eq? 'a 'a)", w_true)
run("(eq? '(a) '(a))", w_false) #racket
run("(eq? (list 'a) (list 'a))", w_false)
# run('(eq? "a" "a")', w_true) #racket
# run('(eq? "" "")', w_true) #racket
run("(eq? '() '())", w_true)
run("(eq? 2 2)", w_true) #racket
run("(eq? #\A #\A)", w_true) #racket
run("(eq? car car)", w_true)
run("(let ((n (+ 2 3)))(eq? n n))", w_true) #racket
run("(let ((x '(a)))(eq? x x))", w_true)
run("(let ((x '#()))(eq? x x))", w_true)
run("(let ((p (lambda (x) x))) (eq? p p))", w_true)
开发者ID:rrnewton,项目名称:pycket,代码行数:20,代码来源:test_basic.py
示例15: test_keyword
def test_keyword():
run("'#:foo", W_Keyword.make("foo"))
开发者ID:rrnewton,项目名称:pycket,代码行数:2,代码来源:test_basic.py
示例16: test_vararg
def test_vararg():
run_fix ("((lambda x (car x)) 1)", 1)
run_fix ("((lambda (a . x) a) 1)", 1)
run ("((lambda (a . x) x) 1)", w_null)
开发者ID:rrnewton,项目名称:pycket,代码行数:4,代码来源:test_basic.py
示例17: test_box
def test_box():
run("(unbox (box #t))", w_true)
run("(unbox (box-immutable #f))", w_false)
run("(let ([b (box 5)]) (begin (set-box! b #f) (unbox b)))", w_false)
开发者ID:rrnewton,项目名称:pycket,代码行数:4,代码来源:test_basic.py
示例18: test_lists
def test_lists():
run ("null", w_null)
run ("(list)", w_null)
run ("(list #t)", to_list([w_true]))
run ("(list-tail (list #f #f #t #t) 2)", to_list([w_true, w_true]))
开发者ID:rrnewton,项目名称:pycket,代码行数:5,代码来源:test_basic.py
示例19: test_bools
def test_bools():
run ("#t", w_true)
run ("#true", w_true)
run ("#T", w_true)
run ("#f", w_false)
run ("#false", w_false)
run ("#F", w_false)
run ("(not #t)", w_false)
run ("(not #f)", w_true)
run ("(not 5)", w_false)
run ("true", w_true, stdlib=True)
run ("false", w_false, stdlib=True)
开发者ID:rrnewton,项目名称:pycket,代码行数:12,代码来源:test_basic.py
示例20: test_set_bang
def test_set_bang():
run("((lambda (x) (set! x #t) x) 1)", w_true)
run("(letrec([x 0]) ((lambda (x) (set! x #t) x) 1))", w_true)
开发者ID:rrnewton,项目名称:pycket,代码行数:3,代码来源:test_basic.py
注:本文中的pycket.test.testhelper.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论