diff options
author | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-15 20:23:50 +0100 |
---|---|---|
committer | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-15 20:23:50 +0100 |
commit | 1d93e444ff1e0190b32f2f15ee90d330088a0241 (patch) | |
tree | 9e84c1e4b483b3c37cae68c124353b0fa7967ff9 | |
parent | 30d4cf0a191b923b2d651a16ad40dc6762a4bedb (diff) |
[test] Leak on reuse of Match().
-rw-r--r-- | test/RegexMatch.fu | 13 | ||||
-rw-r--r-- | test/RegexMatchReuse.fu | 15 |
2 files changed, 22 insertions, 6 deletions
diff --git a/test/RegexMatch.fu b/test/RegexMatch.fu index 15e2a5a..14c3215 100644 --- a/test/RegexMatch.fu +++ b/test/RegexMatch.fu @@ -12,13 +12,14 @@ public class Test || m.Value != "brown fox" || m.GetCapture(1) != "brown" || m.GetCapture(2) != "fox") return false; + Match() m2; string p = "The quick brown fox jumps over the lazy dog"; - if (!m.Find(p, "(B.+?) (\\wo\\w)", RegexOptions.IgnoreCase)) + if (!m2.Find(p, "(B.+?) (\\wo\\w)", RegexOptions.IgnoreCase)) return false; - return m.Start == 10 - && m.End == 19 && m.End * 2 == 38 - && m.Length == 9 && m.Length * 2 == 18 - && m.Value == "brown fox" - && m.GetCapture(1) == "brown" && m.GetCapture(2) == "fox"; + return m2.Start == 10 + && m2.End == 19 && m2.End * 2 == 38 + && m2.Length == 9 && m2.Length * 2 == 18 + && m2.Value == "brown fox" + && m2.GetCapture(1) == "brown" && m2.GetCapture(2) == "fox"; } } diff --git a/test/RegexMatchReuse.fu b/test/RegexMatchReuse.fu new file mode 100644 index 0000000..b2f92d5 --- /dev/null +++ b/test/RegexMatchReuse.fu @@ -0,0 +1,15 @@ +public class Test +{ + public static bool Run() + { + Match() m; + string() s = "foo bar"; //FAIL: cl + if (!m.Find(s, "\\w{3}")) //FAIL: swift TODO + return false; + if (m.Start != 0) + return false; + if (!m.Find(s, "b\\w\\w")) //FAIL: c leak TODO + return false; + return m.Start == 4; + } +} |