updated
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 21 Dec 2016 01:19:25 +0000
changeset 93 21f41e08457d
parent 92 cfff88de2ff5
child 94 ae4708c851ee
updated
marking/knight3b_test.scala
marking/mark02b
marking/mark03b
marking/re1d_test.scala
marking/test
--- a/marking/knight3b_test.scala	Tue Dec 20 01:48:09 2016 +0000
+++ b/marking/knight3b_test.scala	Wed Dec 21 01:19:25 2016 +0000
@@ -31,7 +31,7 @@
 
 lazy val f = Future {
 
-  val tsc = first_closed_tour_heuristic(6, List((3, 3))).get
+  val tsc = first_closed_tour_heuristic(6, List(List((3, 3)))).get
   assert(correct_closed_urban(6)(tsc) == true)
 
 }
--- a/marking/mark02b	Tue Dec 20 01:48:09 2016 +0000
+++ b/marking/mark02b	Wed Dec 21 01:19:25 2016 +0000
@@ -26,7 +26,7 @@
 # functional tests
 
 function scala_assert {
-  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+  (scala -i "$1" "$2" -e "") # 2> /dev/null 1> /dev/null)
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking/mark03b	Wed Dec 21 01:19:25 2016 +0000
@@ -0,0 +1,85 @@
+#!/bin/bash
+set -e
+
+out=${1:-output}
+
+echo "" > $out
+
+echo "Below is the feedback and provisional mark for your submission" >> $out
+echo "for CW 8, Part 2.  Please note all marks are provisional until" >> $out
+echo "ratified by the assessment board -- this is not an official" >> $out
+echo "results transcript." >> $out
+echo "" >> $out
+
+function scala_vars {
+   (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
+}
+
+
+# compilation tests
+
+function scala_compile {
+  (scala "$1" 2> /dev/null 1> /dev/null) 
+}
+
+
+# functional tests
+
+function scala_assert {
+  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+}
+
+
+# marks for CW
+marks=$(( 0 ))
+
+
+# var, return, ListBuffer test
+#
+echo "re2.scala does not contain vars, returns etc?" | tee -a $out
+
+if (scala_vars re.scala)
+then
+  echo "  --> fail" | tee -a $out
+  tsts0=$(( 1 ))
+else
+  echo "  --> yes" | tee -a $out
+  tsts0=$(( 0 )) 
+fi
+
+
+# compilation test
+if  [ $tsts0 -eq 0 ]
+then    
+  echo "re2.scala runs?" | tee -a $out
+
+  if (scala_compile re2.scala)
+  then
+    echo "  --> yes" | tee -a $out
+    tsts1=$(( 0 ))
+  else
+    echo "  --> scala re2.scala did not run successfully" | tee -a $out
+    tsts1=$(( 1 )) 
+  fi
+else
+  tsts1=$(( 1 ))     
+fi
+
+#if [ $tsts1 -eq 0 ]
+#then
+#  echo " nullable(ZERO) == false" | tee -a $out
+#  echo " nullable(ONE) == true" | tee -a $out
+#  
+#  if (scala_assert "re.scala.bak" "../../../marking/re1a_test.scala")
+#  then
+#    echo "  --> success" | tee -a $out
+#    marks=$(( marks + 1 ))
+#  else
+#    echo "  --> test failed" | tee -a $out
+#  fi
+#fi
+
+
+## final marks
+echo "Overall mark for CW 8, Part 2" | tee -a $out
+echo "$marks" | tee -a $out
--- a/marking/re1d_test.scala	Tue Dec 20 01:48:09 2016 +0000
+++ b/marking/re1d_test.scala	Wed Dec 21 01:19:25 2016 +0000
@@ -5,20 +5,32 @@
 import scala.language.postfixOps 
 
 
-val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
+val EVIL_urban = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
 
 lazy val f = Future {
-  assert(ders(List.fill(5)('a'), EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b')))
-  assert(ders(List('b'), EVIL) == ONE)
-  assert(ders(List('b','b'), EVIL) == ZERO)
-  assert(matcher(EVIL, "a" * 5 ++ "b") == true)
-  assert(matcher(EVIL, "b") == true)
-  assert(matcher(EVIL, "bb") == false)
+  println("1")
+  assert(ders(List.fill(5)('a'), EVIL_urban) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b')))
+  println("2")
+  assert(ders(List('b'), EVIL_urban) == ONE)
+  println("3")
+  assert(ders(List('b','b'), EVIL_urban) == ZERO)
+  println("4")
+  assert(matcher(EVIL_urban, "a" * 5 ++ "b") == true)
+  println("5")
+  assert(matcher(EVIL_urban, "b") == true)
+  println("6") 
+  assert(matcher(EVIL_urban, "bb") == false)
+  println("7")
   assert(matcher("abc", "abc") == true)
+  println("8")
   assert(matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true)
+  println("9")
   assert(matcher(ONE, "") == true)
+  println("10")
   assert(matcher(ZERO, "") == false)
+  println("11")
   assert(matcher(ONE | CHAR('a'), "") == true)
+  println("12")
   assert(matcher(ONE | CHAR('a'), "a") == true)
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking/test	Wed Dec 21 01:19:25 2016 +0000
@@ -0,0 +1,92 @@
+#!/bin/bash
+set -e
+
+out=${1:-output-test}
+
+
+function scala_vars {
+   (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
+}
+
+
+# compilation tests
+
+function scala_compile {
+  (scala "$1" 2> /dev/null 1> /dev/null) 
+}
+
+
+# functional tests
+
+function scala_assert {
+  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+}
+
+
+
+# var, return, ListBuffer test
+#
+#echo "re.scala does not contain vars, returns etc?" | tee -a $out
+
+if (scala_vars re.scala)
+then
+  #echo "  --> fail" | tee -a $out
+  tsts0=$(( 1 ))
+else
+  #echo "  --> yes" | tee -a $out
+  tsts0=$(( 0 )) 
+fi
+
+
+# compilation test
+if  [ $tsts0 -eq 0 ]
+then    
+  #echo "re.scala runs?" | tee -a $out
+
+  if (scala_compile re.scala.bak)
+  then
+    #echo "  --> yes" | tee -a $out
+    tsts1=$(( 0 ))
+  else
+    #echo "  --> scala re.scala did not run successfully" | tee -a $out
+    tsts1=$(( 1 )) 
+  fi
+else
+  tsts1=$(( 1 ))     
+fi
+
+
+if [ $tsts1 -eq 0 ]
+then
+  if (scala_assert "re.scala.bak" "../../../marking/re1d_test.scala")
+  then
+    echo "  --> success" | tee -a $out
+    t1=$(( 1 ))
+  else
+    echo "  --> test failed" | tee -a $out
+    t1=$(( 0 ))   
+  fi
+else  
+  t1=$(( 0 ))
+fi
+
+if [ $tsts1 -eq 0 ]
+then
+  if (scala_assert "re.scala.bak" "../../../marking/re1d_bug_test.scala")
+  then
+    echo "  bug --> success" | tee -a $out
+    t2=$(( 1 ))
+  else
+    echo "  bug --> test failed" | tee -a $out
+    t2=$(( 0 ))  
+  fi
+else  
+  t2=$(( 0 ))
+fi
+
+if [ $t1 -ne $t2 ]
+then
+  echo "disagree"
+  pwd
+fi
+