updated myassert workaround
authorChristian Urban <urbanc@in.tum.de>
Wed, 24 Jul 2019 15:18:44 +0100
changeset 267 9e0216756771
parent 266 ca48ac1d3c3e
child 268 e43f7e92ba26
updated myassert workaround
marking1/collatz_test.sh
marking1/collatz_test1.scala
marking1/collatz_test2.scala
marking1/drumb_test.sh
marking1/drumb_test1.scala
--- a/marking1/collatz_test.sh	Wed Jul 24 14:22:06 2019 +0100
+++ b/marking1/collatz_test.sh	Wed Jul 24 15:18:44 2019 +0100
@@ -19,7 +19,7 @@
 echo "The feedback for your submission for collatz.scala" >> $out
 echo "" >> $out
 
-# marks for CW6 part 1
+# marks for CW6 basic part 
 marks=$(( 0 ))
 
 # compilation tests
@@ -121,7 +121,7 @@
 
 ## final marks
 echo >> $out
-echo "Overall mark for Basic Part" | tee -a $out
+echo "Overall mark for the Basic Part" | tee -a $out
 echo " $marks" | tee -a $out
 
 
--- a/marking1/collatz_test1.scala	Wed Jul 24 14:22:06 2019 +0100
+++ b/marking1/collatz_test1.scala	Wed Jul 24 15:18:44 2019 +0100
@@ -1,10 +1,14 @@
-
 
-assert(collatz(1) == 0)
-assert(collatz(6) == 9)
-assert(collatz(9) == 19)
-assert(collatz(9000) == 47)
+def myassert(cond : => Boolean) = {
+  try {
+    assert(cond)
+  } catch { 
+    case _ : Throwable => System.exit(1)
+  }
+}
 
+myassert(collatz(1) == 0)
+myassert(collatz(6) == 8)
+myassert(collatz(9) == 19)
+myassert(collatz(9000) == 47)
 
-System.exit(4)
-
--- 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))
--- a/marking1/drumb_test.sh	Wed Jul 24 14:22:06 2019 +0100
+++ b/marking1/drumb_test.sh	Wed Jul 24 15:18:44 2019 +0100
@@ -82,7 +82,7 @@
 if [ $tsts -eq 0 ]
 then
   echo "  get_january_data(\"GOOG\", 1980) == List()" | tee -a $out
-  echo "  get_january_data(\"GOOG\", 2010).head == \"2010-01-04,311.349976\"" | tee -a $out
+  echo "  get_january_data(\"GOOG\", 2010).head == \"2010-01-04,312.204773\"" | tee -a $out
 
   if (scala_assert "drumb.scala" "drumb_test1.scala")
   then
--- a/marking1/drumb_test1.scala	Wed Jul 24 14:22:06 2019 +0100
+++ b/marking1/drumb_test1.scala	Wed Jul 24 15:18:44 2019 +0100
@@ -1,21 +1,12 @@
-
-
-assert(get_january_data("GOOG", 1980) == List())
-
-assert(get_january_data("GOOG", 2010).head == "2010-01-04,311.349976")
-
-
-
+def myassert(cond : => Boolean) = {
+  try {
+    assert(cond)
+  } catch { 
+    case _ : Throwable => System.exit(1)
+  }
+}
 
-/*
-assert(CW6c.get_prices(List("BIDU"), 2004 to 2008) == 
-       List(List(None), List(None), 
-            List(Some(6.35)), List(Some(12.241)), 
-            List(Some(38.188))))
+myassert(get_january_data("GOOG", 1980) == List())
 
+myassert(get_january_data("GOOG", 2010).head == "2010-01-04,312.204773")
 
-assert(CW6c.get_prices(List("GOOG", "AAPL"), 2010 to 2012) ==
-       List(List(Some(311.349976), Some(27.505054)), 
-            List(Some(300.222351), Some(42.357094)), 
-            List(Some(330.555054), Some(52.852215))))
-*/