Skip to content

Commit

Permalink
fix double/0 test case displayed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LarynQi committed Jan 14, 2021
1 parent f8c9983 commit 6fcd8be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion ok-disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
correct = total = 0
i = 0
cycled = -1
first = True
while tests:
if i == cycled:
break
Expand All @@ -94,11 +95,13 @@
if run[1] == 0 and not args.v:
if cycled == -1:
cycled = i
continue
if not first:
continue
else:
cycled = -1
result, correct, total = result + run[0], correct + run[1], total + run[2]
i = (i + 1) % len(extensions_present)
first = False

result += "---------------------------------------------------------------------\nTest summary\n"
if args.v:
Expand Down
15 changes: 10 additions & 5 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,15 @@ def __init__(self, language, number, test, output=""):
self.output = output

def run(self, actual):
if not actual and not self.output:
return "{!s} {!s}\n{!s}{!s}".format(self.language.prompt, self.test, actual, "") + "-- OK! --\n", True
base = "{!s} {!s}\n{!s}{!s}".format(self.language.prompt, self.test, actual, "" if actual[len(actual) - 1] == "\n" else "\n")
tab = " "
if not actual:
if not self.output:
return "{!s} {!s}\n{!s}{!s}".format(self.language.prompt, self.test, actual, "") + "-- OK! --\n", True
base = "{!s} {!s}\n{!s}{!s}".format(self.language.prompt, self.test, actual, "")
else:
base = "{!s} {!s}\n{!s}{!s}".format(self.language.prompt, self.test, actual, "" if actual[len(actual) - 1] == "\n" else "\n")
if actual.strip() == self.output.strip() or actual == self.output:
return base + "-- OK! --\n", True
tab = " "
spaced_actual = ""
for c in actual:
if c == "\n":
Expand All @@ -134,7 +137,9 @@ def run(self, actual):
spaced_output += c + tab
else:
spaced_output += c
return base + "\nError: expected\n{!s}{!s}\nbut got\n{!s}{!s}\n".format(tab, spaced_output, tab, spaced_actual[:-1] if spaced_actual[len(spaced_actual) - 1] == "\n" else spaced_actual), False
if self.output and actual:
return base + "\nError: expected\n{!s}{!s}\nbut got\n{!s}{!s}\n".format(tab, spaced_output, tab, spaced_actual[:-1] if spaced_actual[len(spaced_actual) - 1] == "\n" else spaced_actual), False
return base + "\nError: expected\n{!s}{!s}\nbut got\n{!s}{!s}\n".format(tab, spaced_output, tab, spaced_actual), False

def __str__(self):
return "Q{!s} - Input: {!s}, Output: {!s}".format(self.number, self.test, self.output)
Expand Down

0 comments on commit 6fcd8be

Please sign in to comment.