Carp/test/list.carp
Tim Dévé d7ad0b2629
feat: Adds Dynamic.sort & improves output of failing dynamic tests (#1411)
* 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.
2022-04-09 07:04:16 +02:00

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"))