Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cucumber-rs/gherkin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.11.1
Choose a base ref
...
head repository: cucumber-rs/gherkin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.11.2
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Feb 18, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    evenyag Yingwen
    Copy the full SHA
    aae1bf6 View commit details
  2. Copy the full SHA
    5235160 View commit details
Showing with 98 additions and 11 deletions.
  1. +14 −0 CHANGELOG.md
  2. +2 −2 Cargo.toml
  3. +1 −1 LICENSE-MIT
  4. +1 −1 src/keywords.rs
  5. +1 −1 src/lib.rs
  6. +78 −5 src/parser.rs
  7. +1 −1 src/tagexpr.rs
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,20 @@ All user visible changes to `gherkin` crate will be documented in this file. Thi



## [0.11.2] · 2022-02-18
[0.11.2]: /../../tree/v0.11.2

[Diff](/../../compare/v0.11.1...v0.11.2)

### Fixed

- Incorrect line numbers reporting. ([#33])

[#33]: /../../pull/33




## [0.11.1] · 2021-12-08
[0.11.1]: /../../tree/v0.11.1

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gherkin"
version = "0.11.1"
version = "0.11.2"
edition = "2018"
description = """\
Pure Rust implementation of Gherkin language (`.feature` file) for \
@@ -48,7 +48,7 @@ syn = "1.0"

[dev-dependencies]
async-trait = "0.1.40"
cucumber = "0.10"
cucumber = "0.11"
futures = "0.3.5"

[[test]]
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018-2021 Brendan Molloy <brendan@bbqsrc.net>
Copyright (c) 2018-2022 Brendan Molloy <brendan@bbqsrc.net>

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
2 changes: 1 addition & 1 deletion src/keywords.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2021 Brendan Molloy <brendan@bbqsrc.net>
// Copyright (c) 2020-2022 Brendan Molloy <brendan@bbqsrc.net>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2021 Brendan Molloy <brendan@bbqsrc.net>
// Copyright (c) 2018-2022 Brendan Molloy <brendan@bbqsrc.net>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
83 changes: 78 additions & 5 deletions src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2021 Brendan Molloy <brendan@bbqsrc.net>
// Copyright (c) 2020-2022 Brendan Molloy <brendan@bbqsrc.net>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@@ -109,7 +109,10 @@ impl GherkinEnv {
}

fn increment_nl(&self, offset: usize) {
self.line_offsets.borrow_mut().push(offset);
let mut line_offsets = self.line_offsets.borrow_mut();
if !line_offsets.contains(&offset) {
line_offsets.push(offset);
}
}

fn position(&self, offset: usize) -> LineCol {
@@ -202,15 +205,15 @@ rule language_directive() -> ()
}

rule docstring() -> String
= "\"\"\"" n:$((!"\"\"\""[_])*) "\"\"\"" nl_eof() {
= "\"\"\"" n:$((!"\"\"\"" (nl() / [_]))*) "\"\"\"" nl_eof() {
textwrap::dedent(n)
}
/ "```" n:$((!"```"[_])*) "```" nl_eof() {
/ "```" n:$((!"```"(nl() / [_]))*) "```" nl_eof() {
textwrap::dedent(n)
}

rule table_cell() -> &'input str
= "|" _ !(nl0() / eof()) n:$((!"|"[_])*) { n }
= "|" _ !(nl0() / eof()) n:$((!("|" / nl0())[_])*) { n }

pub(crate) rule table_row() -> Vec<String>
= n:(table_cell() ** _) _ "|" _ nl_eof() {
@@ -665,6 +668,76 @@ Scenario: Hello
assert!(feature.scenarios[0].steps[0].position.line != 0)
}

#[test]
fn correct_line_numbers() {
let env = GherkinEnv::default();
let input = r#"
# language: en
Feature: Basic functionality
here's some text
really
@tag
Scenario: Hello
Given a step
Then a step
@tag
Scenario: Hello
Given a step
And more
# comment
Rule: rule
@tag
Scenario Outline: Hello
Given <step>
"""
Doc String
"""
Examples:
| step |
| 1 |
| 2 |
@tag
Rule: rule
#comment
Scenario: Hello
Given a step
"#;
let feature = gherkin_parser::feature(input, &env).unwrap();
assert_eq!(feature.scenarios.len(), 2);
assert!(feature.description.is_some());
assert_eq!(feature.position.line, 3);
assert_eq!(feature.scenarios[0].position.line, 7);
assert_eq!(feature.scenarios[0].steps[0].position.line, 8);
assert_eq!(feature.scenarios[0].steps[1].position.line, 9);
assert_eq!(feature.scenarios[1].position.line, 11);
assert_eq!(feature.scenarios[1].steps[0].position.line, 12);
assert_eq!(feature.scenarios[1].steps[1].position.line, 14);
assert_eq!(feature.rules[0].position.line, 17);
assert_eq!(feature.rules[0].position.line, 17);
assert_eq!(feature.rules[0].scenarios[0].position.line, 19);
assert_eq!(feature.rules[0].scenarios[0].steps[0].position.line, 20);
assert_eq!(feature.rules[0].scenarios[0].examples[0].position.line, 25);
assert_eq!(
feature.rules[0].scenarios[0].examples[0]
.table
.position
.line,
26,
);
assert_eq!(
feature.rules[0].scenarios[0].examples[0].table.rows.len(),
3,
);
assert_eq!(feature.rules[1].position.line, 32);
assert_eq!(feature.rules[1].scenarios[0].position.line, 34);
assert_eq!(feature.rules[1].scenarios[0].steps[0].position.line, 35);
}

#[test]
fn feature_only() {
let env = GherkinEnv::default();
2 changes: 1 addition & 1 deletion src/tagexpr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 Brendan Molloy <brendan@bbqsrc.net>
// Copyright (c) 2020-2022 Brendan Molloy <brendan@bbqsrc.net>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license