Skip to content

Commit

Permalink
Add tests for issue RT #129862
Browse files Browse the repository at this point in the history
* split table tests into current and 'skipped'; add tests for #129862, PR903

* add a note ref future tests

* move toward incorporating Zoffix's comments

* add plan back in

* removed 'done-testing' from both table test files
  • Loading branch information
tbrowder authored and zoffixznet committed Oct 14, 2016
1 parent 2a3cdb2 commit f1ab1c7
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 65 deletions.
86 changes: 21 additions & 65 deletions S26-documentation/07-tables.t
@@ -1,8 +1,9 @@
use v6;
use Test;
plan 51;
my $r;

plan 42;

=begin table
The Shoveller Eddie Stevens King Arthur's singing shovel
Blue Raja Geoffrey Smith Master of cutlery
Expand Down Expand Up @@ -61,7 +62,7 @@ is $r.contents[1].join('|'), "Human|2|Pizza";
is $r.contents[2].join('|'), "Shark|0|Fish";

=table
Superhero | Secret |
Superhero | Secret |
| Identity | Superpower
==============|=================|================================
The Shoveller | Eddie Stevens | King Arthur's singing shovel
Expand Down Expand Up @@ -118,11 +119,11 @@ is $r.contents[1].join(','), ',X,O';
is $r.contents[2].join(','), ',,X';

=table
X O
X O
===========
X O
X O
===========
X
X

$r = $=pod[7];
is $r.contents.elems, 3;
Expand All @@ -143,66 +144,21 @@ bar
$r = $=pod[8];
is $r.contents.elems, 2;

# TODO: test for issue #128221 when it's closed
# This test, with a '-r0c0' entry in
# the single table row, column 0,
# causes an exception and thus the leading
# hyphen needs to be removed until the issue is
# closed.
=begin table
r0c0 r0c1
=end table
$r = $=pod[9];
my $issue-N128221-fixed = False;
if !$issue-N128221-fixed {
skip 'issue #128221 not yet fixed', 3;
}
else {
# 3 tests
is $r.contents.elems, 1;
is $r.contents[0][0], "-r0c0"; # <= note leading hyphen which needs to be added to the table
is $r.contents[0][1], "r0c1";
}

# TODO: an expanded test (per Zoffix) for issue #128221
# when it's closed.
# This test is for other table parsing issues
# discovered in Zoffix's work on the problem.
# As in the previous test, the first cell in the header
# should have a leading hyphen added ('Col 1' => '-Col 1')
# to fully test the fix.
# test for issue #129862
# uneven rows

# NOTE: This test may need to change after planned table pod fixes are
# made because this is a malformed table and the user should be warned
# of that fact.

=begin table
Col 1 | -Col 2 | _Col 3 | =Col 4
=======+========+========+=======
r0Col 1 | -r0Col 2 | _r0Col 3 | =r0Col 4
-------|--------|--------|-------
r1Col 1 | -r1Col 2 | _r1Col 3 | =r1Col 4
r2Col 1 | -r2Col 2 | _r2Col 3 | =r2Col 4
r3Col 1 | -r3Col 2 | _r3Col 3 | =r3Col 4
r4Col 1 | -r4Col 2 | _r4Col 3 | =r4Col 4
r5Col 1 | -r5Col 2 | _r5Col 3 | =r5Col 4
-------|--------|--------|-------
r6Col 1 | r6Col 2 | r6Col 3 | r6Col 4
a | b | c
l | m | n
x | y
=end table
$r = $=pod[10];
my $issue-N128221-fixed-b = False;
if !$issue-N128221-fixed-b {
skip 'issue #128221 not yet fixed', 10;
}
else {
my $hdrs = $r.headers.join(' ');
my @rows = $r.contents>>.join(' ');

# 10 tests
is $r.headers.elems, 1;
is $r.contents.elems, 7;
is $hdrs, "-Col 1 -Col 2 _Col 3 =Col 4"; # <= note leading hyphen which needs to be added to the table
is @rows[0], "r0Col 1 -r0Col 2 _r0Col 3 =r0Col 4";
is @rows[1], "r1Col 1 -r1Col 2 _r1Col 3 =r1Col 4";
is @rows[2], "r2Col 1 -r2Col 2 _r2Col 3 =r2Col 4";
is @rows[3], "r3Col 1 -r3Col 2 _r3Col 3 =r3Col 4";
is @rows[4], "r4Col 1 -r4Col 2 _r4Col 3 =r4Col 4";
is @rows[5], "r5Col 1 -r5Col 2 _r5Col 3 =r5Col 4";
is @rows[6], "r6Col 1 r6Col 2 r6Col 3 r6Col 4";
}

$r = $=pod[9];
is $r.contents.elems, 3;
is $r.contents[0].join(','), 'a,b,c';
is $r.contents[1].join(','), 'l,m,n';
is $r.contents[2].join(','), 'x,y';
55 changes: 55 additions & 0 deletions S26-documentation/07a-tables-todo-skipped.t
@@ -0,0 +1,55 @@
use v6;
use Test;
my $r;

#?rakudo skip 'RT #128221'
{
# tables here are skipped until appropriate fixes are made

# TODO: test for issue #128221 when it's closed
# This test, with a '-r0c0' entry in
# the single table row, column 0,
# caused an exception.
=begin table
-r0c0 r0c1
=end table
$r = $=pod[9];
# 3 tests
is $r.contents.elems, 1;
is $r.contents[0][0], "-r0c0"; # <= note leading hyphen which caused the original issue
is $r.contents[0][1], "r0c1";

# TODO: an expanded test (per Zoffix) for issue #128221
# when it's closed.
# This test is for other table parsing issues
# discovered in Zoffix's work on the problem.
=begin table
-Col 1 | -Col 2 | _Col 3 | =Col 4
=======+========+========+=======
r0Col 1 | -r0Col 2 | _r0Col 3 | =r0Col 4
-------|--------|--------|-------
r1Col 1 | -r1Col 2 | _r1Col 3 | =r1Col 4
r2Col 1 | -r2Col 2 | _r2Col 3 | =r2Col 4
r3Col 1 | -r3Col 2 | _r3Col 3 | =r3Col 4
r4Col 1 | -r4Col 2 | _r4Col 3 | =r4Col 4
r5Col 1 | -r5Col 2 | _r5Col 3 | =r5Col 4
-------|--------|--------|-------
r6Col 1 | r6Col 2 | r6Col 3 | r6Col 4
=end table
$r = $=pod[10];
my $hdrs = $r.headers.join(' ');
my @rows = $r.contents>>.join(' ');

# 10 tests
is $r.headers.elems, 1;
is $r.contents.elems, 7;
is $hdrs, "-Col 1 -Col 2 _Col 3 =Col 4"; # <= note leading hyphen which caused the original issue
is @rows[0], "r0Col 1 -r0Col 2 _r0Col 3 =r0Col 4";
is @rows[1], "r1Col 1 -r1Col 2 _r1Col 3 =r1Col 4";
is @rows[2], "r2Col 1 -r2Col 2 _r2Col 3 =r2Col 4";
is @rows[3], "r3Col 1 -r3Col 2 _r3Col 3 =r3Col 4";
is @rows[4], "r4Col 1 -r4Col 2 _r4Col 3 =r4Col 4";
is @rows[5], "r5Col 1 -r5Col 2 _r5Col 3 =r5Col 4";
is @rows[6], "r6Col 1 r6Col 2 r6Col 3 r6Col 4";
}

0 comments on commit f1ab1c7

Please sign in to comment.