Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for extra table content #245

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions dotnet/Gherkin/GherkinLine.cs
Expand Up @@ -125,16 +125,19 @@ public IEnumerable<GherkinLineSpan> GetTableCells()
cell = "";
startPos = pos;
} else if (c == GherkinLanguageConstants.TABLE_CELL_ESCAPE_CHAR) {
rowEnum.MoveNext();
pos++;
c = rowEnum.Current;
if (c == GherkinLanguageConstants.TABLE_CELL_NEWLINE_ESCAPE) {
cell += "\n";
} else {
if (c.ToString() != GherkinLanguageConstants.TABLE_CELL_SEPARATOR && c != GherkinLanguageConstants.TABLE_CELL_ESCAPE_CHAR) {
cell += GherkinLanguageConstants.TABLE_CELL_ESCAPE_CHAR;
if(rowEnum.MoveNext()) {
pos++;
c = rowEnum.Current;
if (c == GherkinLanguageConstants.TABLE_CELL_NEWLINE_ESCAPE) {
cell += "\n";
} else {
if (c.ToString() != GherkinLanguageConstants.TABLE_CELL_SEPARATOR && c != GherkinLanguageConstants.TABLE_CELL_ESCAPE_CHAR) {
cell += GherkinLanguageConstants.TABLE_CELL_ESCAPE_CHAR;
}
cell += c;
}
cell += c;
} else {
cell += GherkinLanguageConstants.TABLE_CELL_ESCAPE_CHAR;
}
} else {
cell += c;
Expand Down
9 changes: 6 additions & 3 deletions perl/lib/Gherkin/Line.pm
Expand Up @@ -86,9 +86,12 @@ sub _split_table_cells_iterator {
return ( $cell, $start_col );
}
} elsif ( $char eq "\\" ) {
$row =~ s/^(.)// || die "Unpossible";
$col += 1;
$cell .= '\\' . $1;
if ($row =~ s/^(.)//) {
$col += 1;
$cell .= '\\' . $1;
} else {
$cell .= '\\';
}
} elsif ( defined $char ) {
$cell .= $char;
} else {
Expand Down
12 changes: 12 additions & 0 deletions testdata/good/extra_table_content.feature
@@ -0,0 +1,12 @@
Feature: Extra table content
Tables are delimited by pipes on both sides.
Anything that isn't enclosed is not part of
the table.

It is not recommended to use this feature, but
it is how the implementation currently works.

Scenario: We're a bit extra
Given a pirate crew
| Luffy | Zorro | Doflamingo \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain the slash, maybe in another test case?

| Nami | Brook | BlackBeard
1 change: 1 addition & 0 deletions testdata/good/extra_table_content.feature.ast.ndjson
@@ -0,0 +1 @@
{"gherkinDocument": {"comments": [], "feature": {"children": [{"scenario": {"description": "", "examples": [], "id": "3", "keyword": "Scenario", "location": {"column": 3, "line": 9}, "name": "We're a bit extra", "steps": [{"dataTable": {"location": {"column": 7, "line": 11}, "rows": [{"cells": [{"location": {"column": 9, "line": 11}, "value": "Luffy"}, {"location": {"column": 17, "line": 11}, "value": "Zorro"}], "id": "0", "location": {"column": 7, "line": 11}}, {"cells": [{"location": {"column": 9, "line": 12}, "value": "Nami"}, {"location": {"column": 17, "line": 12}, "value": "Brook"}], "id": "1", "location": {"column": 7, "line": 12}}]}, "id": "2", "keyword": "Given ", "keywordType": "Context", "location": {"column": 5, "line": 10}, "text": "a pirate crew"}], "tags": []}}], "description": " Tables are delimited by pipes on both sides.\n Anything that isn't enclosed is not part of\n the table.\n\n It is not recommended to use this feature, but\n it is how the implementation currently works.", "keyword": "Feature", "language": "en", "location": {"column": 1, "line": 1}, "name": "Extra table content", "tags": []}, "uri": "../testdata/good/extra_table_content.feature"}}
1 change: 1 addition & 0 deletions testdata/good/extra_table_content.feature.pickles.ndjson
@@ -0,0 +1 @@
{"pickle": {"astNodeIds": ["3"], "id": "5", "language": "en", "name": "We're a bit extra", "steps": [{"argument": {"dataTable": {"rows": [{"cells": [{"value": "Luffy"}, {"value": "Zorro"}]}, {"cells": [{"value": "Nami"}, {"value": "Brook"}]}]}}, "astNodeIds": ["2"], "id": "4", "text": "a pirate crew", "type": "Context"}], "tags": [], "uri": "../testdata/good/extra_table_content.feature"}}
1 change: 1 addition & 0 deletions testdata/good/extra_table_content.feature.source.ndjson
@@ -0,0 +1 @@
{"source": {"data": "Feature: Extra table content\n Tables are delimited by pipes on both sides.\n Anything that isn't enclosed is not part of\n the table.\n\n It is not recommended to use this feature, but\n it is how the implementation currently works.\n\n Scenario: We're a bit extra\n Given a pirate crew\n | Luffy | Zorro | Doflamingo \\\n | Nami | Brook | BlackBeard\n", "mediaType": "text/x.cucumber.gherkin+plain", "uri": "../testdata/good/extra_table_content.feature"}}
13 changes: 13 additions & 0 deletions testdata/good/extra_table_content.feature.tokens
@@ -0,0 +1,13 @@
(1:1)FeatureLine:()Feature/Extra table content/
(2:1)Other:/ Tables are delimited by pipes on both sides./
(3:1)Other:/ Anything that isn't enclosed is not part of/
(4:1)Other:/ the table./
(5:1)Other://
(6:1)Other:/ It is not recommended to use this feature, but/
(7:1)Other:/ it is how the implementation currently works./
(8:1)Other://
(9:3)ScenarioLine:()Scenario/We're a bit extra/
(10:5)StepLine:(Context)Given /a pirate crew/
(11:7)TableRow://9:Luffy,17:Zorro
(12:7)TableRow://9:Nami,17:Brook
EOF