Sha256: 10d6c62020fb13d752e985c47e99606a6f7fd85b4f88daf2c3de9e9a421cee09

Contents?: true

Size: 894 Bytes

Versions: 23

Compression:

Stored size: 894 Bytes

Contents

$:.unshift File.dirname(__FILE__) + "/../../lib"

require 'test/unit'
require 'syntax'

class TokenizerTestCase < Test::Unit::TestCase
  def self.syntax( type )
    class_eval <<-EOF
      def setup
        @tokenizer = Syntax.load(#{type.inspect})
      end
    EOF
  end

  def default_test
  end

  private

    attr_reader :tokenizer

    def tokenize( string )
      @tokens = []
      @tokenizer.tokenize( string ) { |tok| @tokens << tok }
    end

    def assert_next_token(group, lexeme, instruction=:none)
      assert false, "no tokens in stack" if @tokens.nil? or @tokens.empty?
      assert_equal [group, lexeme, instruction],
        [@tokens.first.group, @tokens.first, @tokens.shift.instruction]
    end

    def assert_no_next_token
      assert @tokens.empty?
    end

    def skip_token( n=1 )
      n.times { @tokens.shift } unless @tokens.nil? || @tokens.empty?
    end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
syntax-1.1.0 test/syntax/tokenizer_testcase.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/syntax-1.0.0/test/syntax/tokenizer_testcase.rb
syntax-1.0.0 test/syntax/tokenizer_testcase.rb
typo-3.99.0 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-3.99.1 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-3.99.2 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-3.99.3 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-3.99.4 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-4.0.0 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-4.0.1 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-4.0.2 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-4.0.3 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-4.1.1 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-5.0.2 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-5.0.1 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-4.1 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-5.0.3.98.1 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-5.0 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-5.0.3.98 vendor/syntax/test/syntax/tokenizer_testcase.rb
typo-5.1.2 vendor/syntax/test/syntax/tokenizer_testcase.rb