From 564f9d0062444e9b65cafc437801719e79d06e34 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Fri, 21 Oct 2011 07:26:55 -0500 Subject: [PATCH] adjust HtDP teaching languages' first and rest so that they accept circular lists. This commit fix an unintentional change introduced by this commit: c7d67f9babc2496aaf295a08264b79750785314b (and it also adds in test cases for what that commit appears to have been doing) Assuming everyone agrees that the behavior for first rest from back in 2010 is the behavior we still want (and the lack of release notes on the subject makes me believe that we do), then: Please include in 5.2. (cherry picked from commit 7acc5b78521ca86acd58e3e871af07bc2a3c716e) --- collects/deinprogramm/signature/signature-unit.rkt | 2 +- collects/tests/htdp-lang/advanced.rktl | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/collects/deinprogramm/signature/signature-unit.rkt b/collects/deinprogramm/signature/signature-unit.rkt index 2059bb7fc4..c608317da0 100644 --- a/collects/deinprogramm/signature/signature-unit.rkt +++ b/collects/deinprogramm/signature/signature-unit.rkt @@ -5,7 +5,7 @@ (require scheme/promise mzlib/struct - (only-in racket/list first rest) + (only-in mzlib/list first rest) (for-syntax scheme/base) (for-syntax stepper/private/shared)) diff --git a/collects/tests/htdp-lang/advanced.rktl b/collects/tests/htdp-lang/advanced.rktl index 0a82c83f47..dc6c8d89ba 100644 --- a/collects/tests/htdp-lang/advanced.rktl +++ b/collects/tests/htdp-lang/advanced.rktl @@ -174,6 +174,14 @@ (htdp-test 1 car (shared ([x (cons 1 x)]) x)) (htdp-test 1 cadr (shared ([x (cons 1 x)][y (cons 2 x)]) y)) (htdp-test 1 cadddr (shared ([x (cons 1 x)][y (cons 2 x)]) y)) +(htdp-test 1 first (shared ([x (cons 1 x)]) x)) +(htdp-test 1 second (shared ([x (cons 1 x)]) x)) +(htdp-test 1 third (shared ([x (cons 1 x)]) x)) +(htdp-test 1 fourth (shared ([x (cons 1 x)]) x)) +(htdp-test 1 fifth (shared ([x (cons 1 x)]) x)) +(htdp-test 1 sixth (shared ([x (cons 1 x)]) x)) +(htdp-test 1 seventh (shared ([x (cons 1 x)]) x)) +(htdp-test 1 eighth (shared ([x (cons 1 x)]) x)) (htdp-test #t (lambda (l) (eq? l (cdr l))) (shared ([x (cons 1 x)]) x)) (htdp-test #t (lambda (l) (eq? l (car l))) (shared ([x (list x x)]) x)) (htdp-test #t (lambda (l) (eq? l (cadr l))) (shared ([x (list x x)]) x)) @@ -200,6 +208,10 @@ (htdp-err/rt-test (cons 1 2) "cons: second argument must be a list or cyclic list, but received 1 and 2") (htdp-err/rt-test (append (list 1) 2) "append: last argument must be a list or cyclic list, but received 2") +(htdp-err/rt-test (first 1) "first: expected argument of type ; given 1") +(htdp-err/rt-test (rest 1) "rest: expected argument of type ; given 1") + + (htdp-test #t 'equal? (equal? (vector (list 10) 'apple) (vector (list 10) 'apple))) (htdp-test #t 'equal? (equal? (shared ([x (cons 10 x)]) x) (shared ([x (cons 10 x)]) x))) (htdp-test #t 'equal? (equal? (shared ([x (cons (vector x) x)]) x) (shared ([x (cons (vector x) x)]) x)))