diff options
author | Marc Feeley <feeley@iro.umontreal.ca> | 2024-02-15 08:41:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-15 08:41:15 -0500 |
commit | 72d24f7478dcd3a6481831831d29f20f43973794 (patch) | |
tree | f6e2b1de0bdf3ed237089aad8307ecba4c044511 | |
parent | b3df41a7ccf00c50fb50d0f552cc026b7e3716f0 (diff) | |
parent | e25a37038106d87416419130f41654f42742651f (diff) |
Merge pull request #892 from afleckenstein/gh_884
fix argument length mismatch checking in vector-map and vector-for-each
-rw-r--r-- | lib/_std#.scm | 4 | ||||
-rw-r--r-- | tests/unit-tests/07-vector/vector_for_each.scm | 3 | ||||
-rw-r--r-- | tests/unit-tests/07-vector/vector_map.scm | 5 |
3 files changed, 9 insertions, 3 deletions
diff --git a/lib/_std#.scm b/lib/_std#.scm index 08dc4cda..e2624e07 100644 --- a/lib/_std#.scm +++ b/lib/_std#.scm @@ -1262,8 +1262,8 @@ end-of-code (if (##fx> len-arg max-len) (loop (##cdr lst) (##cons arg rev-x-y) + min-len len-arg - max-len arg-num (##fx+ arg-num 1)) (loop (##cdr lst) @@ -1360,8 +1360,8 @@ end-of-code (if (##fx> len-arg max-len) (loop (##cdr lst) (##cons arg rev-x-y) + min-len len-arg - max-len arg-num (##fx+ arg-num 1)) (loop (##cdr lst) diff --git a/tests/unit-tests/07-vector/vector_for_each.scm b/tests/unit-tests/07-vector/vector_for_each.scm index adc06bb2..15fd6a08 100644 --- a/tests/unit-tests/07-vector/vector_for_each.scm +++ b/tests/unit-tests/07-vector/vector_for_each.scm @@ -103,3 +103,6 @@ (check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-for-each))) (check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-for-each one))) + +(set! ##allow-length-mismatch? #f) +(check-tail-exn length-mismatch-exception? (lambda () (vector-for-each one '#(1) '#(1 2) '#(1)))) diff --git a/tests/unit-tests/07-vector/vector_map.scm b/tests/unit-tests/07-vector/vector_map.scm index ff105f77..1aa027c3 100644 --- a/tests/unit-tests/07-vector/vector_map.scm +++ b/tests/unit-tests/07-vector/vector_map.scm @@ -7,7 +7,7 @@ (define vect2 (vector 11 22)) (define (inc x) (+ x 1)) -(define (add x y) (+ x y)) +(define add +) (check-equal? (vector-map inc vect0) '#()) (check-equal? (vector-map inc vect1) '#(12)) @@ -42,3 +42,6 @@ (check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-map))) (check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-map inc))) + +(set! ##allow-length-mismatch? #f) +(check-tail-exn length-mismatch-exception? (lambda () (vector-map add '#(1) '#(1 2) '#(1)))) |