aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArun Isaac2021-02-27 23:50:48 +0530
committerArun Isaac2021-02-27 23:50:48 +0530
commitc37a8e33f790b385ec1f913b062ad5b5f4bbe96e (patch)
tree5f19b5ff43b5c7f2c72d4a523a01b36064b0a965 /tests
parentd475760dfbbc0a3bb2732a924b006e68f6dcc065 (diff)
downloadccwl-c37a8e33f790b385ec1f913b062ad5b5f4bbe96e.tar.gz
ccwl-c37a8e33f790b385ec1f913b062ad5b5f4bbe96e.tar.lz
ccwl-c37a8e33f790b385ec1f913b062ad5b5f4bbe96e.zip
Add break-pair utility.
* ccwl/ccwl.scm (break-pair): New function. * tests/ccwl.scm: New file. * tests/ccwl.scm ("break-pair", "break-pair: check last elemet handling"): New test cases.
Diffstat (limited to 'tests')
-rw-r--r--tests/ccwl.scm34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ccwl.scm b/tests/ccwl.scm
new file mode 100644
index 0000000..3d4799c
--- /dev/null
+++ b/tests/ccwl.scm
@@ -0,0 +1,34 @@
+(use-modules (srfi srfi-71)
+ (srfi srfi-64))
+
+(define break-pair
+ (module-ref (resolve-module '(ccwl ccwl))
+ 'break-pair))
+
+(test-begin "ccwl")
+
+(test-assert "break-pair"
+ (let ((prefix tail
+ (break-pair (case-lambda
+ ((element next)
+ (or (odd? element)
+ (odd? next)))
+ ((last)
+ (odd? last)))
+ (list 12 66 74 95 7 74 96 46 99 76 37))))
+ (equal? prefix (list 12 66))
+ (equal? tail (list 74 95 7 74 96 46 99 76 37))))
+
+(test-assert "break-pair: check last elemet handling"
+ (let ((prefix tail
+ (break-pair (case-lambda
+ ((element next)
+ (or (odd? element)
+ (odd? next)))
+ ((last)
+ (odd? last)))
+ (list 12 66 74))))
+ (equal? prefix (list 12 66 74))
+ (equal? tail (list))))
+
+(test-end "ccwl")