--- a/core_testing2/docdiff_test.sh Thu Nov 02 11:32:10 2023 +0000
+++ b/core_testing2/docdiff_test.sh Thu Nov 02 12:37:58 2023 +0000
@@ -11,23 +11,22 @@
echo "Below is the feedback for your submission docdiff.scala" >> $out
echo "" >> $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)
}
@@ -42,6 +41,7 @@
tsts=$(( 0 ))
else
echo -e " --> SCALA DID NOT RUN docdiff.scala\n" >> $out
+ echo -e " --> try running scala-cli compile docdiff.scala on your own computer\n" >> $out
tsts=$(( 1 ))
fi
--- a/core_testing2/docdiff_test1.scala Thu Nov 02 11:32:10 2023 +0000
+++ b/core_testing2/docdiff_test1.scala Thu Nov 02 12:37:58 2023 +0000
@@ -1,6 +1,7 @@
-import C2._
+def urbanmain() = {
+ import C2._
-assert(clean("ab a abc") == List("ab", "a", "abc"))
-
-assert(clean("ab*a abc1") == List("ab", "a", "abc1"))
+ assert(clean("ab a abc") == List("ab", "a", "abc"))
+ assert(clean("ab*a abc1") == List("ab", "a", "abc1"))
+}
--- a/core_testing2/docdiff_test2.scala Thu Nov 02 11:32:10 2023 +0000
+++ b/core_testing2/docdiff_test2.scala Thu Nov 02 12:37:58 2023 +0000
@@ -1,6 +1,7 @@
-import C2._
+def urbanmain() = {
+ import C2._
-assert(occurrences(List("a", "b", "b", "c", "d")) == Map("a" -> 1, "b" -> 2, "c" -> 1, "d" -> 1))
-
-assert(occurrences(List("d", "b", "d", "b", "d")) == Map("d" -> 3, "b" -> 2))
+ assert(occurrences(List("a", "b", "b", "c", "d")) == Map("a" -> 1, "b" -> 2, "c" -> 1, "d" -> 1))
+ assert(occurrences(List("d", "b", "d", "b", "d")) == Map("d" -> 3, "b" -> 2))
+}
--- a/core_testing2/docdiff_test3.scala Thu Nov 02 11:32:10 2023 +0000
+++ b/core_testing2/docdiff_test3.scala Thu Nov 02 12:37:58 2023 +0000
@@ -1,11 +1,11 @@
-import C2._
-
-val urban_list1 = List("a", "b", "b", "c", "d")
-val urban_list2 = List("d", "b", "d", "b", "d")
+def urbanmain() = {
+ import C2._
-assert(prod(urban_list1, urban_list2) == 7)
+ val urban_list1 = List("a", "b", "b", "c", "d")
+ val urban_list2 = List("d", "b", "d", "b", "d")
-assert(prod(urban_list1, urban_list1) == 7)
-
-assert(prod(urban_list2, urban_list2) == 13)
+ assert(prod(urban_list1, urban_list2) == 7)
+ assert(prod(urban_list1, urban_list1) == 7)
+ assert(prod(urban_list2, urban_list2) == 13)
+}
--- a/core_testing2/docdiff_test4.scala Thu Nov 02 11:32:10 2023 +0000
+++ b/core_testing2/docdiff_test4.scala Thu Nov 02 12:37:58 2023 +0000
@@ -1,11 +1,12 @@
-import C2._
-val urban_list1 = List("a", "b", "b", "c", "d")
-val urban_list2 = List("d", "b", "d", "b", "d")
+def urbanmain() = {
+ import C2._
-assert(overlap(urban_list1, urban_list2) == 0.5384615384615384)
+ val urban_list1 = List("a", "b", "b", "c", "d")
+ val urban_list2 = List("d", "b", "d", "b", "d")
-assert(overlap(urban_list1, urban_list1) == 1.0)
-
-assert(overlap(urban_list2, urban_list2) == 1.0)
+ assert(overlap(urban_list1, urban_list2) == 0.5384615384615384)
+ assert(overlap(urban_list1, urban_list1) == 1.0)
+ assert(overlap(urban_list2, urban_list2) == 1.0)
+}