namespace WoofWare.Expect.Test open WoofWare.Expect open NUnit.Framework [] [] module TestRegexMetacharacters = [] let ``Prepare to bulk-update tests`` () = // GlobalBuilderConfig.enterBulkUpdateMode () () [] let ``Update all tests`` () = GlobalBuilderConfig.updateAllSnapshots () type Dummy = class end [] let ``Regex metacharacters in verbatim string`` () = let source = Assembly.getEmbeddedResource typeof.Assembly "RegexMetacharacters.fs" |> _.Split('\n') expect { snapshot @"namespace BigExample open WoofWare.Expect module MyModule = let regexChars () = expect { snapshot @""replacement with .*+?[]{}()|^$\ chars"" return 123 } let regexInTripleQuote () = expect { snapshot """"""regex: .*+?[]{}()|^$\ in triple quotes"""""" return 456 } let regexInRegularString () = expect { snapshot ""escaped regex: \\.\\*\\+\\?\\[\\]\\{\\}\\(\\)\\|\\^\\$\\\\"" return 789 } let complexRegexPattern () = expect { snapshotJson @""^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"" return ""IP regex"" } " return SnapshotUpdate.updateSnapshotAtLine source 8 "replacement with .*+?[]{}()|^$\\ chars" |> String.concat "\n" } [] let ``Regex metacharacters in triple quote`` () = let source = Assembly.getEmbeddedResource typeof.Assembly "RegexMetacharacters.fs" |> _.Split('\n') expect { snapshot @"namespace BigExample open WoofWare.Expect module MyModule = let regexChars () = expect { snapshot @""test with regex chars: .*+?[]{}()|^$\ and more"" return 123 } let regexInTripleQuote () = expect { snapshot @""new regex: [a-z]+(?:\d{2,4})? pattern"" return 456 } let regexInRegularString () = expect { snapshot ""escaped regex: \\.\\*\\+\\?\\[\\]\\{\\}\\(\\)\\|\\^\\$\\\\"" return 789 } let complexRegexPattern () = expect { snapshotJson @""^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"" return ""IP regex"" } " return SnapshotUpdate.updateSnapshotAtLine source 14 "new regex: [a-z]+(?:\\d{2,4})? pattern" |> String.concat "\n" } [] let ``Regex metacharacters in regular string`` () = let source = Assembly.getEmbeddedResource typeof.Assembly "RegexMetacharacters.fs" |> _.Split('\n') expect { snapshot @"namespace BigExample open WoofWare.Expect module MyModule = let regexChars () = expect { snapshot @""test with regex chars: .*+?[]{}()|^$\ and more"" return 123 } let regexInTripleQuote () = expect { snapshot """"""regex: .*+?[]{}()|^$\ in triple quotes"""""" return 456 } let regexInRegularString () = expect { snapshot @""new regex: [a-z]+(?:\d{2,4})? pattern"" return 789 } let complexRegexPattern () = expect { snapshotJson @""^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"" return ""IP regex"" } " return SnapshotUpdate.updateSnapshotAtLine source 20 "new regex: [a-z]+(?:\\d{2,4})? pattern" |> String.concat "\n" } [] let ``IP regex`` () = let source = Assembly.getEmbeddedResource typeof.Assembly "RegexMetacharacters.fs" |> _.Split('\n') expect { snapshot @"namespace BigExample open WoofWare.Expect module MyModule = let regexChars () = expect { snapshot @""test with regex chars: .*+?[]{}()|^$\ and more"" return 123 } let regexInTripleQuote () = expect { snapshot """"""regex: .*+?[]{}()|^$\ in triple quotes"""""" return 456 } let regexInRegularString () = expect { snapshot ""escaped regex: \\.\\*\\+\\?\\[\\]\\{\\}\\(\\)\\|\\^\\$\\\\"" return 789 } let complexRegexPattern () = expect { snapshotJson @""new regex: [a-z]+(?:\d{2,4})? pattern"" return ""IP regex"" } " return SnapshotUpdate.updateSnapshotAtLine source 26 "new regex: [a-z]+(?:\\d{2,4})? pattern" |> String.concat "\n" }