mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-09 16:24:08 +03:00
1.0 KiB
1.0 KiB
Unit tests for Any.unsafeExtract
Any.unsafeExtract is a way to extract the value contained in an Any. This is unsafe because it allows the programmer to coerce a value into any type, which would cause undefined behaviour if used to coerce a value to the wrong type.
test> Any.unsafeExtract.works =
use Nat !=
checks [1 == Any.unsafeExtract (Any 1),
not (1 == Any.unsafeExtract (Any 2)),
(Some 1) == Any.unsafeExtract (Any (Some 1))
]
Loading changes detected in scratch.u.
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
Any.unsafeExtract.works : [Result]
Now evaluating any watch expressions (lines starting with
`>`)... Ctrl+C cancels.
3 | checks [1 == Any.unsafeExtract (Any 1),
✅ Passed Passed
.> add
⍟ I've added these definitions:
Any.unsafeExtract.works : [Result]