Sha256: 85038fbfb1ac5180cfa399f0719ea4382a14d1fc44341f4eca7a9c9d5723532d

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

require 'helper'

class TestDiagnosticEngine < MiniTest::Unit::TestCase
  def setup
    @buffer  = Parser::Source::Buffer.new('(source)')
    @buffer.source = 'foobar'

    @engine = Parser::Diagnostic::Engine.new

    @queue  = []
    @engine.consumer = lambda { |diag| @queue << diag }
  end

  def test_process_warnings
    warn = Parser::Diagnostic.new(:warning, "foo", @buffer, 1..2)
    @engine.process(warn)

    assert_equal [warn], @queue
  end

  def test_ignore_warnings
    @engine.ignore_warnings = true

    warn = Parser::Diagnostic.new(:warning, "foo", @buffer, 1..2)
    @engine.process(warn)

    assert_equal [], @queue
  end

  def test_all_errors_are_fatal
    @engine.all_errors_are_fatal = true

    error = Parser::Diagnostic.new(:error, "foo", @buffer, 1..2)

    assert_raises Parser::SyntaxError do
      @engine.process(error)
    end

    assert_equal [error], @queue
  end

  def test_all_errors_are_collected
    error = Parser::Diagnostic.new(:error, "foo", @buffer, 1..2)
    @engine.process(error)

    assert_equal [error], @queue
  end

  def test_fatal_error
    fatal = Parser::Diagnostic.new(:fatal, "foo", @buffer, 1..2)

    assert_raises Parser::SyntaxError do
      @engine.process(fatal)
    end

    assert_equal [fatal], @queue
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
parser-1.4.2 test/test_diagnostic_engine.rb
parser-1.4.1 test/test_diagnostic_engine.rb
parser-2.0.0.beta1 test/test_diagnostic_engine.rb
parser-1.4.0 test/test_diagnostic_engine.rb
parser-1.3.4 test/test_diagnostic_engine.rb
parser-1.3.3 test/test_diagnostic_engine.rb
parser-1.3.2 test/test_diagnostic_engine.rb
parser-1.3.1 test/test_diagnostic_engine.rb
parser-1.3.0 test/test_diagnostic_engine.rb
parser-1.2.0 test/test_diagnostic_engine.rb
parser-1.1.0 test/test_diagnostic_engine.rb
parser-1.0.1 test/test_diagnostic_engine.rb
parser-1.0.0 test/test_diagnostic_engine.rb
parser-0.9.2 test/test_diagnostic_engine.rb
parser-0.9.1 test/test_diagnostic_engine.rb
parser-0.9.0 test/test_diagnostic_engine.rb