Lexing of CSS axes with surrounding whitespace.

This commit is contained in:
Yorick Peterse 2014-10-07 22:06:45 +02:00
parent 619c0bbc14
commit 625b9eeffd
3 changed files with 32 additions and 15 deletions

View File

@ -183,9 +183,9 @@ module Oga
op_ends_with = '$=';
op_in = '*=';
op_hyphen_in = '|=';
op_child = '>';
op_fol_direct = '+';
op_fol = '~';
op_child = whitespace* '>' whitespace*;
op_fol_direct = whitespace* '+' whitespace*;
op_fol = whitespace* '~' whitespace*;
# Numbers
#

View File

@ -0,0 +1,29 @@
require 'spec_helper'
describe Oga::CSS::Lexer do
context 'axes' do
example 'lex the > axis' do
lex_css('>').should == [[:T_CHILD, nil]]
end
example 'lex the > axis with surrounding whitespace' do
lex_css('>').should == [[:T_CHILD, nil]]
end
example 'lex the + axis' do
lex_css('+').should == [[:T_FOLLOWING_DIRECT, nil]]
end
example 'lex the + axis with surrounding whitespace' do
lex_css(' + ').should == [[:T_FOLLOWING_DIRECT, nil]]
end
example 'lex the ~ axis' do
lex_css('~').should == [[:T_FOLLOWING, nil]]
end
example 'lex the ~ axis with surrounding whitespace' do
lex_css(' ~ ').should == [[:T_FOLLOWING, nil]]
end
end
end

View File

@ -33,17 +33,5 @@ describe Oga::CSS::Lexer do
example 'lex the |= operator' do
lex_css('|=').should == [[:T_HYPHEN_IN, nil]]
end
example 'lex the > operator' do
lex_css('>').should == [[:T_CHILD, nil]]
end
example 'lex the + operator' do
lex_css('+').should == [[:T_FOLLOWING_DIRECT, nil]]
end
example 'lex the ~ operator' do
lex_css('~').should == [[:T_FOLLOWING, nil]]
end
end
end