mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 03:10:39 -07:00
Merge pull request #1371 from Shopify/pz-revert-instrument
Revert instrumentation of end_tag_params and range_float
This commit is contained in:
@@ -77,9 +77,6 @@ module Liquid
|
|||||||
body.parse(tokens, parse_context) do |end_tag_name, end_tag_params|
|
body.parse(tokens, parse_context) do |end_tag_name, end_tag_params|
|
||||||
@blank &&= body.blank?
|
@blank &&= body.blank?
|
||||||
|
|
||||||
# Instrument for bug 1346
|
|
||||||
Usage.increment("end_tag_params") if end_tag_params && !end_tag_params.empty?
|
|
||||||
|
|
||||||
return false if end_tag_name == block_delimiter
|
return false if end_tag_name == block_delimiter
|
||||||
raise_tag_never_closed(block_name) unless end_tag_name
|
raise_tag_never_closed(block_name) unless end_tag_name
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ module Liquid
|
|||||||
if start_obj.respond_to?(:evaluate) || end_obj.respond_to?(:evaluate)
|
if start_obj.respond_to?(:evaluate) || end_obj.respond_to?(:evaluate)
|
||||||
new(start_obj, end_obj)
|
new(start_obj, end_obj)
|
||||||
else
|
else
|
||||||
Usage.increment('range_float') if start_obj.is_a?(Float) || end_obj.is_a?(Float)
|
|
||||||
|
|
||||||
start_obj.to_i..end_obj.to_i
|
start_obj.to_i..end_obj.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -55,24 +55,4 @@ class BlockTest < Minitest::Test
|
|||||||
assert_equal buf.object_id, output.object_id
|
assert_equal buf.object_id, output.object_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_instrument_for_bug_1346
|
|
||||||
calls = []
|
|
||||||
Liquid::Usage.stub(:increment, ->(name) { calls << name }) do
|
|
||||||
Liquid::Template.parse("{% for i in (1..2) %}{{ i }}{% endfor {% foo %}")
|
|
||||||
end
|
|
||||||
assert_equal(["end_tag_params"], calls)
|
|
||||||
|
|
||||||
calls = []
|
|
||||||
Liquid::Usage.stub(:increment, ->(name) { calls << name }) do
|
|
||||||
Liquid::Template.parse("{% for i in (1..2) %}{{ i }}{% endfor test %}")
|
|
||||||
end
|
|
||||||
assert_equal(["end_tag_params"], calls)
|
|
||||||
|
|
||||||
calls = []
|
|
||||||
Liquid::Usage.stub(:increment, ->(name) { calls << name }) do
|
|
||||||
Liquid::Template.parse("{% for i in (1..2) %}{{ i }}{% endfor %}")
|
|
||||||
end
|
|
||||||
assert_equal([], calls)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,33 +31,15 @@ class ExpressionTest < Minitest::Test
|
|||||||
assert_equal(3..4, parse_and_eval(" ( 3 .. 4 ) "))
|
assert_equal(3..4, parse_and_eval(" ( 3 .. 4 ) "))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_instrument_range_float
|
|
||||||
assert_usage_increment('range_float') do
|
|
||||||
parse("(1.0..2.0)")
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_usage_increment('range_float') do
|
|
||||||
parse("(1.0..2)")
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_usage_increment('range_float', times: 0) do
|
|
||||||
parse("(1..2)")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def parse(markup)
|
def parse_and_eval(markup, **assigns)
|
||||||
if Liquid::Template.error_mode == :strict
|
if Liquid::Template.error_mode == :strict
|
||||||
p = Liquid::Parser.new(markup)
|
p = Liquid::Parser.new(markup)
|
||||||
markup = p.expression
|
markup = p.expression
|
||||||
p.consume(:end_of_string)
|
p.consume(:end_of_string)
|
||||||
end
|
end
|
||||||
Liquid::Expression.parse(markup)
|
expression = Liquid::Expression.parse(markup)
|
||||||
end
|
|
||||||
|
|
||||||
def parse_and_eval(markup, **assigns)
|
|
||||||
expression = parse(markup)
|
|
||||||
context = Liquid::Context.new(assigns)
|
context = Liquid::Context.new(assigns)
|
||||||
context.evaluate(expression)
|
context.evaluate(expression)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user