require 'test/unit'
class Test::Unit::TestCase
def assert_vooly(vooly, output, param=" ")
IO.popen("vooly_test #{param.to_s.upcase[0..0]}", "w+") { |io|
io.write vooly
io.close_write
assert_equal output, io.read
}
end
end
class VoolyCTest < Test::Unit::TestCase
def test_empty
assert_vooly "", ".: '(null)'\n"
end
DOCUMENT = <>
<>
<< ho >>
>>
>>
EOF
def test_parse
assert_vooly DOCUMENT, <
Business as usual.
HTML
*: '
This is just plain, '
<: 'em'
*: 'stupid'
>: '(null)'
*: ' HTML.
Business as usual.
'
.: '(null)'
OUTPUT
end
def test_nested
assert_vooly '<>>>', <: '(null)'
>: '(null)'
.: '(null)'
OUTPUT
assert_vooly "< >>>>>\n", <'
>: '(null)'
>: '(null)'
*: '>
'
.: '(null)'
OUTPUT
end
def test_multiple
assert_vooly "<> >>> >>>", <>'
>: '(null)'
>: '(null)'
*: '>'
.: '(null)'
OUTPUT
assert_vooly "<<> >>> >>>", <>'
>: '(null)'
>: '(null)'
.: '(null)'
OUTPUT
assert_vooly "<<> >>>", <>'
>: '(null)'
.: '(null)'
OUTPUT
assert_vooly "<<<> >>> >>>>", <> >>>'
>: '(null)'
.: '(null)'
OUTPUT
end
end
unless File.executable?("vooly_test")
VoolyCTest.instance_eval do
instance_methods.grep(/^test_/) { |t|
warn "Skipping VoolyCTest#{t}, no vooly_test available."
undef_method t
}
define_method(:default_test) { }
end
end