equal
deleted
inserted
replaced
1 #!/bin/bash |
1 #!/bin/bash |
2 set -euo pipefail |
2 set -euo pipefail |
3 |
3 |
4 out=${1:-output} |
4 |
|
5 scalafile=${1:-bf.scala} |
|
6 out=${2:-output} |
5 |
7 |
6 echo -e "" > $out |
8 echo -e "" > $out |
7 |
9 |
8 echo -e "Below is the feedback for your submission of bf.scala." >> $out |
10 echo -e "Below is the feedback for your submission of bf.scala." >> $out |
9 echo -e "" >> $out |
11 echo -e "" >> $out |
30 |
32 |
31 |
33 |
32 # compilation test |
34 # compilation test |
33 echo -e "bf.scala runs?" >> $out |
35 echo -e "bf.scala runs?" >> $out |
34 |
36 |
35 if (scala_compile bf.scala) |
37 if (scala_compile $scalafile) |
36 then |
38 then |
37 echo -e " --> passed" >> $out |
39 echo -e " --> passed" >> $out |
38 tsts1=$(( 0 )) |
40 tsts1=$(( 0 )) |
39 else |
41 else |
40 echo -e " --> SCALA DID NOT RUN BF.SCALA\n" >> $out |
42 echo -e " --> SCALA DID NOT RUN BF.SCALA\n" >> $out |
47 |
49 |
48 if [ $tsts1 -eq 0 ] |
50 if [ $tsts1 -eq 0 ] |
49 then |
51 then |
50 echo -e "bf.scala does not contain vars, returns etc?" >> $out |
52 echo -e "bf.scala does not contain vars, returns etc?" >> $out |
51 |
53 |
52 if (scala_vars bf.scala) |
54 if (scala_vars $scalafile) |
53 then |
55 then |
54 echo -e " --> FAIL (make triple-sure your program conforms to the required format)" >> $out |
56 echo -e " --> FAIL (make triple-sure your program conforms to the required format)" >> $out |
55 tsts1=$(( 1 )) |
57 tsts1=$(( 1 )) |
56 else |
58 else |
57 echo -e " --> passed" >> $out |
59 echo -e " --> passed" >> $out |
66 if [ $tsts1 -eq 0 ] |
68 if [ $tsts1 -eq 0 ] |
67 then |
69 then |
68 echo -e " load_bff(\"benchmark.bf\").length == 188" >> $out |
70 echo -e " load_bff(\"benchmark.bf\").length == 188" >> $out |
69 echo -e " load_bff(\"foobar.bf\") == \"\"" >> $out |
71 echo -e " load_bff(\"foobar.bf\") == \"\"" >> $out |
70 |
72 |
71 if (scala_assert "bf.scala" "bf_test1.scala") |
73 if (scala_assert $scalafile "bf_test1.scala") |
72 then |
74 then |
73 echo -e " --> success" >> $out |
75 echo -e " --> success" >> $out |
74 else |
76 else |
75 echo -e " --> \n ONE TEST FAILED\n" >> $out |
77 echo -e " --> \n ONE TEST FAILED\n" >> $out |
76 fi |
78 fi |
81 echo -e " sread(Map(), 2) == 0" >> $out |
83 echo -e " sread(Map(), 2) == 0" >> $out |
82 echo -e " sread(Map(2 -> 1), 2) == 1" >> $out |
84 echo -e " sread(Map(2 -> 1), 2) == 1" >> $out |
83 echo -e " write(Map(), 1, 2) == Map(1 -> 2)" >> $out |
85 echo -e " write(Map(), 1, 2) == Map(1 -> 2)" >> $out |
84 echo -e " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" >> $out |
86 echo -e " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" >> $out |
85 |
87 |
86 if (scala_assert "bf.scala" "bf_test2.scala") |
88 if (scala_assert $scalafile "bf_test2.scala") |
87 then |
89 then |
88 echo -e " --> success" >> $out |
90 echo -e " --> success" >> $out |
89 else |
91 else |
90 echo -e " --> \n ONE TEST FAILED\n" >> $out |
92 echo -e " --> \n ONE TEST FAILED\n" >> $out |
91 fi |
93 fi |
102 echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" >> $out |
104 echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" >> $out |
103 echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" >> $out |
105 echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" >> $out |
104 echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" >> $out |
106 echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" >> $out |
105 echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" >> $out |
107 echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" >> $out |
106 |
108 |
107 if (scala_assert "bf.scala" "bf_test3.scala") |
109 if (scala_assert $scalafile "bf_test3.scala") |
108 then |
110 then |
109 echo -e " --> success" >> $out |
111 echo -e " --> success" >> $out |
110 else |
112 else |
111 echo -e " --> \n ONE TEST FAILED\n" >> $out |
113 echo -e " --> \n ONE TEST FAILED\n" >> $out |
112 fi |
114 fi |
121 echo -e " run(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" >> $out |
123 echo -e " run(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" >> $out |
122 |
124 |
123 echo -e " run(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" >> $out |
125 echo -e " run(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" >> $out |
124 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" >> $out |
126 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" >> $out |
125 |
127 |
126 if (scala_assert "bf.scala" "bf_test4.scala") |
128 if (scala_assert $scalafile "bf_test4.scala") |
127 then |
129 then |
128 echo -e " --> success" >> $out |
130 echo -e " --> success" >> $out |
129 else |
131 else |
130 echo -e " --> \n ONE TEST FAILED\n" >> $out |
132 echo -e " --> \n ONE TEST FAILED\n" >> $out |
131 fi |
133 fi |