Sha256: 4573cf15afafa07e68636355f0b4c2f08d76ebdd579f0ad8b1b4a0cb341fb944

Contents?: true

Size: 687 Bytes

Versions: 6

Compression:

Stored size: 687 Bytes

Contents

# encoding: binary

require 'helper'

class TestEncoding < MiniTest::Unit::TestCase
  def recognize(string)
    Parser::Source::Buffer.recognize_encoding(string)
  end

  if defined?(Encoding)
    def test_default
      assert_equal Encoding::BINARY, recognize("foobar")
    end

    def test_bom
      assert_equal Encoding::UTF_8, recognize("\xef\xbb\xbffoobar")
    end

    def test_magic_comment
      assert_equal Encoding::KOI8_R, recognize("# coding:koi8-r\nfoobar")
    end

    def test_shebang
      assert_equal Encoding::KOI8_R, recognize("#!/bin/foo\n# coding:koi8-r\nfoobar")
    end

    def test_empty
      assert_equal Encoding::UTF_8, recognize("")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parser-1.3.3 test/test_encoding.rb
parser-1.3.2 test/test_encoding.rb
parser-1.3.1 test/test_encoding.rb
parser-1.3.0 test/test_encoding.rb
parser-1.2.0 test/test_encoding.rb
parser-1.1.0 test/test_encoding.rb