ratfactor/ziglings

Comparing output assumes exercise output contains only one line

perillo opened this issue · 1 comments

I'm writing a changeset where, in exercises, the hint and output fields use a multiline string literal to make the code more readable. This only happens when the string has multiple lines or when use the " character.

After this change I realized that the output comparison in ZiglingStep is actually broken, since it assumes that the string only have one line.

This means that the CR character is actually not removed from the exercise output, and since no one complained, it means that trimming CR characters is probably not necessary.

IMHO, there are only two cases where a CR character can be introduced:

  1. The Zig compiler converts \n to \r\n in the source file on Windows.
    This never happens.
    Maybe the patch command for Windows can do it?
  2. A \r character can be added in a multiline string literal, when using a native Windows editor.
    This never happens (see https://ziglang.org/documentation/master/#Source-Encoding).

Maybe the patch command for Windows can do it?

Wouldn't that have been noticed already, either in our automatic test runs or by users with Windows?