require 'test/unit' require 'rockit/prettyprint/box' include Rockit::PrettyPrint class UTestBox < Test::Unit::TestCase def setup @h = Box::H.new(1, "a") @h1 = Box::H.new(1, "a", "b") @h2 = Box::H.new(2, "a", "b") @h3 = Box::H.new(3, "a", "b", "c") @v = Box::V.new("a", "2 2", "c") @e = Box::Epsilon.new("x", " ", ":=") end def test_01_creation assert_kind_of(Box::H, @h) assert_equal(1, @h.num_spaces) assert_equal(["a"], @h.elements) assert_kind_of(Box::H, @h3) assert_equal(3, @h3.num_spaces) assert_equal(["a", "b", "c"], @h3.elements) assert_kind_of(Box::V, @v) assert_equal(["a", "2 2", "c"], @v.elements) assert_kind_of(Box::Epsilon, @e) end def test_02_render assert_equal("a", @h.render) assert_equal("a b", @h1.render) assert_equal("a b", @h2.render) assert_equal("a b c", @h3.render) assert_equal("a\n2 2\nc", @v.render) assert_equal("x :=", @e.render) end def test_03_prepend p = Box::Prepend["#", "A comment"] assert_equal("# A comment", p.render) end end