fix `vector-copy' range checking for starting position

This commit is contained in:
Matthew Flatt 2011-01-25 15:46:03 -07:00
parent f8039ddb74
commit 60335d9b23
2 changed files with 5 additions and 2 deletions

View File

@ -41,13 +41,13 @@
end))
(vector)]
[else
(unless (and (<= 0 start) (< start len))
(unless (and (<= 0 start len))
(raise-mismatch-error
'vector-copy
(format "start index ~e out of range [~e, ~e] for vector: "
start 0 len)
v))
(unless (and (<= start end) (<= end len))
(unless (and (<= start end len))
(raise-mismatch-error
'vector-copy
(format "end index ~e out of range [~e, ~e] for vector: "

View File

@ -133,6 +133,9 @@
(let ()
(test #() vector-copy #())
(test #(1 2 3) vector-copy #(1 2 3))
(test #() vector-copy #(1 2 3) 3)
(test #(2 3) vector-copy #(1 2 3) 1)
(test #(2) vector-copy #(1 2 3) 1 2)
(test #f immutable? (vector-copy #(1 2 3)))
(let ([v (vector 1 2 3)])
(test #f eq? v (vector-copy v))))