diff -r ac79c2e534bd -r b528d1d3d3c3 core_testing3/postfix_test.sh --- a/core_testing3/postfix_test.sh Thu Nov 02 12:37:58 2023 +0000 +++ b/core_testing3/postfix_test.sh Thu Nov 02 13:53:37 2023 +0000 @@ -9,26 +9,26 @@ echo -e "Below is the feedback for your submission postfix.scala and postfix2.scala" >> $out echo -e "" >> $out + # compilation tests function scala_compile { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out) + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala-cli compile "$1" 2> c$out 1> c$out) } # functional tests function scala_assert { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala-cli -i "$1" "$2" -e "urbanmain()" 2> /dev/null 1> /dev/null) } # purity test - function scala_vars { - (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null) + (sed 's/immutable/ok/g' c$out > cb$out; + egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null) } - # compilation test echo -e "postfix.scala runs?" >> $out @@ -38,7 +38,8 @@ echo -e " --> passed" >> $out tsts=$(( 0 )) else - echo -e " --> SCALA DID NOT RUN postfix.scala\n" >> $out + echo -e " --> SCALA DID NOT RUN postfix.scala\n" >> $out + echo -e " --> try running scala-cli compile postfix.scala on your own computer\n" >> $out tsts=$(( 1 )) fi @@ -69,7 +70,7 @@ echo -e " syard(split(\"5 + 7 / 2\")) == List(\"5\", \"7\", \"2\", \"/\", \"+\")" >> $out echo -e " syard(split(\"5 * 7 / 2\")) == List(\"5\", \"7\", \"\*\", \"2\", \"/\")" >> $out - if (scala_assert "postfix.scala" "postfix_test7.scala") + if (scala_assert "postfix.scala" "postfix_test1.scala") then echo -e " --> success" >> $out else @@ -88,7 +89,7 @@ echo -e " compute(syard(split(\"5 * 7 / 2\"))) == 17" >> $out echo -e " compute(syard(split(\"9 + 24 / ( 7 - 3 )\"))) == 15" >> $out - if (scala_assert "postfix.scala" "postfix_test8.scala") + if (scala_assert "postfix.scala" "postfix_test2.scala") then echo -e " --> success" >> $out else @@ -111,6 +112,7 @@ tsts1=$(( 0 )) else echo -e " --> SCALA DID NOT RUN postfix2.scala\n" >> $out + echo -e " --> try running scala-cli compile postfix2.scala on your own computer\n" >> $out tsts1=$(( 1 )) fi @@ -152,7 +154,7 @@ echo -e " compute(syard(split(\"( 4 ^ 3 ) ^ 2\"))) == 4096" >> $out echo -e " compute(syard(split(\"( 3 + 1 ) ^ 2 ^ 3\"))) == 65536" >> $out - if (scala_assert "postfix2.scala" "postfix_test9.scala") + if (scala_assert "postfix2.scala" "postfix_test3.scala") then echo -e " --> success" >> $out else