File: test_source_comment.rb

package info (click to toggle)
ruby-whitequark-parser 3.3.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,828 kB
  • sloc: yacc: 40,699; ruby: 20,395; makefile: 12; sh: 8
file content (36 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

require 'helper'

class TestSourceComment < Minitest::Test
  def setup
    @buf = Parser::Source::Buffer.new('(string)',
      source: "# foo\n=begin foo\nbar\n=end baz\n")
  end

  def range(s, e)
    Parser::Source::Range.new(@buf, s, e)
  end

  def test_initialize
    comment = Parser::Source::Comment.new(range(0, 5))
    assert comment.frozen?
  end

  def test_text
    comment = Parser::Source::Comment.new(range(0, 5))
    assert_equal '# foo', comment.text
  end

  def test_inline
    comment = Parser::Source::Comment.new(range(0, 5))
    assert_equal :inline, comment.type
    assert comment.inline?
  end

  def test_document
    comment = Parser::Source::Comment.new(range(6, 25))
    assert_equal :document, comment.type
    assert comment.document?
  end
end