From 2d4d37907eb060fc23cc4a9f8ebf6b577db3a18b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 5 Oct 2020 06:19:02 -0700 Subject: New functions trim-left and trim-right. * regex.c (trim_left, trim_right): New static functions. (regex_init): New intrinsics registered. * tests/015/trim.tl, tests/015/trim.expected: New files. * txr.1: Documented. --- tests/015/trim.tl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/015/trim.tl (limited to 'tests/015/trim.tl') diff --git a/tests/015/trim.tl b/tests/015/trim.tl new file mode 100644 index 00000000..da1fc0c1 --- /dev/null +++ b/tests/015/trim.tl @@ -0,0 +1,41 @@ +(load "../common") + +(mtest + (trim-left "" "") "" + (trim-left 1 "") :error + (trim-left "" 1) :error + (trim-left 1 1) :error) + +(mtest + (trim-left "" "abc") "abc" + (trim-left "a" "abc") "bc" + (trim-left "ab" "abc") "c" + (trim-left "abc" "abc") "" + (trim-left "abcd" "abc") "abc" + (trim-left "z" "abc") "abc") + +(mtest + (trim-left #// "abc") "abc" + (trim-left #/./ "abc") "bc" + (trim-left #/../ "abc") "c" + (trim-left #/.../ "abc") "" + (trim-left #/.*/ "abc") "" + (trim-left #/..../ "abc") "abc" + (trim-left #/z/ "abc") "abc") + +(mtest + (trim-right "" "abc") "abc" + (trim-right "c" "abc") "ab" + (trim-right "bc" "abc") "a" + (trim-right "abc" "abc") "" + (trim-right "xabc" "abc") "abc" + (trim-right "z" "abc") "abc") + +(mtest + (trim-right #// "abc") "abc" + (trim-right #/./ "abc") "ab" + (trim-right #/../ "abc") "a" + (trim-right #/.../ "abc") "" + (trim-right #/.*/ "abc") "" + (trim-right #/..../ "abc") "abc" + (trim-right #/z/ "abc") "abc") -- cgit v1.2.3