shithub: mc

Download patch

ref: 2b9c96053f0d6947452862d89217541b96492241
parent: 69c70ba14ea083bf65395ee45f3aff5956e77d83
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Jun 10 05:27:37 EDT 2016

Fix chomp.

--- a/lib/std/test/chomp.myr
+++ b/lib/std/test/chomp.myr
@@ -1,7 +1,16 @@
 use std
 
 const main = {
-	std.assert(std.sleq(std.chomp("aaab", "aaa"), "b"), "expected chomp(aaab, aaa) => b\n")
-	std.assert(std.sleq(std.chomp("aaa", "aaa"), ""), "expected chomp(aaa,aaa) => ''\n")
-	std.assert(std.sleq(std.chomp("aa", "aaa"), "aa"), "expected chomp(aa,aaa) => aa\n")
+	check("aaab", "aaa", "b")
+	check("aaa", "aaa", "")
+	check("aa", "aaa", "aa")
+}
+
+const check = {sl, pfx, expected
+	var r
+
+	r = sl
+	std.chomp(&r, pfx)
+	std.assert(std.sleq(r, expected), \
+		"expected chomp({}, {}) => {}, got {}\n", sl, pfx, expected, r)
 }