diff options
author | Andy Fleckenstein <andrew.fleckenstein@gmail.com> | 2024-02-13 12:37:14 -0500 |
---|---|---|
committer | Andy Fleckenstein <andrew.fleckenstein@gmail.com> | 2024-02-15 07:57:37 -0500 |
commit | e25a37038106d87416419130f41654f42742651f (patch) | |
tree | 680c75cd7ee14179a2e6063198ca37ba88e5a7d9 | |
parent | 199aeab61d34fda75ee9eabe0b5a4520eb21912d (diff) |
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)))) |