shithub: mc

Download patch

ref: c9a1c6a12afc70747acc0b141ac1e04cd61b0f8b
parent: 6ed494853cfc436672cc3d296f42034ea475dd40
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jun 7 13:54:23 EDT 2016

add test for chomp

--- a/lib/std/chomp.myr
+++ b/lib/std/chomp.myr
@@ -5,7 +5,7 @@
 ;;
 
 const chomp = {str, pfx
-	if std.hasprefix(str)
+	if std.hasprefix(str, pfx)
 		-> str[pfx.len:]
 	else
 		-> str
--- /dev/null
+++ b/lib/std/test/chomp.myr
@@ -1,0 +1,7 @@
+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")
+}