mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
Proper warning support
This commit is contained in:
@@ -14,6 +14,12 @@ Rake::TestTask.new(:base_test) do |t|
|
|||||||
t.verbose = false
|
t.verbose = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'run test suite with warn error mode'
|
||||||
|
task :warn_test do
|
||||||
|
ENV['LIQUID_PARSER_MODE'] = 'warn'
|
||||||
|
Rake::Task['base_test'].invoke
|
||||||
|
end
|
||||||
|
|
||||||
desc 'runs test suite with both strict and lax parsers'
|
desc 'runs test suite with both strict and lax parsers'
|
||||||
task :test do
|
task :test do
|
||||||
ENV['LIQUID_PARSER_MODE'] = 'lax'
|
ENV['LIQUID_PARSER_MODE'] = 'lax'
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
|
context.errors.concat(@warnings) if @warnings
|
||||||
context.registers[:for] ||= Hash.new(0)
|
context.registers[:for] ||= Hash.new(0)
|
||||||
|
|
||||||
collection = context[@collection_name]
|
collection = context[@collection_name]
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
context.errors += @warnings if @warnings
|
context.errors.concat(@warnings) if @warnings
|
||||||
context.stack do
|
context.stack do
|
||||||
@blocks.each do |block|
|
@blocks.each do |block|
|
||||||
if block.evaluate(context)
|
if block.evaluate(context)
|
||||||
|
|||||||
@@ -79,6 +79,13 @@ class ErrorHandlingTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_warnings
|
||||||
|
template = Liquid::Template.parse('{% if ~~~ %}derp{% else %}wat{% endif %}', :error_mode => :warn)
|
||||||
|
assert_equal 'wat', template.render
|
||||||
|
assert_equal 1, template.errors.size
|
||||||
|
assert_equal 'Unexpected character ~.', template.errors.first.message
|
||||||
|
end
|
||||||
|
|
||||||
# Liquid should not catch Exceptions that are not subclasses of StandardError, like Interrupt and NoMemoryError
|
# Liquid should not catch Exceptions that are not subclasses of StandardError, like Interrupt and NoMemoryError
|
||||||
def test_exceptions_propagate
|
def test_exceptions_propagate
|
||||||
assert_raise Exception do
|
assert_raise Exception do
|
||||||
|
|||||||
Reference in New Issue
Block a user