Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Karsten Poeck
ansi-test
Commits
5bee0e73
Commit
5bee0e73
authored
Sep 04, 2003
by
pfdietz
Browse files
Check that SORT 'works' even when the comparison function is not a total order.
parent
bf2e44b8
Changes
1
Show whitespace changes
Inline
Side-by-side
ansi-tests/sort.lsp
View file @
5bee0e73
...
...
@@ -21,6 +21,24 @@
(sort a #'<))
(1 2 3 4 5))
;;;
;;; Confirm that sort only permutes the sequence, even when given
;;; a comparison function that does not define a total order.
;;;
(deftest sort-list.4
(loop
repeat 100
always
(let ((a (list 1 2 3 4 5 6 7 8 9 0))
(cmp (make-array '(10 10))))
(loop for i from 0 to 9 do
(loop for j from 0 to 9 do
(setf (aref cmp i j) (zerop (logand (random 1024) 512)))))
(setq a (sort a #'(lambda (i j) (aref cmp i j))))
(and (eqlt (length a) 10)
(equalt (sort a #'<) '(0 1 2 3 4 5 6 7 8 9)))))
t)
(deftest sort-vector.1
(let ((a (copy-seq #(1 4 2 5 3))))
(sort a #'<))
...
...
@@ -43,6 +61,20 @@
(sort a #'<))
#(10 20 30 40 50))
(deftest sort-vector.5
(loop
repeat 100
always
(let ((a (vector 1 2 3 4 5 6 7 8 9 0))
(cmp (make-array '(10 10))))
(loop for i from 0 to 9 do
(loop for j from 0 to 9 do
(setf (aref cmp i j) (zerop (logand (random 1024) 512)))))
(setq a (sort a #'(lambda (i j) (aref cmp i j))))
(and (eqlt (length a) 10)
(equalpt (sort a #'<) #(0 1 2 3 4 5 6 7 8 9)))))
t)
(deftest sort-bit-vector.1
(let ((a (copy-seq #*10011101)))
(sort a #'<))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment