exercism / csharp

Exercism exercises in C#.
https://exercism.org/tracks/csharp
MIT License
349 stars 349 forks source link

sgf-parsing: handling line breaks to spec #557

Closed cmccandless closed 6 years ago

cmccandless commented 6 years ago

As the Python implementation of this exercise was based on the C# implementation, I thought I'd raise this here as well (since there is currently no canonical data for sgf-parsing).

From @paiv in exercism/python#1376

https://github.com/exercism/python/blob/8f456d7fb7df9228470558737d23497515255378/exercises/sgf-parsing/sgf_parsing_test.py#L76

According to spec at https://www.red-bean.com/sgf/sgf4.html#text

3.2. Text Text is a formatted text. White spaces other than linebreaks are converted to space (e.g. no tab, vertical tab, ..). Formatting:

  • Soft line break: linebreaks preceded by a "\" (soft linebreaks are converted to "", i.e. they are removed)
  • Hard line breaks: any other linebreaks encountered

... this test has hard line breaks that should be preserved, i.e.

        expected = SgfTree(
            properties={'A': [']b\nc\nd  e \n]']}
        )

To use data relevant to this track, the current test code is https://github.com/exercism/csharp/blob/3ce038d6f9b1ac747a2e94f5500b86f3cded46c5/exercises/sgf-parsing/SgfParsingTest.cs#L114

The proper expected code should be

var expected = TreeWithNoChildren(CreateData("A", @"]b\nc\nd  e \n]"));
ErikSchierboom commented 6 years ago

Thanks for the feedback! We will be fixing this.