cucumber-tag-expressions 4.0.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cucumber/tag_expressions/expressions.rb +2 -2
- data/lib/cucumber/tag_expressions/parser.rb +30 -1
- data/spec/expressions_spec.rb +29 -0
- data/spec/parser_spec.rb +5 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add075dc395b297351352601837188db90a7e347035845e63e8af7028ecc9d90
|
4
|
+
data.tar.gz: d9e1ed8d2291b2338c2a64303581e6cfa84854265aff0422d75bf8641f156c5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 258a7f1a40ba0022491144dba178f8b6ac6a2e9c6180273e2c19244981b463651cb586c9ee6bf4acf4c34c42400f28305165d75571749be6de275fe9fb68d3ed
|
7
|
+
data.tar.gz: e03fbb76b4a951de7a8f4a1d6a3f60b3d47ed9c79b158e729ec153880b36bb28181bbc95c14125cd6ace08ab3578def4ca68781d90fbee64f455d04e4a6ad232
|
@@ -3,7 +3,7 @@ module Cucumber
|
|
3
3
|
# Literal expression node
|
4
4
|
class Literal
|
5
5
|
def initialize(value)
|
6
|
-
@value = value
|
6
|
+
@value = value
|
7
7
|
end
|
8
8
|
|
9
9
|
def evaluate(variables)
|
@@ -11,7 +11,7 @@ module Cucumber
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_s
|
14
|
-
@value.gsub(/\(/,
|
14
|
+
@value.gsub(/\\/, "\\\\\\\\").gsub(/\(/, "\\(").gsub(/\)/, "\\)")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -53,7 +53,36 @@ module Cucumber
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def tokens(infix_expression)
|
56
|
-
|
56
|
+
escaped = false
|
57
|
+
token = ""
|
58
|
+
result = []
|
59
|
+
infix_expression.chars.each do | ch |
|
60
|
+
if ch == '\\' && !escaped
|
61
|
+
escaped = true
|
62
|
+
else
|
63
|
+
if ch.match(/\s/)
|
64
|
+
if token.length > 0
|
65
|
+
result.push(token)
|
66
|
+
token = ""
|
67
|
+
end
|
68
|
+
else
|
69
|
+
if (ch == '(' || ch == ')') && !escaped
|
70
|
+
if token.length > 0
|
71
|
+
result.push(token)
|
72
|
+
token = ""
|
73
|
+
end
|
74
|
+
result.push(ch)
|
75
|
+
else
|
76
|
+
token = token + ch
|
77
|
+
end
|
78
|
+
end
|
79
|
+
escaped = false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
if token.length > 0
|
83
|
+
result.push(token)
|
84
|
+
end
|
85
|
+
result
|
57
86
|
end
|
58
87
|
|
59
88
|
def process_tokens!(infix_expression)
|
data/spec/expressions_spec.rb
CHANGED
@@ -52,4 +52,33 @@ describe 'Expression node' do
|
|
52
52
|
include_examples 'expression node', infix_expression, data
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
describe Cucumber::TagExpressions::Or do
|
57
|
+
context '#evaluate' do
|
58
|
+
infix_expression = 'x\\\\ or (y\\\\\\)) or (z\\\\)'
|
59
|
+
data = [[%w(), false],
|
60
|
+
[%w(x), false],
|
61
|
+
[%w(y\)), false],
|
62
|
+
[%w(z), false],
|
63
|
+
[%w(x\\), true],
|
64
|
+
[%w(y\\\)), true],
|
65
|
+
[%w(z\\), true]]
|
66
|
+
include_examples 'expression node', infix_expression, data
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe Cucumber::TagExpressions::Or do
|
71
|
+
context '#evaluate' do
|
72
|
+
infix_expression = '\\x or y\\ or z\\'
|
73
|
+
data = [[%w(), false],
|
74
|
+
[%w(\\x), false],
|
75
|
+
[%w(y\\), false],
|
76
|
+
[%w(z\\), false],
|
77
|
+
[%w(x), true],
|
78
|
+
[%w(y), true],
|
79
|
+
[%w(z), true]]
|
80
|
+
include_examples 'expression node', infix_expression, data
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
55
84
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -9,7 +9,11 @@ describe Cucumber::TagExpressions::Parser do
|
|
9
9
|
['not a or b and not c or not d or e and f',
|
10
10
|
'( ( ( not ( a ) or ( b and not ( c ) ) ) or not ( d ) ) or ( e and f ) )'],
|
11
11
|
['not a\\(\\) or b and not c or not d or e and f',
|
12
|
-
'( ( ( not ( a\\(\\) ) or ( b and not ( c ) ) ) or not ( d ) ) or ( e and f ) )']
|
12
|
+
'( ( ( not ( a\\(\\) ) or ( b and not ( c ) ) ) or not ( d ) ) or ( e and f ) )'],
|
13
|
+
['a\\\\ and b', '( a\\\\ and b )'],
|
14
|
+
['\\a and b\\ and c\\', '( ( a and b ) and c )'],
|
15
|
+
['(a and b\\\\)', '( a and b\\\\ )'],
|
16
|
+
['a\\\\\\( and b\\\\\\)', '( a\\\\\\( and b\\\\\\) )']
|
13
17
|
]
|
14
18
|
|
15
19
|
error_test_data = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-tag-expressions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Nodari
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -93,8 +93,8 @@ requirements: []
|
|
93
93
|
rubygems_version: 3.1.2
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
|
-
summary: cucumber-tag-expressions-4.0
|
96
|
+
summary: cucumber-tag-expressions-4.1.0
|
97
97
|
test_files:
|
98
|
-
- spec/parser_spec.rb
|
99
|
-
- spec/capture_warnings.rb
|
100
98
|
- spec/expressions_spec.rb
|
99
|
+
- spec/capture_warnings.rb
|
100
|
+
- spec/parser_spec.rb
|