From b7855c124f4df8357f8fda67a527cb7fd54cbbce Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sun, 1 Jun 2014 19:49:37 +0200 Subject: [PATCH] XPath lexer test for predicates using axes. --- spec/oga/xpath/lexer_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/oga/xpath/lexer_spec.rb b/spec/oga/xpath/lexer_spec.rb index 776a368..6c41361 100644 --- a/spec/oga/xpath/lexer_spec.rb +++ b/spec/oga/xpath/lexer_spec.rb @@ -126,6 +126,19 @@ describe Oga::XPath::Lexer do ] end + example 'lex a predicate expression using axes' do + lex_xpath('/div[/foo/bar]').should == [ + [:T_SLASH, nil], + [:T_IDENT, 'div'], + [:T_LBRACK, nil], + [:T_SLASH, nil], + [:T_IDENT, 'foo'], + [:T_SLASH, nil], + [:T_IDENT, 'bar'], + [:T_RBRACK, nil] + ] + end + # The following are a bunch of examples taken from Wikipedia and the W3 spec # to see how the lexer handles them.