summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-22 16:04:18 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-22 16:04:18 +0100
commit6fe4d2c6f0439153017a7ede20ce52a5643eeec2 (patch)
treea492f12cb288f6ff6f5cbb4ebb806e2b253c65e3 /spec/lib
parent867a4f68cbbe58652e8389e05edfd36df81cb72b (diff)
downloadgitlab-ce-6fe4d2c6f0439153017a7ede20ce52a5643eeec2.tar.gz
Build a recursive parser for pipeline expressions
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
index 180b6908fb5..c70bcc8438c 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
@@ -2,5 +2,22 @@ require 'spec_helper'
describe Gitlab::Ci::Pipeline::Expression::Parser do
describe '#tree' do
+ context 'when using an operator' do
+ it 'returns a reverse descent parse tree' do
+ expect(described_class.new(tokens('$VAR == "123"')).tree)
+ .to be_a Gitlab::Ci::Pipeline::Expression::Equals
+ end
+ end
+
+ context 'when using a single token' do
+ it 'returns a single token instance' do
+ expect(described_class.new(tokens('$VAR')).tree)
+ .to be_a Gitlab::Ci::Pipeline::Expression::Variable
+ end
+ end
+ end
+
+ def tokens(statement)
+ Gitlab::Ci::Pipeline::Expression::Lexer.new(statement).tokens.to_enum
end
end