shithub: mc

Download patch

ref: ad008b9e79bfae6db3cf4049ac441f9696f2c459
parent: ad893b63f1fe71c628742a0e38ddae971bdf8231
author: Ori Bernstein <[email protected]>
date: Tue Nov 4 16:53:47 EST 2014

Fix most tests.

    Matching constants is still buggered.

--- a/libstd/search.myr
+++ b/libstd/search.myr
@@ -15,6 +15,8 @@
 		match cmp(sl[i], val)
 		| `Equal:
 			-> `Some i
+		| _:
+			/* nothing */
 		;;
 	;;
 	-> `None
--- a/libstd/sort.myr
+++ b/libstd/sort.myr
@@ -40,10 +40,12 @@
 		s = r
 		match cmp(sl[s], sl[c])
 		| `Before:	s = c
+		| _:		/* nothing */
 		;;
 		if c + 1 < sl.len
 			match cmp(sl[s], sl[c + 1])
 			| `Before:	s = c + 1
+			| _:	/* nothing */
 			;;
 		;;
 		if s != r
--- a/test/genericret.myr
+++ b/test/genericret.myr
@@ -12,6 +12,7 @@
 const main = {
 	match f()
 	| `None:	std.exit(42)
+	| _:		std.die("Impossible match failure\n");
 	;;
 	std.exit(0)
 }
--- a/test/generictype.myr
+++ b/test/generictype.myr
@@ -13,6 +13,7 @@
 	match v
 	| `None:	std.exit(1)
 	| `Some 123:	std.exit(0)
+	| `Some _:	std.die("Impossible match failure\n")
 	;;
 	std.exit(60)
 }
--- a/test/matchargstr.myr
+++ b/test/matchargstr.myr
@@ -17,6 +17,7 @@
 	| `Str "fsda":	std.fatal(1, "Wrong match `Str \"fsda\"\n")
 	| `Str "asdf":	std.put("Correct `Str \"asdf\"!\n")
 	| `Nil:		std.fatal(1, "Wrong match `Str \"fsda\"\n")
+	| _:		std.fatal(1, "Impossible failed match\n")
 	;;
 }
 
--- a/test/matchargunion.myr
+++ b/test/matchargunion.myr
@@ -12,10 +12,11 @@
 
 	v = `Int 123
 	match v
-	| `Int 127:	 std.exit(42)
-	| `Int 123:	 std.exit(69)
-	| `Chr 'a':	 std.exit(4)
-	| `Nil:	 std.exit(6)
+	| `Int 127:	std.exit(42)
+	| `Int 123:	std.exit(69)
+	| `Chr 'a':	std.exit(4)
+	| `Nil:		std.exit(6)
+	| _:		std.die("Impossible failed match\n")
 	;;
 }
 
--- a/test/matchbind.myr
+++ b/test/matchbind.myr
@@ -16,6 +16,7 @@
 	| `Int x:	std.exit(x)
 	| `Chr 'a':	std.exit(4)
 	| `Nil:		std.exit(6)
+	| x:		std.die("Impossible match failure\n")
 	;;
 }
 
--- a/test/matchint.myr
+++ b/test/matchint.myr
@@ -11,5 +11,6 @@
 	| 4:	std.exit(99)
 	| 12:	std.exit(84)
 	| 6:	std.exit(18)
+	| x:	std.die("Got an unexpected int!\n")
 	;;
 }
--- a/test/matchunion_sl.myr
+++ b/test/matchunion_sl.myr
@@ -15,6 +15,7 @@
 	| `Int 127: std.exit(42)
 	| `Str s: std.put("%s\n", s)
 	| `Nil:
+	| _:	std.die("Impossible match failure\n")
 	;;
 }
 
--- a/test/nestucon.myr
+++ b/test/nestucon.myr
@@ -13,6 +13,7 @@
 	a = [.x = `Str "asdf"]
 	match a
 	| [.x=`Str s]:	std.put("%s\n", s)
+	| _:	std.die("Impossible match failure\n")
 	;;
 }
 
--- a/test/stdsearch.myr
+++ b/test/stdsearch.myr
@@ -20,6 +20,7 @@
 	| `std.None:
 		match b
 		| `std.Some x: std.fatal(1, "Expected `std.None, `std.None, got `std.None, `std.Some %i\n", x)
+		| `std.None:	/* nothing */
 		;;
 	| `std.Some x:
 		match b