Skip to content

Empty new lines cause unhelpful/untrue diff in Mario in v4.0.0 #379

@ivanharvard

Description

@ivanharvard

Printing any arbitrary amount of new lines at the end of the staff solution for Mario causes this error message:

:) mario.c exists
:) mario.c compiles
:) rejects a height of -1
:) rejects a height of 0
:( handles a height of 1 correctly
    expected: "#  #"
    actual:   "#  #"
    did you add too much trailing whitespace to the end of your pyramid?
:( handles a height of 2 correctly
    expected: "...#  ##"
    actual:   "...#  ##"
    did you add too much trailing whitespace to the end of your pyramid?
:( handles a height of 8 correctly
    expected: "...#####"
    actual:   "...#####"
    did you add too much trailing whitespace to the end of your pyramid?
:( rejects a height of -1, and then accepts a height of 2
    expected: "...#  ##"
    actual:   "...#  ##"
    did you add too much trailing whitespace to the end of your pyramid?
:) rejects a non-numeric height of "foo" 
:) rejects a non-numeric height of "" 

This is probably because of this line under check_pyramids() in problems/mario/less/__init__.py:

    output = [line for line in output.splitlines() if line != ""]

which removes all empty lines, including new lines, from the user's output, thus causing the diff to show equivalent expected and actual answers.

Metadata

Metadata

Assignees

Labels

CS50xCS50xbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions