--- a/testing4/re_test.sh Wed Nov 28 23:26:47 2018 +0000
+++ b/testing4/re_test.sh Thu Nov 29 17:15:11 2018 +0000
@@ -1,24 +1,26 @@
#!/bin/bash
-set -e
+set -euo pipefail
+
out=${1:-output}
-echo "" > $out
+echo -e "" > $out
-echo "Below is the feedback for your submission of CW 8, Part 1." >> $out
-echo "" >> $out
+echo -e "Below is the feedback for your submission of CW 9, Part 1." >> $out
+echo -e "" >> $out
# 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 30 -m 1024000 ; 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)
+
}
# purity test
@@ -30,53 +32,54 @@
# var, return, ListBuffer test
#
-echo "re.scala does not contain vars, returns etc?" >> $out
+echo -e "re.scala does not contain vars, returns etc?" >> $out
if (scala_vars re.scala)
then
- echo " --> fail" >> $out
- tsts0=$(( 1 ))
+ echo -e " --> fail (make triple-sure your program conforms to the required format)" >> $out
+ tsts0=$(( 0 ))
else
- echo " --> yes" >> $out
+ echo -e " --> success" >> $out
tsts0=$(( 0 ))
fi
# compilation test
+
if [ $tsts0 -eq 0 ]
then
- echo "re.scala runs?" >> $out
+ echo -e "re.scala runs?" >> $out
if (scala_compile re.scala)
then
- echo " --> yes" >> $out
+ echo -e " --> yes" >> $out
tsts1=$(( 0 ))
else
- echo " --> scala re.scala did not run successfully" >> $out
+ echo -e " --> SCALA DID NOT RUN RE.SCALA\n" >> $out
tsts1=$(( 1 ))
fi
else
tsts1=$(( 1 ))
fi
-
+### re tests
if [ $tsts1 -eq 0 ]
then
- echo " nullable(ZERO) == false" >> $out
- echo " nullable(ONE) == true" >> $out
- echo " nullable(CHAR('a')) == false" >> $out
- echo " nullable(ZERO | ONE) == true" >> $out
- echo " nullable(ZERO | CHAR('a')) == false" >> $out
- echo " nullable(ONE ~ ONE) == true" >> $out
- echo " nullable(ONE ~ CHAR('a')) == false" >> $out
- echo " nullable(STAR(ZERO)) == true" >> $out
+ echo -e " nullable(ZERO) == false" >> $out
+ echo -e " nullable(ONE) == true" >> $out
+ echo -e " nullable(CHAR('a')) == false" >> $out
+ echo -e " nullable(ZERO | ONE) == true" >> $out
+ echo -e " nullable(ZERO | CHAR('a')) == false" >> $out
+ echo -e " nullable(ONE ~ ONE) == true" >> $out
+ echo -e " nullable(ONE ~ CHAR('a')) == false" >> $out
+ echo -e " nullable(STAR(ZERO)) == true" >> $out
- if (scala_assert "re.scala" "re1a_test.scala")
+ if (scala_assert "re.scala" "re_test1.scala")
then
- echo " --> success" >> $out
+ echo -e " --> success" >> $out
else
- echo " --> test failed" >> $out
+ echo -e " --> \n ONE TEST FAILED\n" >> $out
fi
fi
@@ -84,16 +87,17 @@
if [ $tsts1 -eq 0 ]
then
- echo " der('a', ZERO | ONE) == (ZERO | ZERO)" >> $out
- echo " der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)" >> $out
- echo " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" >> $out
- echo " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" >> $out
+ echo -e " der('a', ZERO | ONE) == (ZERO | ZERO)" >> $out
+ echo -e " der('a', (CHAR('a') | ONE) ~ CHAR('a')) ==" >> $out
+ echo -e " ALT((ONE | ZERO) ~ CHAR('a'), ONE)" >> $out
+ echo -e " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" >> $out
+ echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" >> $out
- if (scala_assert "re.scala" "re1b_test.scala")
+ if (scala_assert "re.scala" "re_test2.scala")
then
- echo " --> success" >> $out
+ echo -e " --> success" >> $out
else
- echo " --> test failed" >> $out
+ echo -e " --> \n ONE TEST FAILED\n" >> $out
fi
fi
@@ -101,61 +105,61 @@
if [ $tsts1 -eq 0 ]
then
- echo " simp(ZERO | ONE) == ONE" >> $out
- echo " simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)" >> $out
- echo " simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')" >> $out
- echo " simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO" >> $out
- echo " simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')" >> $out
- echo " simp(CHAR('a') | CHAR('a')) == CHAR('a')" >> $out
- echo " simp(ONE | CHAR('a')) == (ONE | CHAR('a'))" >> $out
- echo " simp(ALT((CHAR('a') | ZERO) ~ ONE," >> $out
- echo " ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" >> $out
- if (scala_assert "re.scala" "re1c_test.scala")
+ echo -e " simp(ZERO | ONE) == ONE" >> $out
+ echo -e " simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)" >> $out
+ echo -e " simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')" >> $out
+ echo -e " simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO" >> $out
+ echo -e " simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')" >> $out
+ echo -e " simp(CHAR('a') | CHAR('a')) == CHAR('a')" >> $out
+ echo -e " simp(ONE | CHAR('a')) == (ONE | CHAR('a'))" >> $out
+ echo -e " simp(ALT((CHAR('a') | ZERO) ~ ONE," >> $out
+ echo -e " ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" >> $out
+ if (scala_assert "re.scala" "re_test3.scala")
then
- echo " --> success" >> $out
+ echo -e " --> success" >> $out
else
- echo " --> test failed" >> $out
+ echo -e " --> \n ONE TEST FAILED\n" >> $out
fi
fi
if [ $tsts1 -eq 0 ]
then
- echo " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" >> $out
- echo " ders(List.fill(5)('a'),EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))" >> $out
- echo " ders(List('b'),EVIL) == ONE" >> $out
- echo " ders(List('b','b'),EVIL) == ZERO" >> $out
- echo " matcher(EVIL, \"a\" * 5 ++ \"b\") == true" >> $out
- echo " matcher(EVIL, \"b\") == true" >> $out
- echo " matcher(EVIL, \"bb\") == false" >> $out
- echo " matcher(\"abc\", \"abc\") == true" >> $out
- echo " matcher((\"ab\" | \"a\") ~ (ONE | \"bc\"), \"abc\") == true" >> $out
- echo " matcher(ONE, \"\") == true" >> $out
- echo " matcher(ZERO, \"\") == false" >> $out
- echo " matcher(ONE | CHAR('a'), \"\") == true" >> $out
- echo " matcher(ONE | CHAR('a'), \"a\") == true" >> $out
+ echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" >> $out
+ echo -e " ders(\"aaaaa\".toList, EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))" >> $out
+ echo -e " ders(List('b'), EVIL) == ONE" >> $out
+ echo -e " ders(\"bb\".toList, EVIL) == ZERO" >> $out
+ echo -e " matcher(EVIL, \"a\" * 5 ++ \"b\") == true" >> $out
+ echo -e " matcher(EVIL, \"b\") == true" >> $out
+ echo -e " matcher(EVIL, \"bb\") == false" >> $out
+ echo -e " matcher(\"abc\", \"abc\") == true" >> $out
+ echo -e " matcher((\"ab\" | \"a\") ~ (ONE | \"bc\"), \"abc\") == true" >> $out
+ echo -e " matcher(ONE, \"\") == true" >> $out
+ echo -e " matcher(ZERO, \"\") == false" >> $out
+ echo -e " matcher(ONE | CHAR('a'), \"\") == true" >> $out
+ echo -e " matcher(ONE | CHAR('a'), \"a\") == true" >> $out
- if (scala_assert "re.scala" "re1d_test.scala")
+ if (scala_assert "re.scala" "re_test4.scala")
then
- echo " --> success" >> $out
+ echo -e " --> success" >> $out
else
- echo " --> test failed" >> $out
+ echo -e " --> \n ONE TEST FAILED\n" >> $out
fi
fi
if [ $tsts1 -eq 0 ]
then
- echo " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" >> $out
- echo " size(der('a', der('a', EVIL))) == 28" >> $out
- echo " size(der('a', der('a', der('a', EVIL)))) == 58" >> $out
- echo " size(ders(\"aaaaaa\".toList, EVIL)) == 8" >> $out
+ echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" >> $out
+ echo -e " size(der('a', der('a', EVIL))) == 28" >> $out
+ echo -e " size(der('a', der('a', der('a', EVIL)))) == 58" >> $out
+ echo -e " size(ders(\"aaaaaa\".toList, EVIL)) == 8" >> $out
- if (scala_assert "re.scala" "re1e_test.scala")
+ if (scala_assert "re.scala" "re_test5.scala")
then
- echo " --> success" >> $out
+ echo -e " --> success" >> $out
else
- echo " --> test failed" >> $out
+ echo -e " --> \n ONE TEST FAILED\n" >> $out
fi
fi