• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testhelper.run_mod函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pycket.test.testhelper.run_mod函数的典型用法代码示例。如果您正苦于以下问题:Python run_mod函数的具体用法?Python run_mod怎么用?Python run_mod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了run_mod函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_flvector_set_wrong_type

def test_flvector_set_wrong_type():
    with pytest.raises(SchemeException):
        run_mod("""
            #lang pycket
            (require '#%flfxnum '#%unsafe)
            (let [(a (flvector 1.2 1.3))] (flvector-set! a 1 'a))
        """)
开发者ID:magnusmorton,项目名称:pycket,代码行数:7,代码来源:test_vector.py


示例2: test_use_before_definition

def test_use_before_definition():
    with pytest.raises(SchemeException):
        m = run_mod("""
        #lang pycket
        x
        (define x 1)
    """)

    with pytest.raises(SchemeException):
        m = run_mod("""
        #lang pycket
        x
        (define x 1)
        (set! x 2)
    """)
开发者ID:8l,项目名称:pycket,代码行数:15,代码来源:test_mod.py


示例3: test_with_continuation_mark3

def test_with_continuation_mark3():
    m = run_mod(
        """
    #lang racket/base
    (define a 1)
    (set! a 2)
    (define result
        (let* ([extract
	        (lambda (k) (continuation-mark-set->list
	           (continuation-marks k)
	           'x))]
           [go
	        (lambda (in?)
              (lambda ()
	        	      (let ([k (with-continuation-mark 'x 10
	        			 (begin0
	        			  (with-continuation-mark 'x 11
	        			    (call/cc
	        			     (lambda (k )
	        			       (with-continuation-mark 'x 12
	        				 (if in?
	        				     (extract k)
	        				     k)))))
	        			  (+ a 3)))])
	        		(if in?
	        		    k
	        		    (extract k)))))])
        ((go #t))))
    (define valid (equal? result '(11 10)))
    """
    )
    sym = W_Symbol.make("valid")
    assert m.defs[sym] is w_true
开发者ID:rjnw,项目名称:pycket,代码行数:33,代码来源:test_basic.py


示例4: test_set_mod_other

def test_set_mod_other():
    m = run_mod("""
#lang pycket
    (require pycket/set-export)
(define y (not x))
""")
    assert m.defs[W_Symbol.make("y")]
开发者ID:8l,项目名称:pycket,代码行数:7,代码来源:test_mod.py


示例5: test_module_star

def test_module_star():
    m = run_mod(
    """
    #lang pycket
    (module outer pycket
      (define a 1)
      (module* inner #f
        (provide b)
        (define b (+ a 2))))
    (module snd pycket
      (require (submod ".." outer inner))
      (provide c)
      (define c (+ b 1)))
    (require (submod "." snd))
    (define d c)
    """)
    assert len(m.submodules) == 2
    outer = m.find_submodule("outer")
    snd   = m.find_submodule("snd")

    assert outer.parent is m
    assert snd.parent is m
    assert len(outer.submodules) == 1
    assert len(snd.submodules) == 0

    d = m.defs[W_Symbol.make("d")]
    assert isinstance(d, W_Integer) and d.value == 4
开发者ID:8l,项目名称:pycket,代码行数:27,代码来源:test_mod.py


示例6: test_set_mod2

def test_set_mod2():
    m = run_mod("""
#lang pycket
(provide table)
(define table #f)
(set! table #f)
""")
    ov = m.defs[W_Symbol.make("table")]
    assert isinstance(ov, W_Cell)
开发者ID:8l,项目名称:pycket,代码行数:9,代码来源:test_mod.py


示例7: test_kw_submodule

def test_kw_submodule():
    # Just test to see if this runs.
    # It caused quite a few problems
    # when implementing submodules.
    m = run_mod(
    """
    #lang pycket
    (require racket/private/kw)
    procedure-arity-includes?
    """)
开发者ID:8l,项目名称:pycket,代码行数:10,代码来源:test_mod.py


示例8: test_string_set_bang

def test_string_set_bang():
    m = run_mod(
    """
    #lang pycket
    (define str (substring "hello world" 0 5))
    (string-set! str 0 #\\x)
    """)
    sym = W_Symbol.make("str")
    res = m.defs[sym]
    assert isinstance(res, W_String)
    assert not res.immutable()
    assert res.value == "xello"
开发者ID:antongulenko,项目名称:pycket,代码行数:12,代码来源:test_basic.py


示例9: test_shadowing_macro

def test_shadowing_macro():
    m = run_mod("""
#lang pycket

(define-syntax bind+
  (syntax-rules ()
    [(bind+ v e) (let ([x v]) (+ x e))]
    [(bind+ v0 v ... e) (let ([x v0]) (bind+ v ... (+ x e)))]))

(define x (bind+ 1 2 3))
""")
    ov = m.defs[W_Symbol.make("x")]
    assert ov.value == 6
开发者ID:8l,项目名称:pycket,代码行数:13,代码来源:test_mod.py


示例10: test_hash_iteration_enables_jitting

def test_hash_iteration_enables_jitting(source):
    """
    #lang pycket
    (define h #hash((1 . 2) (2 . 3) (3 . 4)))
    (define (fe c v) '())
    (define (fm c v) '())
    (hash-for-each h fe)
    (hash-map h fm)
    """
    mod = run_mod(source)
    f = mod.defs[values.W_Symbol.make('fe')]
    assert f.closure.caselam.lams[0].body[0].should_enter
    f = mod.defs[values.W_Symbol.make('fm')]
    assert f.closure.caselam.lams[0].body[0].should_enter
开发者ID:rrnewton,项目名称:pycket,代码行数:14,代码来源:test_hash.py


示例11: test_let_remove_num_envs_edge_case

def test_let_remove_num_envs_edge_case():
    m = run_mod(
    """
    #lang pycket
    (define d
      (let-values (((es) values))
        (let-values (((adj) '0))
          (let-values ((() (es)))
            adj))))
    """)
    d = W_Symbol.make("d")
    assert type(m.defs[d]) is W_Fixnum and m.defs[d].value == 0

    m = run_mod(
    """
    #lang pycket
    (define d
      (let-values (((es) '0))
        (let-values (((adj) '1))
          (let-values (((a b c) (begin es (values '2 '3 '4))))
            (+ adj a)))))
    """)
    assert type(m.defs[d]) is W_Fixnum and m.defs[d].value == 3
开发者ID:8l,项目名称:pycket,代码行数:23,代码来源:test_ast.py


示例12: test_with_continuation_mark

def test_with_continuation_mark():
    m = run_mod(
    """
    #lang pycket
    (define key (make-continuation-mark-key))
    (define result
      (with-continuation-mark key "quiche"
        (with-continuation-mark key "ham"
           (continuation-mark-set-first
            (current-continuation-marks)
            key))))
    """)
    sym = W_Symbol.make("result")
    assert isinstance(m.defs[sym], values_string.W_String)
    assert m.defs[sym].as_str_utf8() == "ham"
开发者ID:rrnewton,项目名称:pycket,代码行数:15,代码来源:test_basic.py


示例13: test_set_modvar

def test_set_modvar():
    m = run_mod("""
#lang pycket

(define sum 0)

(define (tail-rec-aux i n)
  (if (< i n)
      (begin (set! sum (+ sum 1)) (tail-rec-aux (+ i 1) n))
      sum))

(tail-rec-aux 0 100)
""")
    ov = m.defs[W_Symbol.make("sum")].get_val()
    assert ov.value == 100
开发者ID:8l,项目名称:pycket,代码行数:15,代码来源:test_mod.py


示例14: test_with_continuation_mark_impersonator

def test_with_continuation_mark_impersonator():
    m = run_mod(
    """
    #lang pycket
    (define mark-key
      (impersonate-continuation-mark-key
       (make-continuation-mark-key)
       (lambda (l) (car l))
       (lambda (s) (string->list s))))
    (define result
      (with-continuation-mark mark-key "quiche"
        (continuation-mark-set-first
         (current-continuation-marks)
         mark-key)))
    """)
    sym = W_Symbol.make("result")
    assert isinstance(m.defs[sym], W_Character)
    assert m.defs[sym].value == 'q'
开发者ID:rrnewton,项目名称:pycket,代码行数:18,代码来源:test_basic.py


示例15: test_impersonator_application_mark

def test_impersonator_application_mark():
    m = run_mod(
    """
    #lang pycket
    (require racket/private/kw)
    (define key (make-continuation-mark-key))
    (define proc
      (lambda ()
        (continuation-mark-set-first
          (current-continuation-marks)
          key)))
    (define wrapped
      (impersonate-procedure proc (lambda () (values))
                             impersonator-prop:application-mark (cons key 42)))
    (define result (wrapped))
    """)
    sym = W_Symbol.make("result")
    assert isinstance(m.defs[sym], W_Fixnum)
    assert m.defs[sym].value == 42
开发者ID:rrnewton,项目名称:pycket,代码行数:19,代码来源:test_basic.py


示例16: test_submodule_operations

def test_submodule_operations():
    m = run_mod(
    """
    #lang pycket
    (module test-sub-module pycket
      (provide a)
      (define a 1))
    (require (submod "." test-sub-module))
    (define b (+ a a))
    """)
    assert len(m.submodules) == 1

    # properties concerning relationships between modules and submodules
    b   = m.defs[W_Symbol.make("b")]
    sub = m.resolve_submodule_path(["test-sub-module"])
    assert sub.parent is m
    assert sub in m.submodules
    assert m.root_module() is m
    assert sub.root_module() is m

    a   = sub.defs[W_Symbol.make("a")]
    assert isinstance(b, W_Integer) and b.value == 2
    assert isinstance(a, W_Integer) and a.value == 1
开发者ID:8l,项目名称:pycket,代码行数:23,代码来源:test_mod.py


示例17: test_racket_mod

def test_racket_mod():
    m = run_mod("#lang racket/base\n (define x 1)")
    ov = m.defs[W_Symbol.make("x")]
    assert ov.value == 1
开发者ID:8l,项目名称:pycket,代码行数:4,代码来源:test_mod.py



注:本文中的pycket.test.testhelper.run_mod函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testhelper.run_mod_expr函数代码示例发布时间:2022-05-25
下一篇:
Python testhelper.run_fix函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap