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

[Sass] Display expected strings as strings rather than regexps for css2sass.

This commit is contained in:
Nathan Weizenbaum 2009-09-23 15:00:41 -07:00
parent 0e68e5fcf5
commit 60f9344b0d
3 changed files with 11 additions and 5 deletions

View file

@ -25,6 +25,9 @@ Several bug fixes and minor improvements have been made, including:
* Only displaying the text for the current line when reporting CSS parsing errors.
* Displaying the expected strings as strings rather than regular expressions
whenever possible.
## [2.2.4](http://github.com/nex3/haml/commit/2.2.4)
* Don't add `require 'rubygems'` to the top of init.rb when installed

View file

@ -205,7 +205,8 @@ module Sass
after = "..." + after if pos >= 15
# Display basic regexps as plain old strings
expected = re.source == Regexp.escape(re.source) ? "\"#{re.source}\"" : re.inspect
string = re.source.gsub(/\\(.)/, '\1')
expected = re.source == Regexp.escape(string) ? string.inspect : re.inspect
was = @template.rest[0...15].gsub(/\n.*/m, '')
was += "..." if @template.rest.size >= 15

View file

@ -230,12 +230,14 @@ SASS
CSS
end
# Error reporting
def test_error_reporting
css2sass("foo")
assert(false, "Expected exception")
rescue Sass::SyntaxError => err
assert_equal(1, err.sass_line)
assert_equal('Invalid CSS after "foo": expected /\{/, was ""', err.message)
assert_equal('Invalid CSS after "foo": expected "{", was ""', err.message)
end
def test_error_reporting_in_line
@ -243,7 +245,7 @@ CSS
assert(false, "Expected exception")
rescue Sass::SyntaxError => err
assert_equal(2, err.sass_line)
assert_equal('Invalid CSS after "bar ": expected /\{/, was "}"', err.message)
assert_equal('Invalid CSS after "bar ": expected "{", was "}"', err.message)
end
def test_error_truncate_after
@ -251,7 +253,7 @@ CSS
assert(false, "Expected exception")
rescue Sass::SyntaxError => err
assert_equal(1, err.sass_line)
assert_equal('Invalid CSS after "...aaaaaaaaaaaafoo": expected /\{/, was ""', err.message)
assert_equal('Invalid CSS after "...aaaaaaaaaaaafoo": expected "{", was ""', err.message)
end
def test_error_truncate_was
@ -259,7 +261,7 @@ CSS
assert(false, "Expected exception")
rescue Sass::SyntaxError => err
assert_equal(1, err.sass_line)
assert_equal('Invalid CSS after "foo ": expected /\{/, was "}aaaaaaaaaaaaaa..."', err.message)
assert_equal('Invalid CSS after "foo ": expected "{", was "}aaaaaaaaaaaaaa..."', err.message)
end
private