--- a/testing2/knight1_test.sh Tue Nov 21 16:31:11 2017 +0000
+++ b/testing2/knight1_test.sh Thu Nov 23 10:56:47 2017 +0000
@@ -12,19 +12,27 @@
# compilation tests
function scala_compile {
- (ulimit -t 30 -m 1024000 ; scala "$1" 2>> $out 1>> $out)
+ (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out)
}
# functional tests
-function scala_assert {
- (ulimit -t 300 -m 1024000 ; scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+function scala_assert_slow {
+ (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+}
+
+function scala_assert_thirty {
+ (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+}
+
+function scala_assert_quick {
+ (ulimit -t 10; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
}
# purity test
function scala_vars {
- (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
+ (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
}
@@ -34,7 +42,7 @@
if (scala_vars knight1.scala)
then
- echo " --> fail" >> $out
+ echo " --> fail: if you do not fix this, you will receive a mark of zero" >> $out
tsts0=$(( 1 ))
else
echo " --> success" >> $out
@@ -64,11 +72,12 @@
if [ $tsts1 -eq 0 ]
then
- echo " is_legal(8, Nil) (3, 4) == true " >> $out
- echo " is_legal(8, List((4, 1), (1, 0))) (4, 1) == false " >> $out
- echo " is_legal(2, Nil) (0, 0) == true" >> $out
+ echo "Takes 10 seconds or less to execute: " >> $out
+ echo " is_legal(8, Nil)(3, 4) == true " >> $out
+ echo " is_legal(8, List((4, 1), (1, 0)))(4, 1) == false " >> $out
+ echo " is_legal(2, Nil)(0, 0) == true" >> $out
- if (scala_assert "knight1.scala" "knight1a_test.scala")
+ if (scala_assert_quick "knight1.scala" "knight1a_test.scala")
then
echo " --> success" >> $out
else
@@ -80,6 +89,7 @@
if [ $tsts1 -eq 0 ]
then
+ echo "Takes 10 seconds or less to execute: " >> $out
echo " legal_moves(8, Nil, (2,2)) == List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))" >> $out
echo " legal_moves(8, Nil, (7,7)) == List((6,5), (5,6))" >> $out
echo " legal_moves(8, List((4,1), (1,0)), (2,2)) == List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4))" >> $out
@@ -88,7 +98,7 @@
echo " legal_moves(2, Nil, (0,0)) == Nil" >> $out
echo " legal_moves(3, Nil, (0,0)) == List((1,2), (2,1))" >> $out
- if (scala_assert "knight1.scala" "knight1b_test.scala")
+ if (scala_assert_quick "knight1.scala" "knight1b_test.scala")
then
echo " --> success" >> $out
else
@@ -101,7 +111,7 @@
if [ $tsts1 -eq 0 ]
then
- echo " all_tours from every position on the board" >> $out
+ echo " all_tours from every position on the board, in 2 minutes or less" >> $out
echo " dim = 1: 1" >> $out
echo " 2: 0,0,0,0" >> $out
echo " 3: 0,0,0,0,0,0,0,0,0" >> $out
@@ -109,7 +119,7 @@
echo " 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56,0,56,0,56,0,304,0,56,0,304" >> $out
echo " enum_tours(5, List((0,2)) ) == 56 and all correct?" >> $out
- if (scala_assert "knight1.scala" "knight1c_test.scala")
+ if (scala_assert_slow "knight1.scala" "knight1c_test.scala")
then
echo " --> success" >> $out
else
@@ -153,11 +163,12 @@
if [ $tsts1 -eq 0 ]
then
+ echo "Takes 10 seconds or less to execute: " >> $out
echo " Let f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " >> $out
echo " first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" >> $out
echo " first(List((1,0),(2,0),(3,0)), f) == None" >> $out
- if (scala_assert "knight2.scala" "knight2a_test.scala")
+ if (scala_assert_quick "knight2.scala" "knight2a_test.scala")
then
echo " --> success" >> $out
else
@@ -170,10 +181,11 @@
if [ $tsts1 -eq 0 ]
then
+ echo "Takes 30 seconds or less to execute: " >> $out
echo " is first_tour(8, List((0, 0))) ok? " >> $out
echo " is first_tour(4, List((0, 0))) == None " >> $out
- if (scala_assert "knight2.scala" "knight2b_test.scala")
+ if (scala_assert_thirty "knight2.scala" "knight2b_test.scala")
then
echo " --> success" >> $out
else