Sha256: 603f5e726d2058979ad5f090891964c4fc319be76b422c3ea844db9a20b7e086

Contents?: true

Size: 1.57 KB

Versions: 11

Compression:

Stored size: 1.57 KB

Contents

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

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
liquid-4.0.4 test/unit/regexp_unit_test.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/liquid-4.0.3/test/unit/regexp_unit_test.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/liquid-4.0.3/test/unit/regexp_unit_test.rb
liquid-4.0.3 test/unit/regexp_unit_test.rb
liquid-4.0.2 test/unit/regexp_unit_test.rb
liquid-4-0-2-4.0.2 test/unit/regexp_unit_test.rb
liquid-4.0.1 test/unit/regexp_unit_test.rb
liquid-4.0.0 test/unit/regexp_unit_test.rb
liquid-4.0.0.rc3 test/unit/regexp_unit_test.rb
liquid-4.0.0.rc2 test/unit/regexp_unit_test.rb
liquid-4.0.0.rc1 test/unit/regexp_unit_test.rb