示例#1
0
def test_system_path_convention_type(source):
    """(system-path-convention-type)"""
    result = run_mod_expr(source, wrap=True)
    sym = result.asciivalue()
    if sys.platform in ['win32', 'cygwin']:
        assert sym == "windows"
    else:
        assert sym == "unix"
示例#2
0
def test_read_bytes(source):
    """
    (let ([ip (open-input-bytes (bytes 115 101 99 114 101 116))])
      (read-bytes 6 ip))
    """
    result = run_mod_expr(source, wrap=True)
    assert isinstance(result, values.W_Bytes)
    assert result.value == list("secret")
示例#3
0
def test_read_bytes(source):
    """
    (let ([ip (open-input-bytes (bytes 115 101 99 114 101 116))])
      (read-bytes 6 ip))
    """
    result = run_mod_expr(source, wrap=True)
    assert isinstance(result, values.W_Bytes)
    assert result.value == list("secret")
示例#4
0
def test_system_path_convention_type(source):
    """(system-path-convention-type)"""
    result = run_mod_expr(source, wrap=True)
    sym = result.asciivalue()
    if sys.platform in ['win32', 'cygwin']:
        assert sym == "windows"
    else:
        assert sym == "unix"
示例#5
0
def test_whitebox_bytes(source):
    r"""
    (let ([ht (make-hash)] [st (bytes 65 66)])
        (bytes-set! st 0 67)
        (hash-set! ht #"a" '(red round))
        (hash-set! ht #"b" '(yellow long))
        (hash-set! ht st 77)
        (hash-ref ht #"c" "not there")
        ht)
    """
    result = run_mod_expr(source)
    assert result.strategy is ByteHashmapStrategy.singleton
示例#6
0
def test_whitebox_bytes(source):
    r"""
    (let ([ht (make-hash)] [st (bytes 65 66)])
        (bytes-set! st 0 67)
        (hash-set! ht #"a" '(red round))
        (hash-set! ht #"b" '(yellow long))
        (hash-set! ht st 77)
        (hash-ref ht #"c" "not there")
        ht)
    """
    result = run_mod_expr(source)
    assert result.strategy is ByteHashmapStrategy.singleton
示例#7
0
def test_whitebox_str(source):
    r"""
    (let ([ht (make-hash)] [st (string #\a #\b)])
        (string-set! st 0 #\x)
        (hash-set! ht "a" '(red round))
        (hash-set! ht "b" '(yellow long))
        (hash-set! ht st 77)
        (hash-ref ht "c" "not there")
        ht)
    """
    result = run_mod_expr(source)
    assert result.strategy is StringHashmapStrategy.singleton
示例#8
0
def test_whitebox_str(source):
    r"""
    (let ([ht (make-hash)] [st (string #\a #\b)])
        (string-set! st 0 #\x)
        (hash-set! ht "a" '(red round))
        (hash-set! ht "b" '(yellow long))
        (hash-set! ht st 77)
        (hash-ref ht "c" "not there")
        ht)
    """
    result = run_mod_expr(source)
    assert result.strategy is StringHashmapStrategy.singleton
示例#9
0
def test_system_type_os(source):
    """(cons (system-type) (system-type 'os))"""
    result = run_mod_expr(source, wrap=True)
    assert result.car() == result.cdr()
    sym = result.car().asciivalue()
    # Sadly, this can never cover all cases.
    if sys.platform == "darwin":
        assert sym == "macosx"
    elif sys.platform in ['win32', 'cygwin']:
        assert sym == "windows"
    else:
        assert sym == "unix"
示例#10
0
def test_default_hash(source):
    """
    (let ()
    (make-weak-hasheq)
    (make-immutable-hash)
    (make-hash)
    (make-hasheq)
    (make-hasheqv)
    #t)
    """
    result = run_mod_expr(source, wrap=True)
    assert result is values.w_true
示例#11
0
def test_system_type_os(source):
    """(cons (system-type) (system-type 'os))"""
    result = run_mod_expr(source, wrap=True)
    assert result.car() == result.cdr()
    sym = result.car().asciivalue()
    # Sadly, this can never cover all cases.
    if sys.platform == "darwin":
        assert sym == "macosx"
    elif sys.platform in ['win32', 'cygwin']:
        assert sym == "windows"
    else:
        assert sym == "unix"
示例#12
0
def test_default_hash(source):
    """
    (let ()
    (make-weak-hasheq)
    (make-immutable-hash)
    (make-hash)
    (make-hasheq)
    (make-hasheqv)
    #t)
    """
    result = run_mod_expr(source, wrap=True)
    assert result is values.w_true
示例#13
0
def test_open_input_bytes_and_read_bytes_line(source):
    """
    (let* ([b (string->bytes/utf-8 "ABC\nDEF\n\nGHI\n\nJKL\n\n\nMNOP\n")]
           [expected '(#"MNOP" #"" #"" #"JKL" #"" #"GHI" #"" #"DEF" #"ABC")]
           [inport (open-input-bytes b)])
      (let ([res (let rev ([lines null])
                   (let ([line (read-bytes-line inport)])
                     (if (eof-object? line)
                         lines
                         (rev (cons line lines)))))])
        (equal? res expected)))
    """
    result = run_mod_expr(source, wrap=True)
    assert result == w_true
示例#14
0
def test_open_input_and_read_line(source):
    u"""
    (let* ([b "ÄBC\nDEF\n\nGHI\n\nJKL\n\n\nMNOP\n"]
           [expected '("MNOP" "" "" "JKL" "" "GHI" "" "DEF" "ÄBC")]
           [inport (open-input-string b)])
      (let ([res (let rev ([lines null])
                   (let ([line (read-line inport)])
                     (if (eof-object? line)
                         lines
                         (rev (cons line lines)))))])
        (equal? res expected)))
    """
    result = run_mod_expr(source, wrap=True)
    assert result == w_true
示例#15
0
def test_default_hash(source):
    """
    (let ()
    (make-weak-hasheq)
    (make-immutable-hash)
    (make-hash)
    (make-hasheq)
    (make-hasheqv)
    #t)
    """
    from pycket.test.testhelper import run_mod_expr
    from pycket.values import w_true
    result = run_mod_expr(source, wrap=True)
    assert result is w_true
示例#16
0
def test_open_input_and_read_line(source):
    u"""
    (let* ([b "ÄBC\nDEF\n\nGHI\n\nJKL\n\n\nMNOP\n"]
           [expected '("MNOP" "" "" "JKL" "" "GHI" "" "DEF" "ÄBC")]
           [inport (open-input-string b)])
      (let ([res (let rev ([lines null])
                   (let ([line (read-line inport)])
                     (if (eof-object? line)
                         lines
                         (rev (cons line lines)))))])
        (equal? res expected)))
    """
    result = run_mod_expr(source, wrap=True)
    assert result == w_true
示例#17
0
def test_open_input_bytes_and_read_bytes_line(source):
    """
    (let* ([b (string->bytes/utf-8 "ABC\nDEF\n\nGHI\n\nJKL\n\n\nMNOP\n")]
           [expected '(#"MNOP" #"" #"" #"JKL" #"" #"GHI" #"" #"DEF" #"ABC")]
           [inport (open-input-bytes b)])
      (let ([res (let rev ([lines null])
                   (let ([line (read-bytes-line inport)])
                     (if (eof-object? line)
                         lines
                         (rev (cons line lines)))))])
        (equal? res expected)))
    """
    result = run_mod_expr(source, wrap=True)
    assert result == w_true
示例#18
0
def test_read_utf8_bytes_chars(source):
    ur"""
    (let* ([b "ÄÖÜ"]
           [inport (open-input-string b)]
           [res1 (read-byte inport)]
           [res2 (read-byte inport)]
           [res3 (read-char inport)]
           )
        (and
            (equal? res1 195)
            (equal? res2 132)
            (equal? res3 #\Ö)))
    """
    result = run_mod_expr(source, wrap=True)
    assert result == w_true
示例#19
0
def test_read_utf8_bytes_chars(source):
    ur"""
    (let* ([b "ÄÖÜ"]
           [inport (open-input-string b)]
           [res1 (read-byte inport)]
           [res2 (read-byte inport)]
           [res3 (read-char inport)]
           )
        (and
            (equal? res1 195)
            (equal? res2 132)
            (equal? res3 #\Ö)))
    """
    result = run_mod_expr(source, wrap=True)
    assert result == w_true
示例#20
0
文件: test_mod.py 项目: 8l/pycket
def test_constant_mod():
    run_mod_expr("1")
示例#21
0
文件: test_mod.py 项目: 8l/pycket
def test_constant_mod_val():
    ov = run_mod_expr("1")
    assert isinstance(ov, W_Fixnum)
    assert ov.value == 1
示例#22
0
def test_constant_mod():
    run_mod_expr("1")
示例#23
0
def test_constant_mod_val():
    ov = run_mod_expr("1")
    assert isinstance(ov, W_Fixnum)
    assert ov.value == 1