Sha256: 4001d3c9b4943b4ed51f234b15ff8e0db23ae0485f3396308ee94ebe7b27e81c

Contents?: true

Size: 1.51 KB

Versions: 41

Compression:

Stored size: 1.51 KB

Contents

# coding: utf-8

require 'helper.rb'

module BibTeX
  class LexerTest < Minitest::Spec

    it 'correctly scans a string literal' do
      assert_equal Lexer.new.analyse(%q(@string{ x = "foo" })).symbols, [:AT,:STRING,:LBRACE,:NAME,:EQ,:STRING_LITERAL,:RBRACE,false]
    end

    it 'strips line breaks by default' do
      Lexer.new.analyse(%Q(@string{ x = "foo\nbar" })).stack[-3].must_be :==,
        [:STRING_LITERAL, 'foo bar']
    end

    it 'strips whitespace after line breaks by default' do
      Lexer.new.analyse(%Q(@string{ x = "foo\n    bar" })).stack[-3].must_be :==,
        [:STRING_LITERAL, 'foo bar']
    end

    it 'matches KEY tokens' do
      Lexer.new.analyse("@misc{foo, }").symbols.must_be :==, [:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
    end

    it 'matches KEY tokens with non-ascii characters' do
      Lexer.new.analyse("@misc{löwe, }").symbols.must_be :==, [:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
    end

    it 'matches KEY tokens after whitespace' do
      Lexer.new.analyse("@misc{  foo, }").symbols.must_be :==, [:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
    end

    it "doesn't start a comment for types starting with but not equal @comment" do
      Lexer.new.analyse("@commentary{staudinger, }").symbols.must_be :==, [:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
    end

    it "doesn't start a preamble for types starting with but not equal @preamble" do
      Lexer.new.analyse("@preamblestring{ preamble }").symbols.must_be :==, [:AT, :NAME, :LBRACE, :NAME, :RBRACE, false]
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
bibtex-ruby-4.4.7 test/bibtex/test_lexer.rb
bibtex-ruby-4.4.6 test/bibtex/test_lexer.rb
bibtex-ruby-4.4.5 test/bibtex/test_lexer.rb
bibtex_to_scrapbox-0.2.0 gems/gems/bibtex-ruby-4.4.4/test/bibtex/test_lexer.rb
bibtex_to_scrapbox-0.1.0 gems/gems/bibtex-ruby-4.4.4/test/bibtex/test_lexer.rb
bibtex-ruby-4.4.4 test/bibtex/test_lexer.rb
bibtex-ruby-4.4.3 test/bibtex/test_lexer.rb
bibtex-ruby-4.4.2 test/bibtex/test_lexer.rb
bibtex-ruby-4.4.1 test/bibtex/test_lexer.rb
bibtex-ruby-4.4.0 test/bibtex/test_lexer.rb
bibtex-ruby-4.3.0 test/bibtex/test_lexer.rb
bibtex-ruby-4.2.0 test/bibtex/test_lexer.rb
bibtex-ruby-4.1.2 test/bibtex/test_lexer.rb
bibtex-ruby-4.1.1 test/bibtex/test_lexer.rb
bibtex-ruby-4.1.0 test/bibtex/test_lexer.rb
bibtex-ruby-4.0.16 test/bibtex/test_lexer.rb
bibtex-ruby-4.0.15 test/bibtex/test_lexer.rb
bibtex-ruby-4.0.14 test/bibtex/test_lexer.rb
bibtex-ruby-4.0.13 test/bibtex/test_lexer.rb
bibtex-ruby-4.0.12 test/bibtex/test_lexer.rb