diff --git a/collects/tests/mzscheme/basic.ss b/collects/tests/mzscheme/basic.ss index b71c80a31b..75cb36316c 100644 --- a/collects/tests/mzscheme/basic.ss +++ b/collects/tests/mzscheme/basic.ss @@ -1991,7 +1991,7 @@ (arity-test hash-table-for-each 2 2) (arity-test hash-table? 1 3) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Misc (test #t string? (version)) @@ -2013,6 +2013,30 @@ (arity-test system-library-subpath 0 1) (arity-test current-command-line-arguments 0 1) +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; procedure-closure-contents-eq? + +(for-each + (lambda (jit?) + (parameterize ([eval-jit-enabled jit?]) + (let ([f #f]) + (set! f (eval '(lambda (x) (lambda () x)))) + ((f 'c)) ; forced JIT compilation + (test #t procedure-closure-contents-eq? (f 'a) (f 'a)) + (test #f procedure-closure-contents-eq? (f 'a) (f 'b)) + (set! f (eval '(case-lambda + [(x) (lambda () 12)] + [(x y) (lambda () (list x y))]))) + ((f 'c)) ; forces JIT compilation + ((f 'c 'd)) ; forces JIT compilation + (test #t procedure-closure-contents-eq? (f 'a) (f 'a)) + (test #t procedure-closure-contents-eq? (f 'a 'b) (f 'a 'b)) + (test #f procedure-closure-contents-eq? (f 'a 'b) (f 'c 'b))))) + '(#t #f)) +(test #t procedure-closure-contents-eq? add1 add1) + +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (report-errs) "last item in file" diff --git a/collects/tests/mzscheme/optimize.ss b/collects/tests/mzscheme/optimize.ss index e8d0d50915..d07c001c60 100644 --- a/collects/tests/mzscheme/optimize.ss +++ b/collects/tests/mzscheme/optimize.ss @@ -333,4 +333,17 @@ (test-comp '(let ([f (lambda (x) x)]) f) (syntax-property (datum->syntax-object #f '(lambda (x) x)) 'inferred-name 'f)) +(test-comp '(letrec ([f (lambda (x) x)]) + (f 10) + f) + '(letrec ([f (lambda (x) x)]) + f)) +(test-comp '(let ([f (lambda (x) x)]) + (f 10)) + 10) +(test-comp '(let ([f (lambda (x) (add1 x))] + [y 10]) + (f y)) + '11) + (report-errs) diff --git a/collects/tests/mzscheme/syntax.ss b/collects/tests/mzscheme/syntax.ss index 6bb7d1855d..bddcc0270d 100644 --- a/collects/tests/mzscheme/syntax.ss +++ b/collects/tests/mzscheme/syntax.ss @@ -1081,6 +1081,20 @@ (g)) (test 16 values val)) +;; Function-inline test where (h (g v 10)) involves two inlines: +(letrec ([f (lambda (x) (h (g v 10)))] + [h (lambda (x) (list x x))] + [g (lambda (a b) a)] + [v (list 'hello)] + [w (list 'no!)]) + (test '((hello) (hello)) f 10)) + +;; Inlining introduces a let binding that is immediately dropped: +(test '(1 . 2) + (let ([x (cons 1 2)]) (let ([f (lambda (x) x)]) (f (lambda (y) x)))) + 10) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (report-errs) +