package commons

  1. Overview
  2. Docs
Yet another set of common utilities

Install

Dune Dependency

Authors

Maintainers

Sources

commons_1.8.0.tar.gz
md5=00142d2d5f299c86ee44f19820bf9874
sha512=d25a57c434514ecb9adc5a129eeec9feca1cea2d1383e3bde74b52a05da174a09e0f46e7407f7b86ecdf1bf6faf7e0a66ef744d6fb389cb5f8398bc32e349555

doc/src/commons.tests/Unit_regexp_engine.ml.html

Source file Unit_regexp_engine.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(*
   Unit tests for SPcre
*)

let test_remove_eos_assertions () =
  let check (input, expected_output) =
    let output =
      Regexp_engine.remove_end_of_string_assertions_from_string input
    in
    Alcotest.(check (option string)) input expected_output output
  in
  List.iter check
    [
      ("", Some "");
      ("A", Some "A");
      ("AA", Some "AA");
      ("AAA", Some "AAA");
      ("AAAA", Some "AAAA");
      ({|\$|}, Some {|\$|});
      ({|A\$|}, Some {|A\$|});
      ({|AA\$|}, Some {|AA\$|});
      ({|AAA\$|}, Some {|AAA\$|});
      ({|AAAA\$|}, Some {|AAAA\$|});
      ("^", Some "");
      ("$", Some "");
      ({|\A|}, Some "");
      ({|\Z|}, Some "");
      ({|\z|}, Some "");
      ("^$", Some "");
      ({|^\Z|}, Some "");
      ({|\A$|}, Some "");
      ({|\A\Z|}, Some "");
      ("^A$", Some "A");
      ("^AA$", Some "AA");
      ("^AAA$", Some "AAA");
      ("^^", None);
      ("$$", None);
      ({|A\A|}, Some {|A\A|});
      ("[$]*", None);
      ("(?:^)", None);
      ({|\\A|}, Some {|\\A|});
      ({|(?<!.|\n)|}, None);
      (* DIY beginning-of-string assertion = \A *)
      ({|(?!.|\n)|}, None) (* DIY end-of-string assertion = \z *);
    ]

let tests =
  Testutil.pack_tests "regexp engine"
    [ ("remove eos assertions", test_remove_eos_assertions) ]
OCaml

Innovation. Community. Security.