aboutsummaryrefslogtreecommitdiffstats
path: root/test/testdata/eval-okay-regex-match.nix
diff options
context:
space:
mode:
Diffstat (limited to 'test/testdata/eval-okay-regex-match.nix')
-rw-r--r--test/testdata/eval-okay-regex-match.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/testdata/eval-okay-regex-match.nix b/test/testdata/eval-okay-regex-match.nix
new file mode 100644
index 0000000..273e259
--- /dev/null
+++ b/test/testdata/eval-okay-regex-match.nix
@@ -0,0 +1,29 @@
1with builtins;
2
3let
4
5 matches = pat: s: match pat s != null;
6
7 splitFN = match "((.*)/)?([^/]*)\\.(nix|cc)";
8
9in
10
11assert matches "foobar" "foobar";
12assert matches "fo*" "f";
13assert !matches "fo+" "f";
14assert matches "fo*" "fo";
15assert matches "fo*" "foo";
16assert matches "fo+" "foo";
17assert matches "fo{1,2}" "foo";
18assert !matches "fo{1,2}" "fooo";
19assert !matches "fo*" "foobar";
20assert matches "[[:space:]]+([^[:space:]]+)[[:space:]]+" " foo ";
21assert !matches "[[:space:]]+([[:upper:]]+)[[:space:]]+" " foo ";
22
23assert match "(.*)\\.nix" "foobar.nix" == [ "foobar" ];
24assert match "[[:space:]]+([[:upper:]]+)[[:space:]]+" " FOO " == [ "FOO" ];
25
26assert splitFN "/path/to/foobar.nix" == [ "/path/to/" "/path/to" "foobar" "nix" ];
27assert splitFN "foobar.cc" == [ null null "foobar" "cc" ];
28
29true