1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Failing tests for a bug with errors within doubly-nested imports.

This commit is contained in:
Nathan Weizenbaum 2009-09-13 19:27:56 -07:00
parent f4380e655a
commit 3160111bf6
7 changed files with 44 additions and 10 deletions

View file

@ -180,12 +180,12 @@ SASS
end
def test_imported_exception
[nil, 2].each do |i|
[1, 2, 3].each do |i|
begin
Sass::Engine.new("@import bork#{i}", :load_paths => [File.dirname(__FILE__) + '/templates/']).render
rescue Sass::SyntaxError => err
assert_equal(2, err.sass_line)
assert_match(/bork#{i}\.sass$/, err.sass_filename)
assert_match(/(\/|^)bork#{i}\.sass$/, err.sass_filename)
assert_equal(err.sass_filename, err.sass_backtrace.first[:filename])
assert_equal(err.sass_line, err.sass_backtrace.first[:line])
@ -193,7 +193,7 @@ SASS
assert_nil(err.sass_backtrace[1][:filename])
assert_equal(1, err.sass_backtrace[1][:line])
assert_match(/bork#{i}\.sass:2$/, err.backtrace.first)
assert_match(/(\/|^)bork#{i}\.sass:2$/, err.backtrace.first)
assert_equal("(sass):1", err.backtrace[1])
else
assert(false, "Exception not raised for imported template: bork#{i}")
@ -201,6 +201,32 @@ SASS
end
end
def test_double_imported_exception
[1, 2, 3].each do |i|
begin
Sass::Engine.new("@import nested_bork#{i}", :load_paths => [File.dirname(__FILE__) + '/templates/']).render
rescue Sass::SyntaxError => err
assert_equal(2, err.sass_line)
assert_match(/(\/|^)bork#{i}\.sass$/, err.sass_filename)
assert_equal(err.sass_filename, err.sass_backtrace.first[:filename])
assert_equal(err.sass_line, err.sass_backtrace.first[:line])
assert_match(/(\/|^)nested_bork#{i}\.sass$/, err.sass_backtrace[1][:filename])
assert_equal(2, err.sass_backtrace[1][:line])
assert_nil(err.sass_backtrace[2][:filename])
assert_equal(1, err.sass_backtrace[2][:line])
assert_match(/(\/|^)bork#{i}\.sass:2$/, err.backtrace.first)
assert_match(/(\/|^)nested_bork#{i}\.sass:2$/, err.backtrace[1])
assert_equal("(sass):1", err.backtrace[2])
else
assert(false, "Exception not raised for imported template: bork#{i}")
end
end
end
def test_css_import
assert_equal("@import url(./fonts.css) screen;\n", render("@import url(./fonts.css) screen"))
assert_equal("@import \"./fonts.css\" screen;\n", render("@import \"./fonts.css\" screen"))

View file

@ -52,21 +52,21 @@ class SassPluginTest < Test::Unit::TestCase
end
def test_full_exception_handling
File.delete(tempfile_loc('bork'))
File.delete(tempfile_loc('bork1'))
Sass::Plugin.update_stylesheets
File.open(tempfile_loc('bork')) do |file|
assert_equal("/*\nSass::SyntaxError: Undefined variable: \"!bork\".\non line 2 of #{template_loc('bork')}\n\n1: bork\n2: :bork= !bork", file.read.split("\n")[0...6].join("\n"))
File.open(tempfile_loc('bork1')) do |file|
assert_equal("/*\nSass::SyntaxError: Undefined variable: \"!bork\".\non line 2 of #{template_loc('bork1')}\n\n1: bork\n2: :bork= !bork", file.read.split("\n")[0...6].join("\n"))
end
File.delete(tempfile_loc('bork'))
File.delete(tempfile_loc('bork1'))
end
def test_nonfull_exception_handling
Sass::Plugin.options[:full_exception] = false
File.delete(tempfile_loc('bork'))
File.delete(tempfile_loc('bork1'))
Sass::Plugin.update_stylesheets
assert_equal("/* Internal stylesheet error */", File.read(tempfile_loc('bork')))
File.delete(tempfile_loc('bork'))
assert_equal("/* Internal stylesheet error */", File.read(tempfile_loc('bork1')))
File.delete(tempfile_loc('bork1'))
Sass::Plugin.options[:full_exception] = true
end

View file

@ -0,0 +1,2 @@
bork
bork:

View file

@ -0,0 +1,2 @@
@import bork1

View file

@ -0,0 +1,2 @@
@import bork2

View file

@ -0,0 +1,2 @@
@import bork3