summaryrefslogtreecommitdiffstats
path: root/tests/018
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-22 06:53:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-22 06:53:56 -0700
commit08b4921e616a17ed8492527c6a89c08ccc33ea35 (patch)
treea67cc7524770d4113125ea643895ae8796bba998 /tests/018
parent26b9e97b65074eeee273bf6dd8ee1958f1128c1e (diff)
downloadtxr-08b4921e616a17ed8492527c6a89c08ccc33ea35.tar.gz
txr-08b4921e616a17ed8492527c6a89c08ccc33ea35.tar.bz2
txr-08b4921e616a17ed8492527c6a89c08ccc33ea35.zip
New functions: long-suffix, short-suffix.
* stream.c (short_suffix, long_suffix): New functions. (stream_init): short-suffix and long-suffix intrinsics registered. * stream.c (short_suffix, long_suffix): Declared. * tests/018/path.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests/018')
-rw-r--r--tests/018/path.tl34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/018/path.tl b/tests/018/path.tl
new file mode 100644
index 00000000..be95d6c1
--- /dev/null
+++ b/tests/018/path.tl
@@ -0,0 +1,34 @@
+(load "../common")
+
+(mtest
+ (short-suffix 42) :error
+ (short-suffix #\a) :error
+ (short-suffix "") nil
+ (short-suffix "" 0) 0
+ (short-suffix "a") nil
+ (short-suffix "a" 0) 0
+ (short-suffix ".") ""
+ (short-suffix "a.") ""
+ (short-suffix "a.b.") ""
+ (short-suffix ".c") "c"
+ (short-suffix "a.c") "c"
+ (short-suffix "a.b.c") "c"
+ (short-suffix "foo.txt.gz") "gz"
+ (short-suffix ".gz") "gz")
+
+(mtest
+ (long-suffix 42) :error
+ (long-suffix #\a) :error
+ (long-suffix "") nil
+ (long-suffix "" 0) 0
+ (long-suffix "a") nil
+ (long-suffix "a" 0) 0
+ (long-suffix ".") ""
+ (long-suffix "a.") ""
+ (long-suffix "a.b.") "b."
+ (long-suffix ".c") "c"
+ (long-suffix "a.c") "c"
+ (long-suffix "a.b.c") "b.c"
+ (long-suffix "foo.txt.gz") "txt.gz"
+ (long-suffix ".gz") "gz"
+ (long-suffix ".txt.gz") "txt.gz")