diff -r 34feeb53c0ba -r 0315d9983cd0 main_marking4/knight_test.sh --- a/main_marking4/knight_test.sh Sun Jan 15 10:58:13 2023 +0000 +++ b/main_marking4/knight_test.sh Sat Mar 11 22:01:53 2023 +0000 @@ -41,19 +41,19 @@ } function scala_assert_thirty { - (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) + (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) } function scala_assert_quick { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) } function scala_assert_long { - (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) + (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) } function scala_assert_elong { - (ulimit -t 90; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) + (ulimit -t 90; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) } # purity test @@ -107,7 +107,7 @@ if (scala_assert "knight1.scala" "knight1_test1.scala") then - echo -e " --> success" | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1.0 )) else echo -e " --> \n ONE TEST FAILED\n"| tee -a $out @@ -129,7 +129,7 @@ if (scala_assert "knight1.scala" "knight1_test2.scala") then - echo -e " --> success\n" | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1 )) else echo -e " --> ONE TEST FAILED\n" | tee -a $out @@ -141,19 +141,19 @@ if [ $tsts -eq 0 ] then - echo " count_tours from every position on the board 1 - 4 (0.5% marks)" | tee -a $out + echo " count_tours from every position on the board 1 - 4" | tee -a $out echo " dim = 1: 1" | tee -a $out echo " 2: 0,0,0,0" | tee -a $out echo " 3: 0,0,0,0,0,0,0,0,0" | tee -a $out echo " 4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out START=$(date +%s) - if (scala_assert_thirty "knight1.scala" "knight1_test3a.scala") + if (scala_assert "knight1.scala" "knight1_test3a.scala") then END=$(date +%s) DIFF=$(( $END - $START )) #echo " This test ran for $DIFF seconds." | tee -a $out - echo -e " --> success\n" | tee -a $out + echo -e " --> success (+ 0.5 Marks)\n" | tee -a $out marks=$(( marks + 0.5 )) else END=$(date +%s) @@ -167,16 +167,16 @@ if [ $tsts -eq 0 ] then - echo " count_tours from every position on the board of dim 5 for the first 3 rows (0.25% marks)" | tee -a $out + echo " count_tours from every position on the board of dim 5 for the first 3 rows" | tee -a $out echo " dim = 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56)" | tee -a $out START=$(date +%s) - if (scala_assert_thirty "knight1.scala" "knight1_test3b.scala") + if (scala_assert "knight1.scala" "knight1_test3b.scala") then END=$(date +%s) DIFF=$(( $END - $START )) #echo " This test ran for $DIFF seconds." | tee -a $out - echo -e " --> success\n" | tee -a $out + echo -e " --> success (+ 0.25 Marks)\\n" | tee -a $out marks=$(( marks + 0.25 )) else END=$(date +%s) @@ -192,7 +192,7 @@ then echo " enum_tours(5, List((0,2)) ) => 56 tours? and all correct?" | tee -a $out echo " enum_tours(5, List((0,0)) ) => 304 tours? and all correct?" | tee -a $out - echo " (0.25% marks) " | tee -a $out + #echo " (0.25% marks) " | tee -a $out START=$(date +%s) if (scala_assert_thirty "knight1.scala" "knight1_test3c.scala") @@ -200,7 +200,7 @@ END=$(date +%s) DIFF=$(( $END - $START )) #echo " This test ran for $DIFF seconds." | tee -a $out - echo -e " --> success\n" | tee -a $out + echo -e " --> success (+ 0.25 Marks)\n" | tee -a $out marks=$(( marks + 0.25 )) else END=$(date +%s) @@ -221,7 +221,7 @@ if (scala_assert "knight1.scala" "knight1_test4.scala") then - echo -e " --> success" | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1.0 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out @@ -240,8 +240,8 @@ then END=$(date +%s) DIFF=$(( $END - $START )) - echo -e " This test ran for $DIFF seconds" | tee -a $out - echo -e " --> success" | tee -a $out + #echo -e " This test ran for $DIFF seconds" | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1.0 )) else END=$(date +%s) @@ -300,7 +300,7 @@ if (scala_assert "knight2.scala" "knight2_test6.scala") then - echo -e " --> success" | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1.0 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out @@ -319,8 +319,8 @@ then END=$(date +%s) DIFF=$(( $END - $START )) - echo -e " This test ran for $DIFF seconds" | tee -a $out - echo -e " --> success" | tee -a $out + #echo -e " This test ran for $DIFF seconds" | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1.0 )) else END=$(date +%s) @@ -343,8 +343,8 @@ then END=$(date +%s) DIFF=$(( $END - $START )) - echo " This test ran for $DIFF seconds" | tee -a $out - echo -e " --> success" | tee -a $out + #echo " This test ran for $DIFF seconds" | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1.0 )) else END=$(date +%s) @@ -399,8 +399,8 @@ then END=$(date +%s) DIFF=$(( $END - $START )) - echo -e " This test ran for $DIFF seconds." | tee -a $out - echo -e " --> success" | tee -a $out + #echo -e " This test ran for $DIFF seconds." | tee -a $out + echo -e " --> success (+ 1 Mark)\n" | tee -a $out marks=$(( marks + 1.0 )) else END=$(date +%s) @@ -411,6 +411,62 @@ fi +echo -e "" >> $out +echo -e "Below is the feedback for your submission knight4.scala" >> $out +echo -e "" >> $out + +# compilation test +echo "knight4.scala runs?" | tee -a $out + +if (scala_compile knight4.scala) +then + echo " --> success" | tee -a $out + tsts=$(( 0 )) +else + echo -e " --> SCALA DID NOT RUN knight3.scala\n" | tee -a $out + tsts=$(( 1 )) +fi + + +# knights3: purity test +# +if [ $tsts -eq 0 ] +then + echo -e "knight4.scala does not contain VARS, RETURNS etc?" | tee -a $out + + if (scala_vars knight4.scala) + then + echo " --> TEST FAILED\n" | tee -a $out + tsts=$(( 1 )) + else + echo " --> success" | tee -a $out + tsts=$(( 0 )) + fi +else + tsts=$(( 1 )) +fi + +if [ $tsts -eq 0 ] +then + echo -e " one_tour_pred(8, List((0, 0)), 40, x => x._1 < 5) is ok?" | tee -a $out + START=$(date +%s) + + if (scala_assert "knight4.scala" "knight4_test10.scala") + then + END=$(date +%s) + DIFF=$(( $END - $START )) + #echo -e " This test ran for $DIFF seconds." | tee -a $out + echo -e " --> success (+ 2 Marks)\n" | tee -a $out + marks=$(( marks + 2.0 )) + else + END=$(date +%s) + DIFF=$(( $END - $START )) + echo -e " This test ran for $DIFF seconds." | tee -a $out + echo -e " --> \n ONE TEST FAILED\n" | tee -a $out + fi +fi + + ## final marks echo -e "" >> $out echo -e "Overall mark for Main Part 4 (Scala)" | tee -a $out