Skip to content

Commit

Permalink
Merge pull request #1853 from RickBarretto/migrate-to-unitt-decouple
Browse files Browse the repository at this point in the history
[Collections\decouple] Migrate tests to `unitt`
  • Loading branch information
drkameleon authored Feb 4, 2025
2 parents 6f10987 + e4e23cc commit d3d5969
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
27 changes: 27 additions & 0 deletions tests/unitt/lib/collections/decouple.test.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {unitt}!
import relative {../../commons/functions}!


test "returns a tuple" [
expected: [[a b c] [a b c]]
actual: decouple [[a a] [b b] [c c]]

assert -> expected = actual
assert -> 2 = size actual
]

test "keeps the order" [
expected: [["one" "two" "three"] [1 2 3]]
actual: decouple [["one" 1] ["two" 2] ["three" 3]]

assert -> expected = actual
]

test "inplace-equivalence" [
value: [["one" "two" "three"] [1 2 3]]

[reference inplaced]:
inplaceEquivalence value 'decouple []

assert -> reference = inplaced
]
20 changes: 3 additions & 17 deletions tests/unittests/lib.collections.art
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,10 @@ passed: $[] -> print "[+] passed!"

; ==> Tests

topic "decouple"
; couple don't support literals yet
topic "couple"
do [
ensure -> [["one" "two" "three"] [1 2 3]] = decouple [["one" 1] ["two" 2] ["three" 3]]
passed

a: [["one" 1] ["two" 2] ["three" 3]]
decouple 'a
ensure -> [["one" "two" "three"] [1 2 3]] = a
passed

blk: [["one" 1] ["two" 2] ["three" 3]]

a: new blk
b: #[b: new blk]

decouple 'a
decouple 'b\b
ensure -> a = b\b
ensure -> [["one" 1] ["two" 2] ["three" 3]] = couple ["one" "two" "three"] [1 2 3]
passed
]

Expand Down
4 changes: 1 addition & 3 deletions tests/unittests/lib.collections.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

>> decouple
[+] passed!
[+] passed!
>> couple
[+] passed!

>> drop - :string < :string :string
Expand Down

0 comments on commit d3d5969

Please sign in to comment.