mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-26 13:51:50 +03:00
d7ad0b2629
* feat: Adds Dynamic.sort * test: Adds tests for Dynamic.sort * refactor: Makes dynamic test handler display diff of expected vs actual instead of displaying "true" : "true" * test: Removes complex implementation of list-equal-unordered Replaces it with sort + equal. While this is less "correct", having complex untested functions within test files is undesirable. This implementation is "good enough" for lists of integers.
21 lines
762 B
Plaintext
21 lines
762 B
Plaintext
(load-and-use Test)
|
|
|
|
(deftest test
|
|
(assert-dynamic-equal test
|
|
'(1 2 3 3 4)
|
|
(Dynamic.sort '(3 4 3 1 2) <)
|
|
"Dynamic.sort sorts from lower to higher")
|
|
|
|
(assert-dynamic-equal test
|
|
'(4 3 3 2 1)
|
|
(Dynamic.sort '(3 4 3 1 2) >)
|
|
"Dynamic.sort sorts from higher to lower")
|
|
|
|
(assert-dynamic-equal test
|
|
'("one" "four" "three" "two---")
|
|
(Dynamic.sort '("one" "two---" "three" "four")
|
|
(fn [a b]
|
|
(< (String.length a) (String.length b))))
|
|
"Dynamic.sort sorts using predicate"))
|
|
|