Sha256: 06198b1ac244fde25bbdae4075afb907679d6b7be5796c7cb0c9cbd54be43e71

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rockit-0.7.1 tests/unit/rockit/prettyprint/utest_box.rb