test/test_compiler.rb in review-1.7.2 vs test/test_compiler.rb in review-2.0.0.beta1
- old
+ new
@@ -2,45 +2,90 @@
require 'test_helper'
require 'review/compiler'
require 'review/book'
require 'review/latexbuilder'
+require 'review/htmlbuilder'
class CompilerTest < Test::Unit::TestCase
include ReVIEW
def setup
- @builder = LATEXBuilder.new()
- @c = Compiler.new(@builder)
+ @builder = HTMLBuilder.new()
+ @param = {
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
+ "inencoding" => "UTF-8",
+ "outencoding" => "UTF-8",
+ "subdirmode" => nil,
+ "stylesheet" => nil, # for HTMLBuilder
+ }
+ ReVIEW.book.param = @param
+ @compiler = ReVIEW::Compiler.new(@builder)
+ @chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
+ location = Location.new(nil, nil)
+ @builder.bind(@compiler, @chapter, location)
+
+ def @compiler.compile_command(name, args, lines, node)
+ args
+ end
+
end
def test_parse_args
- args = @c.__send__(:parse_args, "[foo][bar]")
- assert_equal ["foo","bar"], args
+ args = compile_blockelem("//dummy[foo][bar]\n", false)
+ assert_equal ["foo","bar"], args.parse_args(:doc,:doc)
end
def test_parse_args_with_brace1
- args = @c.__send__(:parse_args, "[fo[\\][\\]o][bar]")
- assert_equal ["fo[][]o","bar"], args
+ args = compile_blockelem("//dummy[fo[\\][\\]o][bar]", false)
+ assert_equal ["fo[][]o","bar"], args.parse_args(:doc, :doc)
end
def test_parse_args_with_brace2
- args = @c.__send__(:parse_args, "[f\\]o\\]o][bar]")
- assert_equal ["f]o]o","bar"], args
+ args = compile_blockelem("//dummy[f\\]o\\]o][bar]", false)
+ assert_equal ["f]o]o","bar"], args.parse_args(:doc, :doc)
end
def test_parse_args_with_backslash
- args = @c.__send__(:parse_args, "[foo][bar\\buz]")
- assert_equal ["foo","bar\\buz"], args
+ args = compile_blockelem("//dummy[foo][bar\\buz]", false)
+ assert_equal ["foo","bar\\buz"], args.parse_args(:doc, :doc)
end
def test_parse_args_with_backslash2
- args = @c.__send__(:parse_args, "[foo][bar\\#\\[\\!]")
- assert_equal ["foo","bar\\#\\[\\!"], args
+ args = compile_blockelem("//dummy[foo][bar\\#\\[\\!]", false)
+ assert_equal ["foo","bar\\#\\[\\!"], args.parse_args(:doc, :doc)
end
def test_parse_args_with_backslash3
- args = @c.__send__(:parse_args, "[foo][bar\\\\buz]")
- assert_equal ["foo","bar\\buz"], args
+ args = compile_blockelem("//dummy[foo][bar\\\\buz]", false)
+ assert_equal ["foo","bar\\buz"], args.parse_args(:doc, :doc)
+ end
+
+ def test_compile_inline
+ def @compiler.inline_ruby(*args)
+ return args
+ end
+ args = compile_inline("@<ruby>{abc}",false)
+ assert_equal "abc", args.content[0].content.to_doc
+ end
+
+ def test_inline_ruby
+# def @compiler.inline_ruby(*args)
+# return args
+# end
+ args = compile_inline("@<ruby>{foo,bar}",false)
+ assert_equal "foo", args.content[0].content[0].to_doc
+ assert_equal "bar", args.content[0].content[1].to_doc
+ args = compile_inline("@<ruby>{foo\\,\\,,\\,bar\\,buz}", false)
+ assert_equal "foo,,", args.content[0].content[0].to_doc
+ assert_equal ",bar,buz", args.content[0].content[1].to_doc
+ end
+
+ def test_compile_inline_backslash
+ def @compiler.inline_dummy(*args)
+ return args
+ end
+ args = compile_inline("@<dummy>{abc\\d\\#a}", false)
+ assert_equal "abc\\d\\#a", args.content[0].content.to_doc
end
end