test/sass/engine_test.rb in sass-3.1.0.alpha.221 vs test/sass/engine_test.rb in sass-3.1.0.alpha.246
- old
+ new
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
-require File.dirname(__FILE__) + '/../test_helper'
-require File.dirname(__FILE__) + '/test_helper'
+require 'test_helper'
+require 'sass/test_helper'
require 'sass/engine'
require 'stringio'
require 'mock_importer'
require 'pathname'
@@ -39,13 +39,13 @@
"a\n b: c;" => 'Invalid CSS after "c": expected expression (e.g. 1px, bold), was ";"',
".foo ^bar\n a: b" => ['Invalid CSS after ".foo ": expected selector, was "^bar"', 1],
"a\n @extend .foo ^bar" => 'Invalid CSS after ".foo ": expected selector, was "^bar"',
"a: b" => 'Properties are only allowed within rules, directives, or other properties.',
":a b" => 'Properties are only allowed within rules, directives, or other properties.',
- "!" => 'Invalid variable: "!".',
+ "$" => 'Invalid variable: "$".',
"$a" => 'Invalid variable: "$a".',
- "! a" => 'Invalid variable: "! a".',
+ "$ a" => 'Invalid variable: "$ a".',
"$a b" => 'Invalid variable: "$a b".',
"$a: 1b + 2c" => "Incompatible units: 'c' and 'b'.",
"$a: 1b < 2c" => "Incompatible units: 'c' and 'b'.",
"$a: 1b > 2c" => "Incompatible units: 'c' and 'b'.",
"$a: 1b <= 2c" => "Incompatible units: 'c' and 'b'.",
@@ -66,10 +66,11 @@
"@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
"foo\n @import foo.css" => "CSS import directives may only be used at the root of a document.",
"@if true\n @import foo" => "Import directives may not be used within control directives or mixins.",
"@mixin foo\n @import foo" => "Import directives may not be used within control directives or mixins.",
'$foo: "bar" "baz" !' => %Q{Invalid CSS after ""bar" "baz" ": expected expression (e.g. 1px, bold), was "!"},
+ '$foo: "bar" "baz" $' => %Q{Invalid CSS after ""bar" "baz" ": expected expression (e.g. 1px, bold), was "$"},
"=foo\n :color red\n.bar\n +bang" => "Undefined mixin 'bang'.",
"=foo\n :color red\n.bar\n +bang_bop" => "Undefined mixin 'bang_bop'.",
"=foo\n :color red\n.bar\n +bang-bop" => "Undefined mixin 'bang-bop'.",
".bar\n =foo\n :color red\n" => ["Mixins may only be defined at the root of a document.", 2],
"=foo\n :color red\n.bar\n +foo\n :color red" => "Illegal nesting: Nothing may be nested beneath mixin directives.",
@@ -88,12 +89,12 @@
"=a(,)" => 'Invalid CSS after "(": expected variable (e.g. $foo), was ",)"',
"=a($)" => 'Invalid CSS after "(": expected variable (e.g. $foo), was "$)"',
"=a($foo bar)" => 'Invalid CSS after "($foo ": expected ")", was "bar)"',
"=foo\n bar: baz\n+foo" => ["Properties are only allowed within rules, directives, or other properties.", 2],
"a-\#{$b\n c: d" => ['Invalid CSS after "a-#{$b": expected "}", was ""', 1],
- "=a($b = 1, $c)" => "Required argument $c must come before any optional arguments.",
- "=a($b = 1)\n a: $b\ndiv\n +a(1,2)" => "Mixin a takes 1 argument but 2 were passed.",
+ "=a($b: 1, $c)" => "Required argument $c must come before any optional arguments.",
+ "=a($b: 1)\n a: $b\ndiv\n +a(1,2)" => "Mixin a takes 1 argument but 2 were passed.",
"=a($b: 1)\n a: $b\ndiv\n +a(1,$c: 3)" => "Mixin a doesn't have an argument named $c",
"=a($b)\n a: $b\ndiv\n +a" => "Mixin a is missing parameter $b.",
"@function foo()\n 1 + 2" => "Functions can only contain variable declarations and control directives.",
"@function foo()\n foo: bar" => "Functions can only contain variable declarations and control directives.",
"@function foo()\n foo: bar\n @return 3" => ["Functions can only contain variable declarations and control directives.", 2],
@@ -111,11 +112,10 @@
"@if true\n @return 1" => '@return may only be used within a function.',
"@mixin foo\n @return 1\n@include foo" => ['@return may only be used within a function.', 2],
"@else\n a\n b: c" => ["@else must come after @if.", 1],
"@if false\n@else foo" => "Invalid else directive '@else foo': expected 'if <expr>'.",
"@if false\n@else if " => "Invalid else directive '@else if': expected 'if <expr>'.",
- "a\n !b: 12\nc\n d: !b" => 'Undefined variable: "$b".',
"a\n $b: 12\nc\n d: $b" => 'Undefined variable: "$b".',
"=foo\n $b: 12\nc\n +foo\n d: $b" => 'Undefined variable: "$b".',
"c\n d: $b-foo" => 'Undefined variable: "$b-foo".',
"c\n d: $b_foo" => 'Undefined variable: "$b_foo".',
'@for $a from "foo" to 1' => '"foo" is not an integer.',
@@ -966,81 +966,10 @@
c:
e: f
SASS
end
- def test_equals_warning_for_properties
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 3, character 3 of 'test_equals_warning_for_properties_inline.sass'
-Setting properties with = has been deprecated and will be removed in version 3.2.
-Use "a: $var" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a: 2px 3px; }
-CSS
-$var: 2px 3px
-foo
- a = $var
-SASS
- end
-
- def test_equals_warning_for_dynamic_properties
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 4, character 3 of 'test_equals_warning_for_dynamic_properties_inline.sass'
-Setting properties with = has been deprecated and will be removed in version 3.2.
-Use "a-\#{$i}: $var" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a-12: 2px 3px; }
-CSS
-$var: 2px 3px
-$i: 12
-foo
- a-\#{$i} = $var
-SASS
- end
-
- def test_equals_warning_for_property_with_string
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 2, character 3 of 'test_equals_warning_for_property_with_string_inline.sass'
-Setting properties with = has been deprecated and will be removed in version 3.2.
-Use "a: foo" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a: foo; }
-CSS
-foo
- a = "foo"
-SASS
- end
-
- def test_equals_warning_for_property_with_division
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 2, character 3 of 'test_equals_warning_for_property_with_division_inline.sass'
-Setting properties with = has been deprecated and will be removed in version 3.2.
-Use "a: (1px / 2px)" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a: 0.5; }
-CSS
-foo
- a = 1px/2px
-SASS
- end
-
def test_guarded_assign
assert_equal("foo {\n a: b; }\n", render(%Q{$foo: b\n$foo: c !default\nfoo\n a: $foo}))
assert_equal("foo {\n a: b; }\n", render(%Q{$foo: b !default\nfoo\n a: $foo}))
end
@@ -1146,30 +1075,10 @@
+mixin_hyphen
+mixin-under
SASS
end
- def test_equals_warning_for_mixin_args
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 1, character 10 of 'test_equals_warning_for_mixin_args_inline.sass'
-Setting mixin argument defaults with = has been deprecated and will be removed in version 3.2.
-Use "$arg: 1px" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-bar {
- a: 1px; }
-CSS
-=foo($arg = 1px)
- a: $arg
-
-bar
- +foo
-SASS
- end
-
def test_css_identifier_mixin
assert_equal(<<CSS, render(<<SASS))
a {
foo: 12; }
CSS
@@ -1334,34 +1243,10 @@
b-\#{$j}
j-1: $j - 1
SASS
end
- def test_for_with_bang_var
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 1, character 6 of 'test_for_with_bang_var_inline.sass'
-Variables with ! have been deprecated and will be removed in version 3.2.
-Use "$bar" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-a-0 {
- b: c; }
-
-a-1 {
- b: c; }
-
-a-2 {
- b: c; }
-CSS
-@for !bar from 0 to 3
- a-\#{$bar}
- b: c
-SASS
- end
-
def test_while
assert_equal(<<CSS, render(<<SASS))
a-5 {
blooble: gloop; }
@@ -1460,82 +1345,10 @@
$a: 2
c: $a
SASS
end
- def test_bang_variables
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 1, character 1 of 'test_bang_variables_inline.sass'
-Variables with ! have been deprecated and will be removed in version 3.2.
-Use "$bang-var" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a: 1px; }
-CSS
-!bang-var: 1px
-foo
- a: $bang-var
-SASS
-
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 3, character 6 of 'test_bang_variables_inline.sass'
-Variables with ! have been deprecated and will be removed in version 3.2.
-Use "$dollar-var" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a: 1px; }
-CSS
-$dollar-var: 1px
-foo
- a: !dollar-var
-SASS
- end
-
- def test_equals_warning_for_variables
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 2, character 1 of 'test_equals_warning_for_variables_inline.sass'
-Setting variables with = has been deprecated and will be removed in version 3.2.
-Use "$equals-var: 2px 3px" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a: 2px 3px; }
-CSS
-
-$equals-var = 2px 3px
-foo
- a: $equals-var
-SASS
- end
-
- def test_equals_warning_for_guarded_variables
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
-DEPRECATION WARNING:
-On line 2, character 1 of 'test_equals_warning_for_guarded_variables_inline.sass'
-Setting variable defaults with ||= has been deprecated and will be removed in version 3.2.
-Use "$equals-var: 2px 3px !default" instead.
-
-You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
-WARN
-foo {
- a: 2px 3px; }
-CSS
-
-$equals-var ||= 2px 3px
-foo
- a: $equals-var
-SASS
- end
-
def test_variable_scope
assert_equal(<<CSS, render(<<SASS))
a {
b-1: c;
b-2: c;
@@ -1713,10 +1526,51 @@
* bar
*/
SASS
end
+ def test_loud_comment_in_compressed_mode
+ assert_equal <<CSS, render(<<SASS, :style => :compressed)
+foo{color:blue;/* foo
+ * bar
+ */}
+CSS
+foo
+ color: blue
+ /*! foo
+ * bar
+ */
+SASS
+ end
+ def test_loud_comment_in_silent_comment
+ assert_equal <<CSS, render(<<SASS, :style => :compressed)
+foo{color:blue;/* foo */
+/* bar */
+/* */
+/* bip */
+/* baz */}
+CSS
+foo
+ color: blue
+ //! foo
+ //! bar
+ //!
+ bip
+ baz
+SASS
+ end
+
+ def test_loud_comment_is_evaluated
+ assert_equal <<CSS, render(<<SASS)
+/*
+ * Hue: 327.216deg */
+CSS
+/*!
+ Hue: \#{hue(#f836a0)}
+SASS
+ end
+
def test_attribute_selector_with_spaces
assert_equal(<<CSS, render(<<SASS))
a b[foo=bar] {
c: d; }
CSS
@@ -1917,186 +1771,10 @@
.foo-\#{"bar" "baz"}
a: b
SASS
end
- # Deprecated equals behavior
-
- def test_equals_properties_unquote_strings
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo;
- b: bar;
- c: foo bar;
- d: foo, bar baz;
- e: foo bar, bar; }
-CSS
-foo
- a= "foo"
- b= bar
- c= "foo" bar
- d= foo, "bar baz"
- e= "foo bar", bar
-SASS
- end
- end
-
- def test_equals_properties_unquote_value
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo; }
-CSS
-$var: "foo"
-
-foo
- a= $var
-SASS
- end
- end
-
- def test_equals_properties_deep_unquote_vars
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo bar;
- b: bar foo; }
-CSS
-$var: "foo"
-
-foo
- a= $var "bar"
- b= "bar" $var
-SASS
- end
- end
-
- def test_equals_vars_unquote_strings
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo;
- b: bar;
- c: foo bar;
- d: foo, bar; }
-CSS
-$a = "foo"
-$b = bar
-$c = "foo" bar
-$d = foo, "bar"
-
-foo
- a: $a
- b: $b
- c: $c
- d: $d
-SASS
- end
- end
-
- def test_equals_vars_unquote_value
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo; }
-CSS
-$var1: "foo"
-$var2 = $var1
-
-foo
- a: $var2
-SASS
- end
- end
-
- def test_equals_vars_deep_unquote_vars
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo bar;
- b: bar foo; }
-CSS
-$var: "foo"
-$a = $var "bar"
-$b = "bar" $var
-
-foo
- a: $a
- b: $b
-SASS
- end
- end
-
- def test_equals_args_unquote_strings
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo;
- b: bar;
- c: foo bar;
- d: foo, bar; }
-CSS
-=foo($a = "foo", $b = bar, $c = "foo" bar, $d = (foo, "bar"))
- foo
- a: $a
- b: $b
- c: $c
- d: $d
-
-+foo
-SASS
- end
- end
-
- def test_equals_args_unquote_value
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo; }
-CSS
-$var1: "foo"
-
-=foo($var2 = $var1)
- foo
- a: $var2
-
-+foo
-SASS
- end
- end
-
- def test_equals_args_deep_unquote_vars
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: foo bar;
- b: bar foo; }
-CSS
-$var: "foo"
-=foo($a = $var "bar", $b = "bar" $var)
- foo
- a: $a
- b: $b
-
-+foo
-SASS
- end
- end
-
- def test_equals_properties_force_division
- silence_warnings do
- assert_equal(<<CSS, render(<<SASS))
-foo {
- a: 0.5; }
-CSS
-foo
- a = 1px/2px
-SASS
- end
- end
-
def test_warn_directive
expected_warning = <<EXPECTATION
WARNING: this is a warning
on line 4 of test_warn_directive_inline.sass
@@ -2564,9 +2242,31 @@
@baz {
c: d; }
CSS
@baz
c: d
+SASS
+ end
+
+ def test_comment_interpolation_warning
+ assert_warning(<<END) {render("/* \#{foo}")}
+WARNING:
+On line 1 of 'test_comment_interpolation_warning_inline.sass'
+Comments will evaluate the contents of interpolations (\#{ ... }) in Sass 3.2.
+Please escape the interpolation by adding a backslash before the hash sign.
+END
+ end
+
+ def test_loud_comment_interpolations_can_be_escaped
+ assert_equal <<CSS, render(<<SASS)
+/* \#{foo} */
+CSS
+/* \\\#{foo}
+SASS
+ assert_equal <<CSS, render(<<SASS)
+/* \#{foo} */
+CSS
+/*! \\\#{foo}
SASS
end
# Encodings