Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
cayhorstmann committed Jan 9, 2021
1 parent a63904d commit ae9b036
Show file tree
Hide file tree
Showing 10 changed files with 414 additions and 19 deletions.
5 changes: 3 additions & 2 deletions checker/comprog
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case _"$LANG" in
;;

_Cpp)
g++ -std=c++11 -g -o prog $@
g++ -std=c++17 -Wall -Wno-sign-compare -g -o prog $@
;;

_Scala)
Expand Down Expand Up @@ -53,6 +53,7 @@ case _"$LANG" in
;;

_)
echo Unknown language $LANG
echo Unknown language $LANG
exit 1
;;
esac
7 changes: 5 additions & 2 deletions checker/src/com/horstmann/codecheck/Comparison.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public class Comparison {
private static final int MANY_MORE_LINES = 10;
// If actual lines > expected + MANY_MORE_LINES, truncate actual output

public boolean execute(String actual, String expected, Report report, String filename) throws IOException {
public boolean execute(String input, String actual, String expected, Report report, String filename) throws IOException {
// TODO: This is where the newlines went to die

List<String> lines1 = getLines(actual.replace("〉\n", "〉"));
List<String> lines2 = getLines(expected.replace("〉\n", "〉"));

Expand All @@ -36,6 +38,8 @@ public boolean execute(String actual, String expected, Report report, String fil
}
}
else {
// Print inputs which are getting replaced
report.input(input);
while (i < lines2.size()) {
Report.Match m = new Report.Match();
m.actual = "";
Expand All @@ -62,7 +66,6 @@ public boolean execute(String actual, String expected, Report report, String fil
m.explanation = null;
matches.add(m);
}
// TODO: Report needs to deal with 〈...〉 (replace with <b>...</b>\n)
report.compareTokens(filename, matches);
}
return outcome;
Expand Down
3 changes: 2 additions & 1 deletion checker/src/com/horstmann/codecheck/CppLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public List<Path> writeTester(Path solutionDir, Path workDir, Path file,
lines.add(i++, extern); // extern function from solution
}
lines.add(i++, "}");
lines.add(i++, "main(int argc, char *argv[]) {");
lines.add(i++, "int main(int argc, char *argv[]) {");
// We declare the student functions locally in main so that they don't conflict with
// solution functions
for (String extern : externs) {
Expand All @@ -94,6 +94,7 @@ public List<Path> writeTester(Path solutionDir, Path workDir, Path file,
// compare expected and actual
lines.add(i++, "}");
}
lines.add(i++, " return 0;");
lines.add(i++, "}");
lines.add(i++, "namespace solution {");
lines.add("}");
Expand Down
4 changes: 2 additions & 2 deletions checker/src/com/horstmann/codecheck/HTMLReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ public HTMLReport pass(boolean b) {
@Override
public HTMLReport compareTokens(String filename, List<Match> matchData) {
caption(filename);
tableStart("output").rowStart().headerCell("Actual output")
.headerCell("Expected output").rowEnd().rowStart();
tableStart("output").rowStart().headerCell("Actual")
.headerCell("Expected").rowEnd().rowStart();
builder.append("<td>");
builder.append("<pre>");
for (Match m : matchData) {
Expand Down
2 changes: 0 additions & 2 deletions checker/src/com/horstmann/codecheck/JavaScriptLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
Expand Down
4 changes: 2 additions & 2 deletions checker/src/com/horstmann/codecheck/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private void testInput(Path mainFile,
// Report output but don't grade it
report.output(outerr);
} else {
boolean outcome = comp.execute(outerr, expectedOuterr, report, null);
boolean outcome = comp.execute(input, outerr, expectedOuterr, report, null);
score.pass(outcome, report);
}
}
Expand All @@ -304,7 +304,7 @@ private void testInput(Path mainFile,
score.pass(outcome, report);
} else {
String expectedContents = Util.read(p);
boolean outcome = comp.execute(contents.remove(0),
boolean outcome = comp.execute(input, contents.remove(0),
expectedContents, report, f);
score.pass(outcome, report);
}
Expand Down
2 changes: 0 additions & 2 deletions checker/src/com/horstmann/codecheck/PythonLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.horstmann.codecheck.Language.Interleave;

public class PythonLanguage implements Language {

public PythonLanguage() {
Expand Down
1 change: 0 additions & 1 deletion checker/src/com/horstmann/codecheck/SMLLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down
4 changes: 2 additions & 2 deletions checker/src/com/horstmann/codecheck/codecheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace codecheck {
template<typename T> void print(std::vector<T> xs) {
std::cout << "{";
for (int i = 0; i < xs.size(); i++) {
if (i > 0) std::cout << ","; std::cout << " ";
if (i > 0) { std::cout << ","; } std::cout << " ";
print(xs[i]);
}
std::cout << " }";
Expand All @@ -43,4 +43,4 @@ namespace codecheck {
print(y); std::cout << std::endl;
std::cout << std::boolalpha << eq(x, y) << std::endl;
}
}
}
Loading

0 comments on commit ae9b036

Please sign in to comment.