cucumber-cucumber-expressions 10.1.0 → 11.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rsync +1 -0
  3. data/VERSION +1 -0
  4. data/cucumber-cucumber-expressions.gemspec +5 -2
  5. data/default.mk +13 -6
  6. data/examples.txt +13 -1
  7. data/lib/cucumber/cucumber_expressions/ast.rb +201 -0
  8. data/lib/cucumber/cucumber_expressions/cucumber_expression.rb +80 -76
  9. data/lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb +4 -8
  10. data/lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb +219 -0
  11. data/lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb +95 -0
  12. data/lib/cucumber/cucumber_expressions/errors.rb +175 -4
  13. data/lib/cucumber/cucumber_expressions/group.rb +1 -1
  14. data/lib/cucumber/cucumber_expressions/parameter_type.rb +12 -7
  15. data/lib/cucumber/cucumber_expressions/parameter_type_matcher.rb +2 -2
  16. data/lib/cucumber/cucumber_expressions/parameter_type_registry.rb +1 -1
  17. data/lib/cucumber/cucumber_expressions/tree_regexp.rb +53 -46
  18. data/spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb +24 -0
  19. data/spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb +73 -124
  20. data/spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb +24 -0
  21. data/spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb +1 -1
  22. data/spec/cucumber/cucumber_expressions/expression_examples_spec.rb +1 -1
  23. data/spec/cucumber/cucumber_expressions/expression_factory_spec.rb +0 -4
  24. data/spec/cucumber/cucumber_expressions/tree_regexp_spec.rb +58 -5
  25. data/testdata/ast/alternation-followed-by-optional.yaml +17 -0
  26. data/testdata/ast/alternation-phrase.yaml +16 -0
  27. data/testdata/ast/alternation-with-parameter.yaml +27 -0
  28. data/testdata/ast/alternation-with-unused-end-optional.yaml +15 -0
  29. data/testdata/ast/alternation-with-unused-start-optional.yaml +8 -0
  30. data/testdata/ast/alternation-with-white-space.yaml +12 -0
  31. data/testdata/ast/alternation.yaml +12 -0
  32. data/testdata/ast/anonymous-parameter.yaml +5 -0
  33. data/testdata/ast/closing-brace.yaml +5 -0
  34. data/testdata/ast/closing-parenthesis.yaml +5 -0
  35. data/testdata/ast/empty-alternation.yaml +8 -0
  36. data/testdata/ast/empty-alternations.yaml +9 -0
  37. data/testdata/ast/empty-string.yaml +3 -0
  38. data/testdata/ast/escaped-alternation.yaml +5 -0
  39. data/testdata/ast/escaped-backslash.yaml +5 -0
  40. data/testdata/ast/escaped-opening-parenthesis.yaml +5 -0
  41. data/testdata/ast/escaped-optional-followed-by-optional.yaml +15 -0
  42. data/testdata/ast/escaped-optional-phrase.yaml +10 -0
  43. data/testdata/ast/escaped-optional.yaml +7 -0
  44. data/testdata/ast/opening-brace.yaml +8 -0
  45. data/testdata/ast/opening-parenthesis.yaml +8 -0
  46. data/testdata/ast/optional-containing-nested-optional.yaml +15 -0
  47. data/testdata/ast/optional-phrase.yaml +12 -0
  48. data/testdata/ast/optional.yaml +7 -0
  49. data/testdata/ast/parameter.yaml +7 -0
  50. data/testdata/ast/phrase.yaml +9 -0
  51. data/testdata/ast/unfinished-parameter.yaml +8 -0
  52. data/testdata/expression/allows-escaped-optional-parameter-types.yaml +4 -0
  53. data/testdata/expression/allows-parameter-type-in-alternation-1.yaml +4 -0
  54. data/testdata/expression/allows-parameter-type-in-alternation-2.yaml +4 -0
  55. data/testdata/expression/does-allow-parameter-adjacent-to-alternation.yaml +5 -0
  56. data/testdata/expression/does-not-allow-alternation-in-optional.yaml +9 -0
  57. data/testdata/expression/does-not-allow-alternation-with-empty-alternative-by-adjacent-left-parameter.yaml +10 -0
  58. data/testdata/expression/does-not-allow-alternation-with-empty-alternative-by-adjacent-optional.yaml +9 -0
  59. data/testdata/expression/does-not-allow-alternation-with-empty-alternative-by-adjacent-right-parameter.yaml +9 -0
  60. data/testdata/expression/does-not-allow-alternation-with-empty-alternative.yaml +9 -0
  61. data/testdata/expression/does-not-allow-empty-optional.yaml +9 -0
  62. data/testdata/expression/does-not-allow-nested-optional.yaml +8 -0
  63. data/testdata/expression/does-not-allow-optional-parameter-types.yaml +9 -0
  64. data/testdata/expression/does-not-allow-parameter-name-with-reserved-characters.yaml +10 -0
  65. data/testdata/expression/does-not-allow-unfinished-parenthesis-1.yaml +8 -0
  66. data/testdata/expression/does-not-allow-unfinished-parenthesis-2.yaml +8 -0
  67. data/testdata/expression/does-not-allow-unfinished-parenthesis-3.yaml +8 -0
  68. data/testdata/expression/does-not-match-misquoted-string.yaml +4 -0
  69. data/testdata/expression/doesnt-match-float-as-int.yaml +5 -0
  70. data/testdata/expression/matches-alternation.yaml +4 -0
  71. data/testdata/expression/matches-anonymous-parameter-type.yaml +5 -0
  72. data/testdata/expression/matches-double-quoted-empty-string-as-empty-string-along-with-other-strings.yaml +4 -0
  73. data/testdata/expression/matches-double-quoted-empty-string-as-empty-string.yaml +4 -0
  74. data/testdata/expression/matches-double-quoted-string-with-escaped-double-quote.yaml +4 -0
  75. data/testdata/expression/matches-double-quoted-string-with-single-quotes.yaml +4 -0
  76. data/testdata/expression/matches-double-quoted-string.yaml +4 -0
  77. data/testdata/expression/matches-doubly-escaped-parenthesis.yaml +4 -0
  78. data/testdata/expression/matches-doubly-escaped-slash-1.yaml +4 -0
  79. data/testdata/expression/matches-doubly-escaped-slash-2.yaml +4 -0
  80. data/testdata/expression/matches-escaped-parenthesis-1.yaml +4 -0
  81. data/testdata/expression/matches-escaped-parenthesis-2.yaml +4 -0
  82. data/testdata/expression/matches-escaped-parenthesis-3.yaml +4 -0
  83. data/testdata/expression/matches-escaped-slash.yaml +4 -0
  84. data/testdata/expression/matches-float-1.yaml +5 -0
  85. data/testdata/expression/matches-float-2.yaml +5 -0
  86. data/testdata/expression/matches-int.yaml +5 -0
  87. data/testdata/expression/matches-multiple-double-quoted-strings.yaml +4 -0
  88. data/testdata/expression/matches-multiple-single-quoted-strings.yaml +4 -0
  89. data/testdata/expression/matches-optional-before-alternation-1.yaml +4 -0
  90. data/testdata/expression/matches-optional-before-alternation-2.yaml +4 -0
  91. data/testdata/expression/matches-optional-before-alternation-with-regex-characters-1.yaml +4 -0
  92. data/testdata/expression/matches-optional-before-alternation-with-regex-characters-2.yaml +4 -0
  93. data/testdata/expression/matches-optional-in-alternation-1.yaml +5 -0
  94. data/testdata/expression/matches-optional-in-alternation-2.yaml +5 -0
  95. data/testdata/expression/matches-optional-in-alternation-3.yaml +5 -0
  96. data/testdata/expression/matches-single-quoted-empty-string-as-empty-string-along-with-other-strings.yaml +4 -0
  97. data/testdata/expression/matches-single-quoted-empty-string-as-empty-string.yaml +4 -0
  98. data/testdata/expression/matches-single-quoted-string-with-double-quotes.yaml +4 -0
  99. data/testdata/expression/matches-single-quoted-string-with-escaped-single-quote.yaml +4 -0
  100. data/testdata/expression/matches-single-quoted-string.yaml +4 -0
  101. data/testdata/expression/matches-word.yaml +4 -0
  102. data/testdata/expression/throws-unknown-parameter-type.yaml +10 -0
  103. data/testdata/regex/alternation-with-optional.yaml +2 -0
  104. data/testdata/regex/alternation.yaml +2 -0
  105. data/testdata/regex/empty.yaml +2 -0
  106. data/testdata/regex/escape-regex-characters.yaml +2 -0
  107. data/testdata/regex/optional.yaml +2 -0
  108. data/testdata/regex/parameter.yaml +2 -0
  109. data/testdata/regex/text.yaml +2 -0
  110. data/testdata/regex/unicode.yaml +2 -0
  111. data/testdata/tokens/alternation-phrase.yaml +13 -0
  112. data/testdata/tokens/alternation.yaml +9 -0
  113. data/testdata/tokens/empty-string.yaml +6 -0
  114. data/testdata/tokens/escape-non-reserved-character.yaml +8 -0
  115. data/testdata/tokens/escaped-alternation.yaml +9 -0
  116. data/testdata/tokens/escaped-char-has-start-index-of-text-token.yaml +9 -0
  117. data/testdata/tokens/escaped-end-of-line.yaml +8 -0
  118. data/testdata/tokens/escaped-optional.yaml +7 -0
  119. data/testdata/tokens/escaped-parameter.yaml +7 -0
  120. data/testdata/tokens/escaped-space.yaml +7 -0
  121. data/testdata/tokens/optional-phrase.yaml +13 -0
  122. data/testdata/tokens/optional.yaml +9 -0
  123. data/testdata/tokens/parameter-phrase.yaml +13 -0
  124. data/testdata/tokens/parameter.yaml +9 -0
  125. data/testdata/tokens/phrase.yaml +11 -0
  126. metadata +117 -11
  127. data/spec/cucumber/cucumber_expressions/cucumber_expression_regexp_spec.rb +0 -57
@@ -0,0 +1,4 @@
1
+ expression: \({int})
2
+ text: (3)
3
+ expected: |-
4
+ [3]
@@ -0,0 +1,4 @@
1
+ expression: a/i{int}n/y
2
+ text: i18n
3
+ expected: |-
4
+ [18]
@@ -0,0 +1,4 @@
1
+ expression: a/i{int}n/y
2
+ text: a11y
3
+ expected: |-
4
+ [11]
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {int}st/nd/rd/th
3
+ text: 3rd
4
+ expected: |-
5
+ [3]
@@ -0,0 +1,9 @@
1
+ expression: three( brown/black) mice
2
+ text: three brown/black mice
3
+ exception: |-
4
+ This Cucumber Expression has a problem at column 13:
5
+
6
+ three( brown/black) mice
7
+ ^
8
+ An alternation can not be used inside an optional.
9
+ You can use '\/' to escape the the '/'
@@ -0,0 +1,10 @@
1
+ expression: |-
2
+ {int}/x
3
+ text: '3'
4
+ exception: |-
5
+ This Cucumber Expression has a problem at column 6:
6
+
7
+ {int}/x
8
+ ^
9
+ Alternative may not be empty.
10
+ If you did not mean to use an alternative you can use '\/' to escape the the '/'
@@ -0,0 +1,9 @@
1
+ expression: three (brown)/black mice
2
+ text: three brown mice
3
+ exception: |-
4
+ This Cucumber Expression has a problem at column 7:
5
+
6
+ three (brown)/black mice
7
+ ^-----^
8
+ An alternative may not exclusively contain optionals.
9
+ If you did not mean to use an optional you can use '\(' to escape the the '('
@@ -0,0 +1,9 @@
1
+ expression: x/{int}
2
+ text: '3'
3
+ exception: |-
4
+ This Cucumber Expression has a problem at column 3:
5
+
6
+ x/{int}
7
+ ^
8
+ Alternative may not be empty.
9
+ If you did not mean to use an alternative you can use '\/' to escape the the '/'
@@ -0,0 +1,9 @@
1
+ expression: three brown//black mice
2
+ text: three brown mice
3
+ exception: |-
4
+ This Cucumber Expression has a problem at column 13:
5
+
6
+ three brown//black mice
7
+ ^
8
+ Alternative may not be empty.
9
+ If you did not mean to use an alternative you can use '\/' to escape the the '/'
@@ -0,0 +1,9 @@
1
+ expression: three () mice
2
+ text: three brown mice
3
+ exception: |-
4
+ This Cucumber Expression has a problem at column 7:
5
+
6
+ three () mice
7
+ ^^
8
+ An optional must contain some text.
9
+ If you did not mean to use an optional you can use '\(' to escape the the '('
@@ -0,0 +1,8 @@
1
+ expression: "(a(b))"
2
+ exception: |-
3
+ This Cucumber Expression has a problem at column 3:
4
+
5
+ (a(b))
6
+ ^-^
7
+ An optional may not contain an other optional.
8
+ If you did not mean to use an optional type you can use '\(' to escape the the '('. For more complicated expressions consider using a regular expression instead.
@@ -0,0 +1,9 @@
1
+ expression: ({int})
2
+ text: '3'
3
+ exception: |-
4
+ This Cucumber Expression has a problem at column 2:
5
+
6
+ ({int})
7
+ ^---^
8
+ An optional may not contain a parameter type.
9
+ If you did not mean to use an parameter type you can use '\{' to escape the the '{'
@@ -0,0 +1,10 @@
1
+ expression: |-
2
+ {(string)}
3
+ text: something
4
+ exception: |-
5
+ This Cucumber Expression has a problem at column 2:
6
+
7
+ {(string)}
8
+ ^
9
+ Parameter names may not contain '{', '}', '(', ')', '\' or '/'.
10
+ Did you mean to use a regular expression?
@@ -0,0 +1,8 @@
1
+ expression: three (exceptionally\) {string\} mice
2
+ exception: |-
3
+ This Cucumber Expression has a problem at column 24:
4
+
5
+ three (exceptionally\) {string\} mice
6
+ ^
7
+ The '{' does not have a matching '}'.
8
+ If you did not intend to use a parameter you can use '\{' to escape the a parameter
@@ -0,0 +1,8 @@
1
+ expression: three (exceptionally\) {string} mice
2
+ exception: |-
3
+ This Cucumber Expression has a problem at column 7:
4
+
5
+ three (exceptionally\) {string} mice
6
+ ^
7
+ The '(' does not have a matching ')'.
8
+ If you did not intend to use optional text you can use '\(' to escape the optional text
@@ -0,0 +1,8 @@
1
+ expression: three ((exceptionally\) strong) mice
2
+ exception: |-
3
+ This Cucumber Expression has a problem at column 7:
4
+
5
+ three ((exceptionally\) strong) mice
6
+ ^
7
+ The '(' does not have a matching ')'.
8
+ If you did not intend to use optional text you can use '\(' to escape the optional text
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three "blind' mice
3
+ expected: |-
4
+ null
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {int}
3
+ text: '1.22'
4
+ expected: |-
5
+ null
@@ -0,0 +1,4 @@
1
+ expression: mice/rats and rats\/mice
2
+ text: rats and rats/mice
3
+ expected: |-
4
+ []
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {}
3
+ text: '0.22'
4
+ expected: |-
5
+ ["0.22"]
@@ -0,0 +1,4 @@
1
+ expression: three {string} and {string} mice
2
+ text: three "" and "handsome" mice
3
+ expected: |-
4
+ ["","handsome"]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three "" mice
3
+ expected: |-
4
+ [""]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three "bl\"nd" mice
3
+ expected: |-
4
+ ["bl\"nd"]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three "'blind'" mice
3
+ expected: |-
4
+ ["'blind'"]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three "blind" mice
3
+ expected: |-
4
+ ["blind"]
@@ -0,0 +1,4 @@
1
+ expression: three \\(exceptionally) \\{string} mice
2
+ text: three \exceptionally \"blind" mice
3
+ expected: |-
4
+ ["blind"]
@@ -0,0 +1,4 @@
1
+ expression: 12\\/2020
2
+ text: 12\
3
+ expected: |-
4
+ []
@@ -0,0 +1,4 @@
1
+ expression: 12\\/2020
2
+ text: '2020'
3
+ expected: |-
4
+ []
@@ -0,0 +1,4 @@
1
+ expression: three \(exceptionally) \{string} mice
2
+ text: three (exceptionally) {string} mice
3
+ expected: |-
4
+ []
@@ -0,0 +1,4 @@
1
+ expression: three \((exceptionally)) \{{string}} mice
2
+ text: three (exceptionally) {"blind"} mice
3
+ expected: |-
4
+ ["blind"]
@@ -0,0 +1,4 @@
1
+ expression: three \((exceptionally)) \{{string}} mice
2
+ text: three (exceptionally) {"blind"} mice
3
+ expected: |-
4
+ ["blind"]
@@ -0,0 +1,4 @@
1
+ expression: 12\/2020
2
+ text: 12/2020
3
+ expected: |-
4
+ []
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {float}
3
+ text: '0.22'
4
+ expected: |-
5
+ [0.22]
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {float}
3
+ text: '.22'
4
+ expected: |-
5
+ [0.22]
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {int}
3
+ text: '22'
4
+ expected: |-
5
+ [22]
@@ -0,0 +1,4 @@
1
+ expression: three {string} and {string} mice
2
+ text: three "blind" and "crippled" mice
3
+ expected: |-
4
+ ["blind","crippled"]
@@ -0,0 +1,4 @@
1
+ expression: three {string} and {string} mice
2
+ text: three 'blind' and 'crippled' mice
3
+ expected: |-
4
+ ["blind","crippled"]
@@ -0,0 +1,4 @@
1
+ expression: three (brown )mice/rats
2
+ text: three brown mice
3
+ expected: |-
4
+ []
@@ -0,0 +1,4 @@
1
+ expression: three (brown )mice/rats
2
+ text: three rats
3
+ expected: |-
4
+ []
@@ -0,0 +1,4 @@
1
+ expression: I wait {int} second(s)./second(s)?
2
+ text: I wait 2 seconds?
3
+ expected: |-
4
+ [2]
@@ -0,0 +1,4 @@
1
+ expression: I wait {int} second(s)./second(s)?
2
+ text: I wait 1 second.
3
+ expected: |-
4
+ [1]
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {int} rat(s)/mouse/mice
3
+ text: 3 rats
4
+ expected: |-
5
+ [3]
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {int} rat(s)/mouse/mice
3
+ text: 2 mice
4
+ expected: |-
5
+ [2]
@@ -0,0 +1,5 @@
1
+ expression: |-
2
+ {int} rat(s)/mouse/mice
3
+ text: 1 mouse
4
+ expected: |-
5
+ [1]
@@ -0,0 +1,4 @@
1
+ expression: three {string} and {string} mice
2
+ text: three '' and 'handsome' mice
3
+ expected: |-
4
+ ["","handsome"]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three '' mice
3
+ expected: |-
4
+ [""]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three '"blind"' mice
3
+ expected: |-
4
+ ["\"blind\""]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three 'bl\'nd' mice
3
+ expected: |-
4
+ ["bl'nd"]
@@ -0,0 +1,4 @@
1
+ expression: three {string} mice
2
+ text: three 'blind' mice
3
+ expected: |-
4
+ ["blind"]
@@ -0,0 +1,4 @@
1
+ expression: three {word} mice
2
+ text: three blind mice
3
+ expected: |-
4
+ ["blind"]
@@ -0,0 +1,10 @@
1
+ expression: |-
2
+ {unknown}
3
+ text: something
4
+ exception: |-
5
+ This Cucumber Expression has a problem at column 1:
6
+
7
+ {unknown}
8
+ ^-------^
9
+ Undefined parameter type 'unknown'.
10
+ Please register a ParameterType for 'unknown'
@@ -0,0 +1,2 @@
1
+ expression: "a/b(c)"
2
+ expected: ^(?:a|b(?:c)?)$
@@ -0,0 +1,2 @@
1
+ expression: "a/b c/d/e"
2
+ expected: ^(?:a|b) (?:c|d|e)$
@@ -0,0 +1,2 @@
1
+ expression: ""
2
+ expected: ^$
@@ -0,0 +1,2 @@
1
+ expression: '^$[]\(\){}\\.|?*+'
2
+ expected: ^\^\$\[\]\(\)(.*)\\\.\|\?\*\+$
@@ -0,0 +1,2 @@
1
+ expression: "(a)"
2
+ expected: ^(?:a)?$
@@ -0,0 +1,2 @@
1
+ expression: "{int}"
2
+ expected: ^((?:-?\d+)|(?:\d+))$
@@ -0,0 +1,2 @@
1
+ expression: "a"
2
+ expected: ^a$
@@ -0,0 +1,2 @@
1
+ expression: "Привет, Мир(ы)!"
2
+ expected: ^Привет, Мир(?:ы)?!$
@@ -0,0 +1,13 @@
1
+ expression: three blind/cripple mice
2
+ expected: |-
3
+ [
4
+ {"type": "START_OF_LINE", "start": 0, "end": 0, "text": ""},
5
+ {"type": "TEXT", "start": 0, "end": 5, "text": "three"},
6
+ {"type": "WHITE_SPACE", "start": 5, "end": 6, "text": " "},
7
+ {"type": "TEXT", "start": 6, "end": 11, "text": "blind"},
8
+ {"type": "ALTERNATION", "start": 11, "end": 12, "text": "/"},
9
+ {"type": "TEXT", "start": 12, "end": 19, "text": "cripple"},
10
+ {"type": "WHITE_SPACE", "start": 19, "end": 20, "text": " "},
11
+ {"type": "TEXT", "start": 20, "end": 24, "text": "mice"},
12
+ {"type": "END_OF_LINE", "start": 24, "end": 24, "text": ""}
13
+ ]
@@ -0,0 +1,9 @@
1
+ expression: blind/cripple
2
+ expected: |-
3
+ [
4
+ {"type": "START_OF_LINE", "start": 0, "end": 0, "text": ""},
5
+ {"type": "TEXT", "start": 0, "end": 5, "text": "blind"},
6
+ {"type": "ALTERNATION", "start": 5, "end": 6, "text": "/"},
7
+ {"type": "TEXT", "start": 6, "end": 13, "text": "cripple"},
8
+ {"type": "END_OF_LINE", "start": 13, "end": 13, "text": ""}
9
+ ]
@@ -0,0 +1,6 @@
1
+ expression: ""
2
+ expected: |-
3
+ [
4
+ {"type": "START_OF_LINE", "start": 0, "end": 0, "text": ""},
5
+ {"type": "END_OF_LINE", "start": 0, "end": 0, "text": ""}
6
+ ]
@@ -0,0 +1,8 @@
1
+ expression: \[
2
+ exception: |-
3
+ This Cucumber Expression has a problem at column 2:
4
+
5
+ \[
6
+ ^
7
+ Only the characters '{', '}', '(', ')', '\', '/' and whitespace can be escaped.
8
+ If you did mean to use an '\' you can use '\\' to escape it