diff options
Diffstat (limited to 'unit-tests/test/script')
-rw-r--r-- | unit-tests/test/script/parser/regex.test | 14 | ||||
-rw-r--r-- | unit-tests/test/script/regex/driver.cxx | 45 |
2 files changed, 29 insertions, 30 deletions
diff --git a/unit-tests/test/script/parser/regex.test b/unit-tests/test/script/parser/regex.test index f3fda75..f9101c9 100644 --- a/unit-tests/test/script/parser/regex.test +++ b/unit-tests/test/script/parser/regex.test @@ -46,9 +46,12 @@ : malformed : - $* <'cmd >~/*foo/' 2>>~/EOE/ != 0 + : Note that old versions of libc++ (for example 1.1) do not detect some + : regex errors. For example '*' is parsed successfully. + : + $* <'cmd >~/foo[/' 2>>~/EOE/ != 0 /testscript:1:7: error: invalid stdout regex redirect.*/ - info: regex: /*foo/ + info: regex: /foo[/ EOE : without-flags @@ -128,7 +131,7 @@ : $* <<EOI 2>>~/EOE/ != 0 cmd >>~/EOO/ - /?foo/ + /foo[/ EOO EOI /testscript:2:1: error: invalid regex.*/ @@ -138,10 +141,11 @@ : $* <<EOI 2>>~/EOE/ != 0 cmd >>~/EOO/ - /* + a + /{ EOO EOI - /testscript:3:1: error: invalid here-document regex.*/ + /testscript:4:1: error: invalid here-document regex.*/ EOE : empty diff --git a/unit-tests/test/script/regex/driver.cxx b/unit-tests/test/script/regex/driver.cxx index 643756e..6ff4d75 100644 --- a/unit-tests/test/script/regex/driver.cxx +++ b/unit-tests/test/script/regex/driver.cxx @@ -35,12 +35,20 @@ main () enum meta {mn = 'n', mp = 'p'}; + // Special roundtrip. + // + assert (lc ('0').special () == '0'); + assert (lc (0).special () == 0); + assert (lc (-1).special () == -1); + assert (lc ('p').special () == 'p'); + assert (lc (u'\u2028').special () == u'\u2028'); + // Special comparison. // assert (lc ('0') == lc ('0')); assert (lc ('0') == '0'); assert (lc ('n') == mn); - assert (mn == static_cast<meta> (lc ('n'))); + assert (mn == static_cast<meta> (lc ('n'))); assert (lc ('0') != lc ('1')); assert (lc ('0') != '1'); @@ -58,11 +66,15 @@ main () assert (lc ('n') <= mn); assert (lc ('1') <= lc ("0", p)); + // Literal roundtrip. + // + assert (*lc ("abc", p).literal () == "abc"); + // Literal comparison. // - assert (lc ("a", p) == lc ("a", p)); - assert (lc ("a", p).literal == lc ("a", p).literal); - assert (char (lc ("a", p)) == '\a'); + assert (lc ("a", p) == lc ("a", p)); + assert (lc ("a", p).literal () == lc ("a", p).literal ()); + assert (char (lc ("a", p)) == '\a'); assert (lc ("a", p) != lc ("b", p)); assert (!(lc ("a", p) != lc (regex ("a"), p))); // Matches. @@ -75,6 +87,10 @@ main () assert (lc ("a", p) <= lc (regex ("a"), p)); assert (lc ("a", p) < lc (regex ("c"), p)); + // Regex roundtrip. + // + assert (regex_match ("abc", *lc (regex ("abc"), p).regex ())); + // Regex comparison. // assert (lc ("a", p) == lc (regex ("a|b"), p)); @@ -129,27 +145,6 @@ main () assert (v1 == vc ({'1', '2', '2'})); } - // Test line_string. - // - // @@ Add more tests. - // - // Note that the following code crashes if compiled with libc++ (LLVM bug - // #31454). - // - // @@ Probably we can overcome it by providing our own allocator for - // basic_string instantiation. The function allocate() could allocate some - // more elements that would be enough not to corrupt the memory (which - // push_back() does). - // @@ But maybe doesn't worth to bother as the bug seems to get assigned. - // @@ Heavily affects MacOS where clang++/libc++ is the default setup. - // - { - line_string s; - s.push_back (line_char ('0')); - s.push_back (line_char ('1')); - s.push_back (line_char ('2')); - } - // Test line_char_locale and ctype<line_char> (only non-trivial functions). // { |