Files
liquid/test/unit/regexp_unit_test.rb
Ken Dreyer ee4295c889 tests: switch to minitest
Ruby 1.9+ uses Minitest as the backend for Test::Unit. As of Minitest 5,
the shim has broken some compatibility with Test::Unit::TestCase in some
scenarios.

Adjusts the test suite to support Minitest 5's syntax.

Minitest versions 4 and below do not support the newer Minitest::Test
class that arrived in version 5. For that case, use the
MiniTest::Unit::TestCase class as a fallback

Conflicts:
	test/integration/tags/for_tag_test.rb
	test/test_helper.rb
2014-07-28 16:36:38 +00:00

45 lines
1.6 KiB
Ruby

require 'test_helper'
class RegexpUnitTest < Minitest::Test
include Liquid
def test_empty
assert_equal [], ''.scan(QuotedFragment)
end
def test_quote
assert_equal ['"arg 1"'], '"arg 1"'.scan(QuotedFragment)
end
def test_words
assert_equal ['arg1', 'arg2'], 'arg1 arg2'.scan(QuotedFragment)
end
def test_tags
assert_equal ['<tr>', '</tr>'], '<tr> </tr>'.scan(QuotedFragment)
assert_equal ['<tr></tr>'], '<tr></tr>'.scan(QuotedFragment)
assert_equal ['<style', 'class="hello">', '</style>'], %|<style class="hello">' </style>|.scan(QuotedFragment)
end
def test_double_quoted_words
assert_equal ['arg1', 'arg2', '"arg 3"'], 'arg1 arg2 "arg 3"'.scan(QuotedFragment)
end
def test_single_quoted_words
assert_equal ['arg1', 'arg2', "'arg 3'"], 'arg1 arg2 \'arg 3\''.scan(QuotedFragment)
end
def test_quoted_words_in_the_middle
assert_equal ['arg1', 'arg2', '"arg 3"', 'arg4'], 'arg1 arg2 "arg 3" arg4 '.scan(QuotedFragment)
end
def test_variable_parser
assert_equal ['var'], 'var'.scan(VariableParser)
assert_equal ['var', 'method'], 'var.method'.scan(VariableParser)
assert_equal ['var', '[method]'], 'var[method]'.scan(VariableParser)
assert_equal ['var', '[method]', '[0]'], 'var[method][0]'.scan(VariableParser)
assert_equal ['var', '["method"]', '[0]'], 'var["method"][0]'.scan(VariableParser)
assert_equal ['var', '[method]', '[0]', 'method'], 'var[method][0].method'.scan(VariableParser)
end
end # RegexpTest