Skip to content

Commit

Permalink
match: adding some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jun 29, 2024
1 parent af62dc0 commit 586d245
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion basis/match/match-tests.factor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
! Copyright (C) 2006 Chris Double.
! See https://factorcode.org/license.txt for BSD license.
USING: arrays kernel match namespaces tools.test ;
USING: arrays kernel match namespaces sequences tools.test ;
FROM: match => _ ;
IN: match.tests

Expand Down Expand Up @@ -60,6 +60,22 @@ C: <foo> foo
] with-variables
] unit-test

{ { 1 "four" 6 "no match" } } [
{
T{ foo f 1 2 }
T{ foo f 3 4 }
T{ foo f 5 6 }
"hello"
} [
{
{ T{ foo f ?a 2 } [ ?a ] }
{ T{ foo f _ 4 } [ "four" ] }
{ T{ foo f ?a ?b } [ ?b ] }
[ drop "no match" ]
} match-cond
] map
] unit-test

{ H{ { ?a ?a } } } [
\ ?a \ ?a match
] unit-test
Expand Down

0 comments on commit 586d245

Please sign in to comment.