feat(users/sterni/nix): move flow.match to string.match
After all it only matches strings. Change-Id: I3d2e5221ef43f692de69028e78ed98b6b11f82d1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2586 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
ed3fce2b19
commit
8ff14cacb6
5 changed files with 17 additions and 14 deletions
|
@ -55,6 +55,9 @@ let
|
|||
then s
|
||||
else pad { inherit char; "${side}" = diff; } s;
|
||||
|
||||
# pattern matching for strings only
|
||||
match = val: matcher: matcher."${val}";
|
||||
|
||||
in {
|
||||
inherit
|
||||
take
|
||||
|
@ -67,5 +70,6 @@ in {
|
|||
fromChars
|
||||
pad
|
||||
fit
|
||||
match
|
||||
;
|
||||
}
|
||||
|
|
|
@ -45,9 +45,21 @@ let
|
|||
null)
|
||||
];
|
||||
|
||||
dontEval = builtins.throw "this should not get evaluated";
|
||||
|
||||
testMatch = it "tests match" [
|
||||
(assertEq "basic match usage" 42
|
||||
(string.match "answer" {
|
||||
"answer" = 42;
|
||||
"banana" = dontEval;
|
||||
"maleur" = dontEval;
|
||||
}))
|
||||
];
|
||||
|
||||
in
|
||||
runTestsuite "nix.string" [
|
||||
testTakeDrop
|
||||
testIndexing
|
||||
testFinding
|
||||
testMatch
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue