diff options
author | Rutger Broekhoff | 2025-07-07 21:52:08 +0200 |
---|---|---|
committer | Rutger Broekhoff | 2025-07-07 21:52:08 +0200 |
commit | ba61dfd69504ec6263a9dee9931d93adeb6f3142 (patch) | |
tree | d6c9b78e50eeab24e0c1c09ab45909a6ae3fd5db /test/testdata/eval-okay-regex-match.nix | |
download | verified-dyn-lang-interp-ba61dfd69504ec6263a9dee9931d93adeb6f3142.tar.gz verified-dyn-lang-interp-ba61dfd69504ec6263a9dee9931d93adeb6f3142.zip |
Initialize repository
Diffstat (limited to 'test/testdata/eval-okay-regex-match.nix')
-rw-r--r-- | test/testdata/eval-okay-regex-match.nix | 29 |
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 @@ | |||
1 | with builtins; | ||
2 | |||
3 | let | ||
4 | |||
5 | matches = pat: s: match pat s != null; | ||
6 | |||
7 | splitFN = match "((.*)/)?([^/]*)\\.(nix|cc)"; | ||
8 | |||
9 | in | ||
10 | |||
11 | assert matches "foobar" "foobar"; | ||
12 | assert matches "fo*" "f"; | ||
13 | assert !matches "fo+" "f"; | ||
14 | assert matches "fo*" "fo"; | ||
15 | assert matches "fo*" "foo"; | ||
16 | assert matches "fo+" "foo"; | ||
17 | assert matches "fo{1,2}" "foo"; | ||
18 | assert !matches "fo{1,2}" "fooo"; | ||
19 | assert !matches "fo*" "foobar"; | ||
20 | assert matches "[[:space:]]+([^[:space:]]+)[[:space:]]+" " foo "; | ||
21 | assert !matches "[[:space:]]+([[:upper:]]+)[[:space:]]+" " foo "; | ||
22 | |||
23 | assert match "(.*)\\.nix" "foobar.nix" == [ "foobar" ]; | ||
24 | assert match "[[:space:]]+([[:upper:]]+)[[:space:]]+" " FOO " == [ "FOO" ]; | ||
25 | |||
26 | assert splitFN "/path/to/foobar.nix" == [ "/path/to/" "/path/to" "foobar" "nix" ]; | ||
27 | assert splitFN "foobar.cc" == [ null null "foobar" "cc" ]; | ||
28 | |||
29 | true | ||