class TestInlineTokenizer

Public Instance Methods

ok(e, str) click to toggle source
# File vendor/qwik/lib/qwik/tokenizer-inline.rb, line 187
def ok(e, str)
  ok_eq(e, Qwik::InlineTokenizer.tokenize(str))
end
test_common() click to toggle source
# File vendor/qwik/lib/qwik/tokenizer-inline.rb, line 191
def test_common
  ok([], '')
  ok(['t'], 't')

  # test em, strong and del
  ok([:"''", 't', :"''"], "''t''")
  ok([:"'''", 't', :"'''"], "'''t'''")
  ok(["'"], "'")
  ok(["'", 't'], "'t")
  ok([:'==', 't', :'=='], '==t==')
  ok(['='], '=')
  ok(['=', 't'], '=t')

  # reference
  ok([[:ref, 't']], '[[t]]')
  ok([[:ref, 's|t']], '[[s|t]]')
  ok([']'], ']')
  ok(['[', 't', ']'], '[t]')
  ok([[:ref, 'C++']], '[[C++]]')

  # plugin
  ok([[:plugin, 't']], '{{t}}')
  ok([[:plugin, 't', 'a']], '{{t(a)}}')
  ok(['{', 't', '}'], '{t}')

  # url
  ok([[:url, 'http://e.com/']], 'http://e.com/')
  ok(['t ', [:url, 'http://e.com/'], ' a'], 't http://e.com/ a')
  ok([[:url, 'https://e.com/']], 'https://e.com/')

  # test_all
  ok(['a ', :"''", 'b', :"''", ' ', :"'''", 'c', :"'''", ' ',
           :==, 'd', :==, ' ', [:ref, 'e'], ' ',
           [:plugin, 'f'], ' ', [:url, 'http://e.com/'], ' g'],
         "a ''b'' '''c''' ==d== [[e]] {{f}} http://e.com/ g")

  # test_wiliki_style
  ok(['[', 'u', ']'], '[u]')
  ok([[:ref, 't|u']], '[u t]')
  ok([[:ref, 't|http://e.com/']], '[http://e.com/ t]')

  # test_ref
  ok([[:ref, 't|u']], '[[t|u]]')
  ok([[:ref, 't']], '[[t]]')
  ok([[:ref, '.attach']], '[[.attach]]')
  ok([[:ref, '.attach/t.txt']], '[[.attach/t.txt]]')
  ok([[:ref, '.attach/s t.txt']], '[[.attach/s t.txt]]')

  ok([[:ref, "\203|\203X\203^\201["]], '[[ポスター]]')
  ok(["\202\240", [:ref, "\203|\203X\203^\201["], "\202\240"],
         'あ[[ポスター]]あ')

  # test_bug
  ok([:"'''", 't', :"''"], "'''t''")

  # test_sjis_bug
  ok_eq("\226]", '望')
  ok(["\226]"], '望')
  ok([[:ref, "\226]"]], '[[望]]')
end