Page MenuHomePhabricator

Create test cases
Open, MediumPublic

Description

The code needs test cases. A set of PGN games needs to be compiled which test the various aspects of the PGN standard, especially:

  • Seven tag roster (STR)
    • Input out of order -> export in order
  • Additional tags
    • Always export after STR
    • Always export in alphabetical order
    • Test on input where tags are mixed with STR
  • Comments
    • Handles brace comments
    • Handles rest of line comments
  • Move numbers
    • Input with superfluous move numbers
    • Input with no move numbers
    • Input with multiple spaces between move numbers and symbols
    • Export in proper standard game notation (e.g. 1. e4 e5 2. c3 ...)
  • Symbols
    • Tests all continuation characters ("_", "+", "#", "=", ":", "-", a-zA-Z, 0-9)
  • Variations

Event Timeline

Wugapodes triaged this task as Medium priority.Dec 1 2019, 8:30 AM

Probably helpful to read this man page on writing tests for extensions. The necessary tests will have to cover much more than what is stated in the original task, but those are a good place to start.

I've got tests working for the __construct(), cut(), getChar(), and parseVariation() functions of PgnParser, as well as test for the exceptions they throw.

Change 554214 had a related patch set uploaded (by Wugapodes; owner: Wugapodes):
[mediawiki/extensions/ChessBrowser@master] Unit tests for PgnParser and related bug fixes

https://gerrit.wikimedia.org/r/554214

Change 554364 had a related patch set uploaded (by Wugapodes; owner: Wugapodes):
[integration/config@master] layout: Configure tests for ChessBrowser extension

https://gerrit.wikimedia.org/r/554364

Change 554364 merged by jenkins-bot:
[integration/config@master] layout: Configure tests for ChessBrowser extension

https://gerrit.wikimedia.org/r/554364

Merging of the patch is prevented by T240611 and T240612 which result in build failures. This task is stalled until the source of those build errors is found and fixed.

Change 554214 merged by jenkins-bot:
[mediawiki/extensions/ChessBrowser@master] ChessBrowser: PgnParser and unit tests

https://gerrit.wikimedia.org/r/554214

i would add specific chess cases, to verify correct pgn parsing:

  1. en passant
  2. castling
  3. promotion

WRT castling, if we are to support chess960 (the pure-JS script does. it seems to work but not thoroughly tested), castling is the most meaningful challenge, as initial positions of king and rooks varies.

also add some negative tests, specifically, feed it illegal/corrupted/empty etc. PGN, and expect sane output.

peace.

@Kipod the changes in 563005 implement some minimal tests for those three cases. The code currently only supports castling in standard board set ups, though presumably that can be changed at some point in the future if/when we can support chess960. You can see on line 152 of ChessParser.php that the source and target squares of the rook are hardcoded, but could be generalized to "other side of the king" in order to support non-standard start positions.