marking1/collatz_test2.scala
changeset 267 9e0216756771
parent 212 4bda49ec24da
child 281 87b9e3e2c1a7
--- a/marking1/collatz_test2.scala	Wed Jul 24 14:22:06 2019 +0100
+++ b/marking1/collatz_test2.scala	Wed Jul 24 15:18:44 2019 +0100
@@ -1,17 +1,23 @@
-
-
-assert(collatz_max(10) == (19, 9))
+def myassert(cond : => Boolean) = {
+  try {
+    assert(cond)
+  } catch { 
+    case _ : Throwable => System.exit(1)
+  }
+}
 
-assert(collatz_max(100) == (118, 97))
+myassert(collatz_max(10) == (19, 9))
 
-assert(collatz_max(1000) == (178, 871))
+myassert(collatz_max(100) == (118, 97))
 
-assert(collatz_max(10000) == (261, 6171))
+myassert(collatz_max(1000) == (178, 871))
 
-assert(collatz_max(100000) == (350, 77031))
+myassert(collatz_max(10000) == (261, 6171))
+
+myassert(collatz_max(100000) == (350, 77031))
 
-assert(collatz_max(1000000) == (524, 837799))
+myassert(collatz_max(1000000) == (524, 837799))
 
-//assert(collatz_max(2) == (1, 2) || collatz_max(2) == (0, 1))
-assert(collatz_max(2) == (1, 2))
-assert(collatz_max(77000) == (339, 52527))
+myassert(collatz_max(2) == (1, 2))
+
+myassert(collatz_max(77000) == (339, 52527))