mirror of
https://github.com/Shopify/liquid.git
synced 2025-09-21 00:00:32 -04:00
Pop the for_stack register in an ensure
This commit is contained in:
parent
863e8968f0
commit
648a4888af
@ -132,8 +132,9 @@ module Liquid
|
||||
end
|
||||
end
|
||||
|
||||
for_stack.pop
|
||||
result
|
||||
ensure
|
||||
for_stack.pop
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -1,24 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ErrorDrop < Liquid::Drop
|
||||
def standard_error
|
||||
raise Liquid::StandardError, 'standard error'
|
||||
end
|
||||
|
||||
def argument_error
|
||||
raise Liquid::ArgumentError, 'argument error'
|
||||
end
|
||||
|
||||
def syntax_error
|
||||
raise Liquid::SyntaxError, 'syntax error'
|
||||
end
|
||||
|
||||
def exception
|
||||
raise Exception, 'exception'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class ErrorHandlingTest < Minitest::Test
|
||||
include Liquid
|
||||
|
||||
|
@ -388,4 +388,14 @@ HERE
|
||||
assert_template_result(expected, template, loader_assigns)
|
||||
assert_template_result(expected, template, array_assigns)
|
||||
end
|
||||
|
||||
def test_for_cleans_up_registers
|
||||
context = Context.new(ErrorDrop.new)
|
||||
|
||||
assert_raises(StandardError) do
|
||||
Liquid::Template.parse('{% for i in (1..2) %}{{ standard_error }}{% endfor %}').render!(context)
|
||||
end
|
||||
|
||||
assert context.registers[:for_stack].empty?
|
||||
end
|
||||
end
|
||||
|
@ -88,3 +88,22 @@ class ThingWithToLiquid
|
||||
'foobar'
|
||||
end
|
||||
end
|
||||
|
||||
class ErrorDrop < Liquid::Drop
|
||||
def standard_error
|
||||
raise Liquid::StandardError, 'standard error'
|
||||
end
|
||||
|
||||
def argument_error
|
||||
raise Liquid::ArgumentError, 'argument error'
|
||||
end
|
||||
|
||||
def syntax_error
|
||||
raise Liquid::SyntaxError, 'syntax error'
|
||||
end
|
||||
|
||||
def exception
|
||||
raise Exception, 'exception'
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user