~ chicken-core (chicken-5) /tests/rest-arg-tests.scm
Trap1;; Test rest argument optimizations23;; Check that rest args are correctly fetched from a closure4(assert (equal? 1 ((lambda f05 (let ((v0 f0))6 (let ((failure07 (lambda ()8 (if (pair? v0)9 (car v0)))))10 (failure0))))11 1)))1213;; Check that rest arg optimizations aren't applied after inlining14;; (#1658), slightly different from the above15(assert (equal? 1 ((lambda f016 (let ((v0 f0))17 (if (pair? v0)18 (car v0))))19 1)))2021;; Ensure that rest conversion is not applied too aggressively.22;; (only when the consequence is () should it be applied)23(define (rest-nonnull-optimization . rest)24 (let ((x (if (null? (cdr rest))25 '(foo)26 (cdr rest))))27 (null? x)))2829(assert (not (rest-nonnull-optimization 1)))30(assert (not (rest-nonnull-optimization 1 2)))3132;; Regression test to make sure explicitly consed rest args don't get33;; rest argvector ops for them (#1756)34(let ()35 (define mdplus36 (lambda args37 (let ((args args))38 (if (pair? args)39 (car args)))))40 (mdplus '1 '2)41 (mdplus '3 '4))