Esempio n. 1
0
def test_eqv():
    check_equal(
        "(eqv? 'yes 'yes)", "#t",
        "(eqv? 'yes 'no)", "#f",
        "(eqv? (expt 2 100) (expt 2 100))", "#t",
        "(eqv? 2 2.0)", "#f",
        "(eqv? (integer->char 955) (integer->char 955))", "#t",
    #run_top("(eqv? (make-string 3 #\z) (make-string 3 #\z))", "#f", stdlib=True)
        "(eqv? +nan.0 +nan.0)", "#t",

        "(eqv? 'a 'a)", "#t",
        "(eqv? 'a 'b)", "#f",
        "(eqv? 2 2)", "#t",
        "(eqv? '() '())", "#t",
        "(eqv? 100000000 100000000)", "#t",
        "(eqv? (cons 1 2) (cons 1 2))", "#f",
        """(eqv? (lambda () 1)
                 (lambda () 2))""", "#f",
        "(eqv? #f 'nil)", "#f",
        """(let ((p (lambda (x) x)))
           (eqv? p p))""", "#t",
    # run('(eqv? "" "")', "#t") #racket
        "(eqv? '#() '#())", "#f", #racket
        """(eqv? (lambda (x) x)
                 (lambda (x) x))""", "#f", #racket
        """(eqv? (lambda (x) x)
                 (lambda (y) y))""", "#f", #racket
    )
    run_top("""(define gen-counter
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) n))))
           (let ((g (gen-counter)))
             (eqv? g g))""",
        w_true)
    run_top("""(define gen-counter
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) n))))
           (eqv? (gen-counter) (gen-counter))""",
        w_false)
    run_top("""(define gen-loser
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) 27))))
           (let ((g (gen-loser)))
             (eqv? g g))""",
        w_true)
    run_top("""(define gen-loser
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) 27))))
           (eqv? (gen-loser) (gen-loser))""",
        w_false) #racket

    run("""(letrec ((f (lambda () (if (eqv? f g) 'both 'f)))
                    (g (lambda () (if (eqv? f g) 'both 'g))))
             (eqv? f g))""",
        w_false) #racket

    run("""(letrec ((f (lambda () (if (eqv? f g) 'f 'both)))
                    (g (lambda () (if (eqv? f g) 'g 'both))))
             (eqv? f g))""",
        w_false)
    run("(eqv? '(a) '(a))", w_false) #racket
    # run('(eqv? "a" "a")', w_true) #racket
    run("(eqv? '(b) (cdr '(a b)))", w_false) #racket
    run("""(let ((x '(a)))
           (eqv? x x))""", w_true)
Esempio n. 2
0
def test_eqv():
    check_equal(
        "(eqv? 'yes 'yes)",
        "#t",
        "(eqv? 'yes 'no)",
        "#f",
        "(eqv? (expt 2 100) (expt 2 100))",
        "#t",
        "(eqv? 2 2.0)",
        "#f",
        "(eqv? (integer->char 955) (integer->char 955))",
        "#t",
        #run_top("(eqv? (make-string 3 #\z) (make-string 3 #\z))", "#f", stdlib=True)
        "(eqv? +nan.0 +nan.0)",
        "#t",
        "(eqv? 'a 'a)",
        "#t",
        "(eqv? 'a 'b)",
        "#f",
        "(eqv? 2 2)",
        "#t",
        "(eqv? '() '())",
        "#t",
        "(eqv? 100000000 100000000)",
        "#t",
        "(eqv? 1.0+2i 1.0+2i)",
        "#t",
        "(eqv? (cons 1 2) (cons 1 2))",
        "#f",
        """(eqv? (lambda () 1)
                 (lambda () 2))""",
        "#f",
        "(eqv? #f 'nil)",
        "#f",
        """(let ((p (lambda (x) x)))
           (eqv? p p))""",
        "#t",
        # run('(eqv? "" "")', "#t") #racket
        "(eqv? '#() '#())",
        "#f",  #racket
        """(eqv? (lambda (x) x)
                 (lambda (x) x))""",
        "#f",  #racket
        """(eqv? (lambda (x) x)
                 (lambda (y) y))""",
        "#f",  #racket
    )
    run_top(
        """(define gen-counter
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) n))))
           (let ((g (gen-counter)))
             (eqv? g g))""", w_true)
    run_top(
        """(define gen-counter
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) n))))
           (eqv? (gen-counter) (gen-counter))""", w_false)
    run_top(
        """(define gen-loser
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) 27))))
           (let ((g (gen-loser)))
             (eqv? g g))""", w_true)
    run_top("""(define gen-loser
             (lambda ()
               (let ((n 0))
                 (lambda () (set! n (+ n 1)) 27))))
           (eqv? (gen-loser) (gen-loser))""", w_false)  #racket

    run("""(letrec ((f (lambda () (if (eqv? f g) 'both 'f)))
                    (g (lambda () (if (eqv? f g) 'both 'g))))
             (eqv? f g))""", w_false)  #racket

    run(
        """(letrec ((f (lambda () (if (eqv? f g) 'f 'both)))
                    (g (lambda () (if (eqv? f g) 'g 'both))))
             (eqv? f g))""", w_false)
    run("(eqv? '(a) '(a))", w_false)  #racket
    # run('(eqv? "a" "a")', w_true) #racket
    run("(eqv? '(b) (cdr '(a b)))", w_false)  #racket
    run("""(let ((x '(a)))
           (eqv? x x))""", w_true)
Esempio n. 3
0
def test_define():
    run_top("(define x 1) x", W_Fixnum(1))
Esempio n. 4
0
def test_define():
    run_top("(define x 1) x", W_Fixnum(1))