Skip to content

Commit

Permalink
[Haml] Clean up the encoding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Sep 29, 2010
1 parent e2907a9 commit 6a9570b
Showing 1 changed file with 22 additions and 169 deletions.
191 changes: 22 additions & 169 deletions test/haml/engine_test.rb
Expand Up @@ -1701,15 +1701,23 @@ def test_same_coding_comment_as_encoding
HAML
end

def test_different_coding_comment_than_encoding
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# coding: ibm866
%p bâr
%p föö
HAML
def test_coding_comments
assert_valid_encoding_comment("-# coding: ibm866")
assert_valid_encoding_comment("-# CodINg: IbM866")
assert_valid_encoding_comment("-#coding:ibm866")
assert_valid_encoding_comment("-# CodINg= ibm866")
assert_valid_encoding_comment("-# foo BAR FAOJcoding: ibm866")
assert_valid_encoding_comment("-# coding: ibm866 ASFJ (&(&#!$")
assert_valid_encoding_comment("-# -*- coding: ibm866")
assert_valid_encoding_comment("-# coding: ibm866 -*- coding: blah")
assert_valid_encoding_comment("-# -*- coding: ibm866 -*-")
assert_valid_encoding_comment("-# -*- encoding: ibm866 -*-")
assert_valid_encoding_comment('-# -*- coding: "ibm866" -*-')
assert_valid_encoding_comment("-#-*-coding:ibm866-*-")
assert_valid_encoding_comment("-#-*-coding:ibm866-*-")
assert_valid_encoding_comment("-# -*- foo: bar; coding: ibm866; baz: bang -*-")
assert_valid_encoding_comment("-# foo bar coding: baz -*- coding: ibm866 -*-")
assert_valid_encoding_comment("-# -*- coding: ibm866 -*- foo bar coding: baz")
end

def test_different_coding_than_system
Expand All @@ -1719,176 +1727,21 @@ def test_different_coding_than_system
%p тАЬ
HAML
end
end

def test_case_insensitive_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# CodINg: IbM866
%p bâr
%p föö
HAML
end

def test_whitespace_insensitive_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-#coding:ibm866
%p bâr
%p föö
HAML
end

def test_equals_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# CodINg= ibm866
%p bâr
%p föö
HAML
end

def test_prefixed_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# foo BAR FAOJcoding: ibm866
%p bâr
%p föö
HAML
end

def test_suffixed_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# coding: ibm866 ASFJ (&(&#!$
%p bâr
%p föö
HAML
end

def test_emacs_prefixed_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# -*- coding: ibm866
%p bâr
%p föö
HAML
end

def test_emacs_suffixed_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# coding: ibm866 -*- coding: blah
%p bâr
%p föö
HAML
end

def test_emacs_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# -*- coding: ibm866 -*-
%p bâr
%p föö
HAML
end

def test_emacs_encoding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# -*- encoding: ibm866 -*-
%p bâr
%p föö
HAML
end

def test_quoted_emacs_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# -*- coding: "ibm866" -*-
%p bâr
%p föö
HAML
end

def test_whitespace_insensitive_emacs_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-#-*-coding:ibm866-*-
%p bâr
%p föö
HAML
end

def test_whitespace_insensitive_emacs_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-#-*-coding:ibm866-*-
%p bâr
%p föö
HAML
end

def test_one_of_several_emacs_comments
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# -*- foo: bar; coding: ibm866; baz: bang -*-
%p bâr
%p föö
HAML
end

def test_prefixed_emacs_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# foo bar coding: baz -*- coding: ibm866 -*-
%p bâr
%p föö
HAML
end
private

def test_suffixed_emacs_coding_comment
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
def assert_valid_encoding_comment(comment)
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
<p>bâr</p>
<p>föö</p>
HTML
-# -*- coding: ibm866 -*- foo bar coding: baz
#{comment}
%p bâr
%p föö
HAML
end

end

private

def assert_converts_template_properly
engine = Haml::Engine.new(<<HAML.encode("iso-8859-1"), :encoding => "utf-8")
%p bâr
Expand Down

0 comments on commit 6a9570b

Please sign in to comment.