Logo

index : blog

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/blog.git/html/modules/uniform/tests/100_compile.spec.jai blob: 12aef0f804ed7ecff73ef6a50451b81a67a41bcf [raw] [clear marker]

        
0simplifies_a_parsed_regexp_without_error_params :: Stringify_Test_Args.[
1 .{"", ""},
2 .{"a", "a"},
3 .{"abcd", "abcd"},
4 .{"ab(cd)", "ab(cd)"},
5 .{"a{2}", "aa"},
6 .{"[ac]{2}", "[ac][ac]"},
7 .{"[abc]{2}", "[a-c][a-c]"},
8 .{"[ac]{2,}", "[ac][ac]+"},
9 .{"[ac]{2,4}", "[ac][ac](?:[ac][ac]?)?"},
10 .{"a[bc]{2}d", "a[b-c][b-c]d"},
11 .{"ab?(cd)+", "ab?(cd)+"},
12 .{"ab?(cd)+a*(:?foo)?", "ab?(cd)+a*(:?foo)?"},
13 .{"a*", "a*"},
14];
15
16simplifies_a_parsed_regexp_without_error :: (args: Stringify_Test_Args) {
17 parsed, status, pool := parse(args.pattern);
18 defer uninit(*pool);
19
20 result := simplify(parsed, *pool);
21
22 assert_that(result, is_not(null));
23 stringified := to_string(result);
24 defer free(stringified);
25 assert_that(stringified, is(args.expected_string));
26} @Test
27
28compiles_a_parsed_regexp_without_error_params :: string.[
29 "",
30 "a",
31 "abcd",
32 "ab(cd)",
33 "a{2}",
34 "[ab]{2}",
35 "[ab]{2,}",
36 "[ab]{2,4}",
37 "a[bc]{2}d",
38 "ab?(cd)+",
39 "ab?(cd)+a*(:?foo)?",
40 "a*",
41 "[^a]", // This range contains both single-byte and multi-byte utf-8 characters
42 ".",
43 ".*",
44];
45
46compiles_a_parsed_regexp_without_error :: (re_string: string) {
47 parsed, status, pool := parse(re_string);
48 defer uninit(*pool);
49
50 re := compile(parsed, *pool);
51
52 assert_that(re, is_not(null));
53} @Test
54
55#scope_file
56
57Stringify_Test_Args :: struct {
58 pattern: string;
59 expected_string: string;
60}
61
62
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit