@@ -37,6 +37,32 @@ let tests =
3737 let r = Regex( " [a-z]" , options)
3838 int r.Options |> equal 257
3939
40+ testCase " RegexOptions.NonBacktracking = 1024" <| fun _ ->
41+ let options = RegexOptions.NonBacktracking
42+ int options |> equal 1024
43+
44+ testCase " Nonbacktracking regex tests" <| fun _ ->
45+ // Note: this is not consistent with .NET because JS linear engine
46+ // does not support unicode. JS \d = 10 digits, .NET \d = 350+ digits
47+ // but for these tests the behavior should be identical.
48+ let none = RegexOptions.None
49+ let nonb = RegexOptions.NonBacktracking
50+ let multiline = RegexOptions.Multiline
51+ let ignorecase = RegexOptions.IgnoreCase
52+ let multilineignorecase = multiline ||| ignorecase
53+ let str = " For more information, see Chapter 3.4.5.1"
54+ let sameResult extraopts str pat =
55+ let result1 = Regex.Match( str, pat, none ||| extraopts) .Success
56+ let result2 = Regex.Match( str, pat, nonb ||| extraopts) .Success
57+ equal result1 result2
58+ sameResult none str " Chapter \d +(\.\d )*"
59+ sameResult none str " chapter \d +(\.\d )*"
60+ sameResult multilineignorecase " ^ab" " ab\n cd"
61+ sameResult multilineignorecase " ^cd" " ab\n cd"
62+ sameResult multilineignorecase " ^AB" " ab\n cd"
63+ sameResult multilineignorecase " ^bc" " ab\n cd"
64+
65+
4066 testCase " Regex.IsMatch with IgnoreCase and Multiline works" <| fun _ ->
4167 let str = " ab\n cd"
4268 let option1 = RegexOptions.IgnoreCase
0 commit comments