mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 00:40:40 -07:00
Speed up the lexer for Ruby 3.4+ (#1832)
* Speed up lexing * Bump msrv to 3.0 (from 2.7) * Normalize test for ruby-head compat * Fix bug when parsing negative numbers
This commit is contained in:
@@ -32,7 +32,7 @@ class TestDrop < Liquid::Drop
|
||||
attr_reader :value
|
||||
|
||||
def registers
|
||||
{ @value => @context.registers[@value] }
|
||||
"{#{@value.inspect}=>#{@context.registers[@value].inspect}}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -50,4 +50,14 @@ class LexerUnitTest < Minitest::Test
|
||||
Lexer.new("%").tokenize
|
||||
end
|
||||
end
|
||||
|
||||
def test_negative_numbers
|
||||
tokens = Lexer.new("foo | default: -1").tokenize
|
||||
assert_equal([[:id, 'foo'], [:pipe, '|'], [:id, 'default'], [:colon, ":"], [:number, '-1'], [:end_of_string]], tokens)
|
||||
end
|
||||
|
||||
def test_greater_than_two_digits
|
||||
tokens = Lexer.new("foo > 12").tokenize
|
||||
assert_equal([[:id, 'foo'], [:comparison, '>'], [:number, '12'], [:end_of_string]], tokens)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user