Skip to content

Commit 67d8641

Browse files
committed
Add tests for satisfies? and instance?.
1 parent eed57f8 commit 67d8641

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/pixie/tests/test-stdlib.pxi

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,30 @@
448448
(t/assert= (f 3) :large)
449449
(t/assert= (f 4) :large)
450450
(t/assert= (f 9) :toolarge)))
451+
452+
(t/deftest test-instance?
453+
(t/assert= (instance? Keyword :a) true)
454+
(t/assert= (instance? Keyword 'a) false)
455+
(t/assert= (instance? [Symbol Keyword] :a) true)
456+
(t/assert= (instance? [Symbol Keyword] 'a) true)
457+
(t/assert= (instance? [Symbol Keyword] 42) false)
458+
(t/assert= (instance? [] :x) false)
459+
(t/assert-throws? RuntimeException
460+
"c must be a type"
461+
(instance? :not-a-type 123))
462+
(t/assert-throws? RuntimeException
463+
"c must be a type"
464+
(instance? [Keyword :also-not-a-type] 123)))
465+
466+
(t/deftest test-satisfies?
467+
(t/assert= (satisfies? IIndexed [1 2]) true)
468+
(t/assert= (satisfies? IIndexed '(1 2)) false)
469+
(t/assert= (satisfies? [] :xyz) true)
470+
(t/assert= (satisfies? [ILookup IIndexed] [1 2]) true)
471+
(t/assert= (satisfies? [ILookup IIndexed] {1 2}) false)
472+
(t/assert-throws? RuntimeException
473+
"proto must be a Protocol"
474+
(satisfies? :not-a-proto 123))
475+
(t/assert-throws? RuntimeException
476+
"proto must be a Protocol"
477+
(satisfies? [IIndexed :also-not-a-proto] [1 2])))

0 commit comments

Comments
 (0)