class TestPlugin

Public Instance Methods

ok_en(e, s) click to toggle source
# File vendor/qwik/lib/qwik/parse-plugin.rb, line 192
def ok_en(e, s)
  ok_eq(e, Qwik::Plugin.encode(s))
end
ok_re(expected, paras, num) click to toggle source
# File vendor/qwik/lib/qwik/parse-plugin.rb, line 136
def ok_re(expected, paras, num)
  nparas = Qwik::Plugin.rewrite(paras, :p, num) {|plugin|
    plugin << 'c'
    plugin
  }
  ok_eq(expected, nparas)
end
ok_sp(e, s) click to toggle source
# File vendor/qwik/lib/qwik/parse-plugin.rb, line 108
def ok_sp(e, s)
  ok_eq(e, Qwik::Plugin.split(s))
end
test_plugin_encode() click to toggle source
# File vendor/qwik/lib/qwik/parse-plugin.rb, line 196
    def test_plugin_encode
      ok_en("{{m}}
", [:plugin, {:method=>'m'}])
      ok_en("{{m}}
", [:plugin, {:method=>'m', :param=>''}])
      ok_en("{{m(p)}}
", [:plugin, {:method=>'m', :param=>'p'}])
      ok_en("{{m(p)

}}
", [:plugin, {:method=>'m', :param=>'p'}, ''])
      ok_en("{{m
c
}}
", [:plugin, {:method=>'m'}, 'c'])
      ok_en("{{m
c
}}
", [:plugin, {:method=>'m'}, "c
"])
      ok_en("{{m
c

}}
", [:plugin, {:method=>'m'}, "c

"])
      ok_en("{{m(p)
c
}}
", [:plugin, {:method=>'m', :param=>'p'}, 'c'])
      ok_en("{{m(p)
c
}}
", [:plugin, {:method=>'m', :param=>'p'}, "c
"])
    end
test_plugin_join() click to toggle source
# File vendor/qwik/lib/qwik/parse-plugin.rb, line 234
    def test_plugin_join
      ok_eq("a
{{p
c
}}
b
",
            Qwik::Plugin.join(["a
", "{{p
c
}}
", "b
"]))
    end
test_plugin_rewrite() click to toggle source
# File vendor/qwik/lib/qwik/parse-plugin.rb, line 144
    def test_plugin_rewrite
      ok_re(["{{p
c
}}
"],
            ['{{p}}'], 1)
      ok_re(['{{p}}'], ['{{p}}'], 2)
      ok_re(["a
", "{{p
c
}}
", "b
"],
            ["a
", "{{p}}
", "b
"], 1)
      ok_re(["a
", "{{p
c
}}
", "{{p}}
", "b
"],
            ["a
", "{{p}}
", "{{p}}
", "b
"], 1)
      ok_re(["{{p}}
", "{{p
c
}}
"],
            ["{{p}}
", '{{p}}'], 2)
      ok_re(["{{p
c
}}
", '{{q}}'],
            ["{{p}}
", '{{q}}'], 1)
      ok_re(["{{p}}
", '{{q}}'],
            ["{{p}}
", '{{q}}'], 2)
    end
test_plugin_split() click to toggle source
# File vendor/qwik/lib/qwik/parse-plugin.rb, line 112
    def test_plugin_split
      ok_sp([], '')
      ok_sp(['a'], 'a')
      ok_sp(['a
b'], 'a
b')
      ok_sp(['{{p}}'], '{{p}}')
      ok_sp(['a
', '{{p}}'], 'a
{{p}}')
      ok_sp(['a
', '{{p}}
', 'b'], 'a
{{p}}
b')
      ok_sp(['a
', '{{p
}}
', 'b'], 'a
{{p
}}
b')
    end