Sha256: 4d28c1ef9dfb602fb64cecc7568da07655e7d7a493b4bd260aa7ffdb8c97cdf3

Contents?: true

Size: 1.43 KB

Versions: 28

Compression:

Stored size: 1.43 KB

Contents

require "test/unit"
require "../../../lib/pdoc/parser/fragment"
require "../../../lib/pdoc/error"

class TestFragment < Test::Unit::TestCase
  
  def test_normalize_empty_fragment
    fragment =<<EOF
    /**
    *
    *
    **/
EOF
    fragment = PDoc::Fragment.new(fragment, 0)
    lines = fragment.normalize
    assert_equal("", lines[0])
    assert_equal("", lines[1])
    assert_equal("", lines.last)
  end
  
  def test_normalize_basic_fragment
    fragment =<<EOF
    /**
    * foo
    *   bar
    **/
EOF
    fragment = PDoc::Fragment.new(fragment, 0)
    lines = fragment.normalize
    assert_equal("", lines[0])
    assert_equal("foo", lines[1])
    assert_equal("  bar", lines[2])
    assert_equal("", lines.last)
  end
  
  def test_normalize_broken_fragment
    fragment =<<EOF
    /**
    * foo
    *bar
    **/
EOF
    assert_raise PDoc::Fragment::InconsistentPrefixError do
      PDoc::Fragment.new(fragment, 0).normalize
    end
  end
  
  def test_empty_prefix
    fragment =<<EOF
/**
foo
  bar
**/
EOF
    fragment = PDoc::Fragment.new(fragment, 0)
    assert_equal("", fragment.prefix)
  end
  
  def test_whitespace_prefix
    fragment =<<EOF
    /**
  foo
    bar
  **/
EOF
    fragment = PDoc::Fragment.new(fragment, 0)
    assert_equal("  ", fragment.prefix)
  end

  def test_mixed_prefix
    fragment =<<EOF
/**
 * foo
 *   bar
 **/
EOF
    fragment = PDoc::Fragment.new(fragment, 0)
    assert_equal(" * ", fragment.prefix)
  end 
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
distil-0.14.4 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.3 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.2 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.2.a vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.1 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.1.a vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.0 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.0.i vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.0.h vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.0.g vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.0.d vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.0.c vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.14.0.b vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.13.6 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.13.5 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.13.4 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.13.3 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.13.2 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.13.1 vendor/pdoc/test/unit/parser/test_fragment.rb
distil-0.13.0 vendor/pdoc/test/unit/parser/test_fragment.rb