Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (51 sloc) 1.284 kb
require 'test/unit'
class TestPedantic < Test::Unit::TestCase
Lib = File.expand_path("../../lib/language_sniffer", __FILE__)
def file(name)
File.read(File.join(Lib, name))
end
def test_language_names_are_sorted
languages = []
file("languages.yml").lines.each do |line|
if line =~ /^(\w+):$/
languages << $1
end
end
assert_sorted languages
end
def test_extensions_are_sorted
extensions = nil
file("languages.yml").lines.each do |line|
if line =~ /^ extensions:$/
extensions = []
elsif extensions && line =~ /^ - \.(\w+)$/
extensions << $1
else
assert_sorted extensions if extensions
extensions = nil
end
end
end
def test_filenames_are_sorted
filenames = nil
file("languages.yml").lines.each do |line|
if line =~ /^ filenames:$/
filenames = []
elsif filenames && line =~ /^ - \.(\w+)$/
filenames << $1
else
assert_sorted filenames if filenames
filenames = nil
end
end
end
def assert_sorted(list)
previous = nil
list.each do |item|
if previous && previous > item
flunk "#{previous} should come after #{item}"
end
previous = item
end
end
end
Jump to Line
Something went wrong with that request. Please try again.