sass 3.3.14 → 3.4.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +5 -5
  4. data/VERSION +1 -1
  5. data/VERSION_DATE +1 -1
  6. data/VERSION_NAME +1 -1
  7. data/bin/sass +1 -1
  8. data/bin/scss +1 -1
  9. data/lib/sass.rb +0 -5
  10. data/lib/sass/css.rb +1 -3
  11. data/lib/sass/engine.rb +28 -39
  12. data/lib/sass/environment.rb +13 -17
  13. data/lib/sass/error.rb +6 -9
  14. data/lib/sass/exec.rb +5 -771
  15. data/lib/sass/exec/base.rb +187 -0
  16. data/lib/sass/exec/sass_convert.rb +264 -0
  17. data/lib/sass/exec/sass_scss.rb +419 -0
  18. data/lib/sass/features.rb +6 -0
  19. data/lib/sass/importers.rb +0 -1
  20. data/lib/sass/importers/base.rb +5 -1
  21. data/lib/sass/importers/filesystem.rb +4 -21
  22. data/lib/sass/media.rb +1 -4
  23. data/lib/sass/plugin/compiler.rb +32 -136
  24. data/lib/sass/script/css_lexer.rb +1 -1
  25. data/lib/sass/script/functions.rb +363 -39
  26. data/lib/sass/script/lexer.rb +68 -50
  27. data/lib/sass/script/parser.rb +29 -14
  28. data/lib/sass/script/tree.rb +1 -0
  29. data/lib/sass/script/tree/funcall.rb +1 -1
  30. data/lib/sass/script/tree/interpolation.rb +19 -1
  31. data/lib/sass/script/tree/selector.rb +26 -0
  32. data/lib/sass/script/value.rb +0 -1
  33. data/lib/sass/script/value/bool.rb +0 -5
  34. data/lib/sass/script/value/color.rb +32 -12
  35. data/lib/sass/script/value/helpers.rb +107 -0
  36. data/lib/sass/script/value/list.rb +0 -15
  37. data/lib/sass/script/value/null.rb +0 -5
  38. data/lib/sass/script/value/number.rb +60 -14
  39. data/lib/sass/script/value/string.rb +53 -9
  40. data/lib/sass/scss/css_parser.rb +8 -2
  41. data/lib/sass/scss/parser.rb +175 -319
  42. data/lib/sass/scss/rx.rb +14 -5
  43. data/lib/sass/scss/static_parser.rb +298 -1
  44. data/lib/sass/selector.rb +56 -193
  45. data/lib/sass/selector/abstract_sequence.rb +28 -13
  46. data/lib/sass/selector/comma_sequence.rb +91 -12
  47. data/lib/sass/selector/pseudo.rb +256 -0
  48. data/lib/sass/selector/sequence.rb +99 -31
  49. data/lib/sass/selector/simple.rb +14 -25
  50. data/lib/sass/selector/simple_sequence.rb +101 -37
  51. data/lib/sass/shared.rb +1 -1
  52. data/lib/sass/source/map.rb +23 -9
  53. data/lib/sass/stack.rb +0 -6
  54. data/lib/sass/supports.rb +1 -1
  55. data/lib/sass/tree/at_root_node.rb +1 -0
  56. data/lib/sass/tree/directive_node.rb +7 -1
  57. data/lib/sass/tree/error_node.rb +18 -0
  58. data/lib/sass/tree/keyframe_rule_node.rb +15 -0
  59. data/lib/sass/tree/prop_node.rb +1 -1
  60. data/lib/sass/tree/rule_node.rb +11 -6
  61. data/lib/sass/tree/visitors/check_nesting.rb +3 -4
  62. data/lib/sass/tree/visitors/convert.rb +8 -17
  63. data/lib/sass/tree/visitors/cssize.rb +12 -24
  64. data/lib/sass/tree/visitors/deep_copy.rb +5 -0
  65. data/lib/sass/tree/visitors/perform.rb +43 -28
  66. data/lib/sass/tree/visitors/set_options.rb +5 -0
  67. data/lib/sass/tree/visitors/to_css.rb +14 -13
  68. data/lib/sass/util.rb +94 -90
  69. data/test/sass/cache_test.rb +1 -1
  70. data/test/sass/callbacks_test.rb +1 -1
  71. data/test/sass/compiler_test.rb +5 -14
  72. data/test/sass/conversion_test.rb +47 -1
  73. data/test/sass/css2sass_test.rb +3 -3
  74. data/test/sass/encoding_test.rb +219 -0
  75. data/test/sass/engine_test.rb +128 -191
  76. data/test/sass/exec_test.rb +2 -2
  77. data/test/sass/extend_test.rb +234 -17
  78. data/test/sass/functions_test.rb +268 -213
  79. data/test/sass/importer_test.rb +31 -21
  80. data/test/sass/logger_test.rb +1 -1
  81. data/test/sass/more_results/more_import.css +1 -1
  82. data/test/sass/plugin_test.rb +12 -11
  83. data/test/sass/results/compact.css +1 -1
  84. data/test/sass/results/complex.css +4 -4
  85. data/test/sass/results/expanded.css +1 -1
  86. data/test/sass/results/import.css +1 -1
  87. data/test/sass/results/import_charset_ibm866.css +2 -2
  88. data/test/sass/results/mixins.css +17 -17
  89. data/test/sass/results/nested.css +1 -1
  90. data/test/sass/results/parent_ref.css +2 -2
  91. data/test/sass/results/script.css +3 -3
  92. data/test/sass/results/scss_import.css +1 -1
  93. data/test/sass/script_conversion_test.rb +7 -4
  94. data/test/sass/script_test.rb +202 -79
  95. data/test/sass/scss/css_test.rb +95 -25
  96. data/test/sass/scss/rx_test.rb +4 -4
  97. data/test/sass/scss/scss_test.rb +363 -19
  98. data/test/sass/source_map_test.rb +48 -41
  99. data/test/sass/superselector_test.rb +191 -0
  100. data/test/sass/templates/scss_import.scss +2 -1
  101. data/test/sass/test_helper.rb +1 -1
  102. data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
  103. data/test/sass/util/normalized_map_test.rb +1 -1
  104. data/test/sass/util/subset_map_test.rb +2 -2
  105. data/test/sass/util_test.rb +1 -1
  106. data/test/sass/value_helpers_test.rb +3 -3
  107. data/test/test_helper.rb +2 -2
  108. metadata +30 -7
  109. data/lib/sass/importers/deprecated_path.rb +0 -51
  110. data/lib/sass/script/value/deprecated_false.rb +0 -55
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper'
3
3
  require File.dirname(__FILE__) + '/test_helper'
4
4
  require 'sass/engine'
5
5
 
6
- class CacheTest < Test::Unit::TestCase
6
+ class CacheTest < MiniTest::Test
7
7
  @@cache_dir = "tmp/file_cache"
8
8
 
9
9
  def setup
@@ -26,7 +26,7 @@ module ClassLevelCallerBack
26
26
  end
27
27
  end
28
28
 
29
- class SassCallbacksTest < Test::Unit::TestCase
29
+ class SassCallbacksTest < MiniTest::Test
30
30
  def test_simple_callback
31
31
  cb = CallerBack.new
32
32
  there = false
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
  require File.dirname(__FILE__) + '/../test_helper'
4
4
  require 'sass/plugin'
5
5
  require 'sass/plugin/compiler'
6
6
 
7
- class CompilerTest < Test::Unit::TestCase
7
+ class CompilerTest < MiniTest::Test
8
8
  class FakeListener
9
9
  attr_accessor :options
10
10
  attr_accessor :directories
@@ -82,18 +82,9 @@ class CompilerTest < Test::Unit::TestCase
82
82
 
83
83
  private
84
84
  def create_listener(*args, &on_filesystem_event)
85
- if Sass::Util.listen_geq_2?
86
- options = args.pop if args.last.is_a?(Hash)
87
- args.map do |dir|
88
- @fake_listener = FakeListener.new(*args, &on_filesystem_event)
89
- @fake_listener.on_start!(&run_during_start)
90
- @fake_listener
91
- end
92
- else
93
- @fake_listener = FakeListener.new(*args, &on_filesystem_event)
94
- @fake_listener.on_start!(&run_during_start)
95
- @fake_listener
96
- end
85
+ @fake_listener = FakeListener.new(*args, &on_filesystem_event)
86
+ @fake_listener.on_start!(&run_during_start)
87
+ @fake_listener
97
88
  end
98
89
  end
99
90
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
3
 
4
- class ConversionTest < Test::Unit::TestCase
4
+ class ConversionTest < MiniTest::Test
5
5
  def test_basic
6
6
  assert_renders <<SASS, <<SCSS
7
7
  foo bar
@@ -589,6 +589,19 @@ foo {
589
589
  SCSS
590
590
  end
591
591
 
592
+ def test_error
593
+ assert_renders <<SASS, <<SCSS
594
+ foo
595
+ @error "oh no!"
596
+ bar: baz
597
+ SASS
598
+ foo {
599
+ @error "oh no!";
600
+ bar: baz;
601
+ }
602
+ SCSS
603
+ end
604
+
592
605
  def test_directive_without_children
593
606
  assert_renders <<SASS, <<SCSS
594
607
  foo
@@ -1819,6 +1832,39 @@ SASS
1819
1832
  SCSS
1820
1833
  end
1821
1834
 
1835
+ def test_keyframes
1836
+ assert_renders(<<SASS, <<SCSS)
1837
+ @keyframes identifier
1838
+ 0%
1839
+ top: 0
1840
+ left: 0
1841
+ 30%
1842
+ top: 50px
1843
+ 68%, 72%
1844
+ left: 50px
1845
+ 100%
1846
+ top: 100px
1847
+ left: 100%
1848
+ SASS
1849
+ @keyframes identifier {
1850
+ 0% {
1851
+ top: 0;
1852
+ left: 0;
1853
+ }
1854
+ 30% {
1855
+ top: 50px;
1856
+ }
1857
+ 68%, 72% {
1858
+ left: 50px;
1859
+ }
1860
+ 100% {
1861
+ top: 100px;
1862
+ left: 100%;
1863
+ }
1864
+ }
1865
+ SCSS
1866
+ end
1867
+
1822
1868
  ## Regression Tests
1823
1869
 
1824
1870
  def test_list_in_args
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
  require File.dirname(__FILE__) + '/../test_helper'
4
4
  require 'sass/css'
5
5
 
6
- class CSS2SassTest < Test::Unit::TestCase
6
+ class CSS2SassTest < MiniTest::Test
7
7
  def test_basic
8
8
  css = <<CSS
9
9
  h1 {
@@ -238,7 +238,7 @@ CSS
238
238
  end
239
239
 
240
240
  def test_subject
241
- assert_equal(<<SASS, css2sass(<<CSS))
241
+ silence_warnings {assert_equal(<<SASS, css2sass(<<CSS))}
242
242
  .foo
243
243
  .bar!
244
244
  .baz
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ require File.dirname(__FILE__) + '/../test_helper'
4
+ require File.dirname(__FILE__) + '/test_helper'
5
+ require 'sass/util/test'
6
+
7
+ class EncodingTest < MiniTest::Test
8
+ include Sass::Util::Test
9
+
10
+ def test_encoding_error
11
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
12
+
13
+ render("foo\nbar\nb\xFEaz".force_encoding("utf-8"))
14
+ assert(false, "Expected exception")
15
+ rescue Sass::SyntaxError => e
16
+ assert_equal(3, e.sass_line)
17
+ assert_equal('Invalid UTF-8 character "\xFE"', e.message)
18
+ end
19
+
20
+ def test_ascii_incompatible_encoding_error
21
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
22
+
23
+ template = "foo\nbar\nb_z".encode("utf-16le")
24
+ template[9] = "\xFE".force_encoding("utf-16le")
25
+ render(template)
26
+ assert(false, "Expected exception")
27
+ rescue Sass::SyntaxError => e
28
+ assert_equal(3, e.sass_line)
29
+ assert_equal('Invalid UTF-16LE character "\xFE"', e.message)
30
+ end
31
+
32
+ def test_prefers_charset_to_ruby_encoding
33
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
34
+
35
+ assert_renders_encoded(<<CSS, <<SASS.encode("IBM866").force_encoding("UTF-8"))
36
+ @charset "UTF-8";
37
+ fЖЖ {
38
+ a: b; }
39
+ CSS
40
+ @charset "ibm866"
41
+ fЖЖ
42
+ a: b
43
+ SASS
44
+ end
45
+
46
+ def test_uses_ruby_encoding_without_charset
47
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
48
+
49
+ assert_renders_encoded(<<CSS, <<SASS.encode("IBM866"))
50
+ @charset "UTF-8";
51
+ тАЬ {
52
+ a: b; }
53
+ CSS
54
+ тАЬ
55
+ a: b
56
+ SASS
57
+ end
58
+
59
+ def test_multibyte_charset_without_bom_declared_as_binary
60
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
61
+
62
+ engine = Sass::Engine.new(<<SASS.encode("UTF-16LE").force_encoding("BINARY"))
63
+ @charset "utf-16le"
64
+ fóó
65
+ a: b
66
+ SASS
67
+ # Since multibyte encodings' @charset declarations aren't
68
+ # ASCII-compatible, we have to interpret the files as UTF-8 which will
69
+ # inevitably fail.
70
+ assert_raise_message(Sass::SyntaxError, "Invalid UTF-8 character \"\\xF3\"") {engine.render}
71
+ end
72
+
73
+ def test_multibyte_charset_without_bom_declared_as_utf_8
74
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
75
+
76
+ engine = Sass::Engine.new(<<SASS.encode("UTF-16LE").force_encoding("UTF-8"))
77
+ @charset "utf-16le"
78
+ fóó
79
+ a: b
80
+ SASS
81
+ # Since multibyte encodings' @charset declarations aren't
82
+ # ASCII-compatible, we have to interpret the files as UTF-8 which will
83
+ # inevitably fail.
84
+ assert_raise_message(Sass::SyntaxError, "Invalid UTF-8 character \"\\xF3\"") {engine.render}
85
+ end
86
+
87
+ def test_utf_16le_with_bom
88
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
89
+
90
+ assert_renders_encoded(<<CSS, <<SASS.encode("UTF-16LE").force_encoding("BINARY"))
91
+ @charset "UTF-8";
92
+ fóó {
93
+ a: b; }
94
+ CSS
95
+ \uFEFFfóó
96
+ a: b
97
+ SASS
98
+ end
99
+
100
+ def test_utf_16be_with_bom
101
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
102
+
103
+ assert_renders_encoded(<<CSS, <<SASS.encode("UTF-16BE").force_encoding("BINARY"))
104
+ @charset "UTF-8";
105
+ fóó {
106
+ a: b; }
107
+ CSS
108
+ \uFEFFfóó
109
+ a: b
110
+ SASS
111
+ end
112
+
113
+ def test_utf_8_with_bom
114
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
115
+
116
+ assert_renders_encoded(<<CSS, <<SASS.force_encoding("BINARY"))
117
+ @charset "UTF-8";
118
+ fóó {
119
+ a: b; }
120
+ CSS
121
+ \uFEFFfóó
122
+ a: b
123
+ SASS
124
+ end
125
+
126
+ def test_charset_with_multibyte_encoding
127
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
128
+
129
+ engine = Sass::Engine.new(<<SASS)
130
+ @charset "utf-32be"
131
+ fóó
132
+ a: b
133
+ SASS
134
+ # The charset declaration is just false here, so we should get an
135
+ # encoding error.
136
+ assert_raise_message(Sass::SyntaxError, "Invalid UTF-32BE character \"\\xC3\"") {engine.render}
137
+ end
138
+
139
+ def test_charset_with_special_case_encoding
140
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
141
+
142
+ # For some reason, a file with an ASCII-compatible UTF-16 charset
143
+ # declaration is specced to be parsed as UTF-8.
144
+ assert_renders_encoded(<<CSS, <<SASS.force_encoding("BINARY"))
145
+ @charset "UTF-8";
146
+ fóó {
147
+ a: b; }
148
+ CSS
149
+ @charset "utf-16"
150
+ fóó
151
+ a: b
152
+ SASS
153
+ end
154
+
155
+ def test_compressed_output_uses_bom
156
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
157
+
158
+ assert_equal("\uFEFFfóó{a:b}\n", render(<<SASS, :style => :compressed))
159
+ fóó
160
+ a: b
161
+ SASS
162
+ end
163
+
164
+ def test_newline_normalization
165
+ assert_equal("/* foo\nbar\nbaz\nbang\nqux */\n",
166
+ render("/* foo\nbar\r\nbaz\fbang\rqux */", :syntax => :scss))
167
+ end
168
+
169
+ def test_null_normalization
170
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
171
+
172
+ assert_equal(<<CSS, render("/* foo\x00bar\x00baz */", :syntax => :scss))
173
+ #{"@charset \"UTF-8\";\n" unless Sass::Util.ruby1_8?
174
+ }/* foo�bar�baz */
175
+ CSS
176
+ end
177
+
178
+ # Regression
179
+
180
+ def test_multibyte_prop_name
181
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
182
+
183
+ assert_equal(<<CSS, render(<<SASS))
184
+ @charset "UTF-8";
185
+ #bar {
186
+ cölor: blue; }
187
+ CSS
188
+ #bar
189
+ cölor: blue
190
+ SASS
191
+ end
192
+
193
+ def test_multibyte_and_interpolation
194
+ return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
195
+
196
+ assert_equal(<<CSS, render(<<SCSS, :syntax => :scss))
197
+ #bar {
198
+ background: a 0%; }
199
+ CSS
200
+ #bar {
201
+ // 
202
+ background: \#{a} 0%;
203
+ }
204
+ SCSS
205
+ end
206
+
207
+ private
208
+
209
+ def assert_renders_encoded(css, sass)
210
+ result = render(sass)
211
+ assert_equal css.encoding, result.encoding
212
+ assert_equal css, result
213
+ end
214
+
215
+ def render(sass, options = {})
216
+ munge_filename options
217
+ Sass::Engine.new(sass, options).render
218
+ end
219
+ end
@@ -17,6 +17,11 @@ module Sass::Script::Functions::UserFunctions
17
17
  return Sass::Script::Value::Null.new
18
18
  end
19
19
 
20
+ def set_a_global_variable(name, value)
21
+ environment.set_global_var(name.value, value)
22
+ return Sass::Script::Value::Null.new
23
+ end
24
+
20
25
  def get_a_variable(name)
21
26
  environment.var(name.value) || Sass::Script::Value::String.new("undefined")
22
27
  end
@@ -26,7 +31,7 @@ module Sass::Script::Functions
26
31
  include Sass::Script::Functions::UserFunctions
27
32
  end
28
33
 
29
- class SassEngineTest < Test::Unit::TestCase
34
+ class SassEngineTest < MiniTest::Test
30
35
  FAKE_FILE_NAME = __FILE__.gsub(/rb$/,"sass")
31
36
  # A map of erroneous Sass documents to the error messages they should produce.
32
37
  # The error messages may be arrays;
@@ -68,8 +73,8 @@ MSG
68
73
  "$a: 1b >= 2c" => "Incompatible units: 'c' and 'b'.",
69
74
  "a\n b: 1b * 2c" => "2b*c isn't a valid CSS value.",
70
75
  "a\n b: 1b % 2c" => "Incompatible units: 'c' and 'b'.",
71
- "$a: 2px + #ccc" => "Cannot add a number with units (2px) to a color (#cccccc).",
72
- "$a: #ccc + 2px" => "Cannot add a number with units (2px) to a color (#cccccc).",
76
+ "$a: 2px + #ccc" => "Cannot add a number with units (2px) to a color (#ccc).",
77
+ "$a: #ccc + 2px" => "Cannot add a number with units (2px) to a color (#ccc).",
73
78
  "& a\n :b c" => ["Base-level rules cannot contain the parent-selector-referencing character '&'.", 1],
74
79
  "a\n :b\n c" => "Illegal nesting: Only properties may be nested beneath properties.",
75
80
  "$a: b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath variable declarations.",
@@ -141,6 +146,8 @@ MSG
141
146
  '@while' => "Invalid while directive '@while': expected expression.",
142
147
  '@debug' => "Invalid debug directive '@debug': expected expression.",
143
148
  %Q{@debug "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath debug directives.",
149
+ '@error' => "Invalid error directive '@error': expected expression.",
150
+ %Q{@error "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath error directives.",
144
151
  '@warn' => "Invalid warn directive '@warn': expected expression.",
145
152
  %Q{@warn "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath warn directives.",
146
153
  "/* foo\n bar\n baz" => "Inconsistent indentation: previous line was indented by 4 spaces, but this line was indented by 2 spaces.",
@@ -526,9 +533,9 @@ ERR
526
533
  opts = {:full_exception => true, :line => 362}
527
534
  render(("a\n b: c\n" * 10) + "d\n e:\n" + ("f\n g: h\n" * 10), opts)
528
535
  rescue Sass::SyntaxError => e
529
- assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts).split("\n")[0..15].join("\n"))
536
+ assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts[:line]).split("\n")[0..15].join("\n"))
530
537
  /*
531
- Syntax error: Invalid property: "e:" (no value).
538
+ Error: Invalid property: "e:" (no value).
532
539
  on line 383 of test_exception_css_with_offset_inline.sass
533
540
 
534
541
  378: a
@@ -548,8 +555,7 @@ CSS
548
555
  end
549
556
 
550
557
  def test_exception_css_with_mixins
551
- opts = {:full_exception => true}
552
- render(<<SASS, opts)
558
+ render(<<SASS, :full_exception => true)
553
559
  =error-mixin($a)
554
560
  color: $a * 1em * 1px
555
561
 
@@ -560,9 +566,9 @@ CSS
560
566
  +outer-mixin(12)
561
567
  SASS
562
568
  rescue Sass::SyntaxError => e
563
- assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts).split("\n")[0..13].join("\n"))
569
+ assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e).split("\n")[0..13].join("\n"))
564
570
  /*
565
- Syntax error: 12em*px isn't a valid CSS value.
571
+ Error: 12em*px isn't a valid CSS value.
566
572
  on line 2 of test_exception_css_with_mixins_inline.sass, in `error-mixin'
567
573
  from line 5 of test_exception_css_with_mixins_inline.sass, in `outer-mixin'
568
574
  from line 8 of test_exception_css_with_mixins_inline.sass
@@ -580,8 +586,7 @@ CSS
580
586
  end
581
587
 
582
588
  def test_cssize_exception_css
583
- opts = {:full_exception => true}
584
- render(<<SASS, opts)
589
+ render(<<SASS, :full_exception => true)
585
590
  .filler
586
591
  stuff: "stuff!"
587
592
 
@@ -591,9 +596,9 @@ a: b
591
596
  a: b
592
597
  SASS
593
598
  rescue Sass::SyntaxError => e
594
- assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts).split("\n")[0..11].join("\n"))
599
+ assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e).split("\n")[0..11].join("\n"))
595
600
  /*
596
- Syntax error: Properties are only allowed within rules, directives, mixin includes, or other properties.
601
+ Error: Properties are only allowed within rules, directives, mixin includes, or other properties.
597
602
  on line 4 of test_cssize_exception_css_inline.sass
598
603
 
599
604
  1: .filler
@@ -613,12 +618,12 @@ CSS
613
618
  end
614
619
 
615
620
  def test_http_import
616
- assert_equal("@import url(http://fonts.googleapis.com/css?family=Droid+Sans);\n",
621
+ assert_equal("@import \"http://fonts.googleapis.com/css?family=Droid+Sans\";\n",
617
622
  render("@import \"http://fonts.googleapis.com/css?family=Droid+Sans\""))
618
623
  end
619
624
 
620
625
  def test_protocol_relative_import
621
- assert_equal("@import url(//fonts.googleapis.com/css?family=Droid+Sans);\n",
626
+ assert_equal("@import \"//fonts.googleapis.com/css?family=Droid+Sans\";\n",
622
627
  render("@import \"//fonts.googleapis.com/css?family=Droid+Sans\""))
623
628
  end
624
629
 
@@ -702,12 +707,12 @@ ERR
702
707
  def test_import_in_rule
703
708
  assert_equal(<<CSS, render(<<SASS, :load_paths => [File.dirname(__FILE__) + '/templates/']))
704
709
  .foo #foo {
705
- background-color: #bbaaff; }
710
+ background-color: #baf; }
706
711
 
707
712
  .bar {
708
713
  a: b; }
709
714
  .bar #foo {
710
- background-color: #bbaaff; }
715
+ background-color: #baf; }
711
716
  CSS
712
717
  .foo
713
718
  @import partial
@@ -1026,7 +1031,6 @@ SASS
1026
1031
  @-webkit-keyframes warm {
1027
1032
  from {
1028
1033
  color: black; }
1029
-
1030
1034
  to {
1031
1035
  color: red; } }
1032
1036
  CSS
@@ -1130,7 +1134,13 @@ SASS
1130
1134
  end
1131
1135
 
1132
1136
  def test_default_values_for_mixin_arguments
1133
- assert_equal("white {\n color: white; }\n\nblack {\n color: black; }\n", render(<<SASS))
1137
+ assert_equal(<<CSS, render(<<SASS))
1138
+ white {
1139
+ color: #FFF; }
1140
+
1141
+ black {
1142
+ color: #000; }
1143
+ CSS
1134
1144
  =foo($a: #FFF)
1135
1145
  :color $a
1136
1146
  white
@@ -1140,17 +1150,17 @@ black
1140
1150
  SASS
1141
1151
  assert_equal(<<CSS, render(<<SASS))
1142
1152
  one {
1143
- color: white;
1153
+ color: #fff;
1144
1154
  padding: 1px;
1145
1155
  margin: 4px; }
1146
1156
 
1147
1157
  two {
1148
- color: white;
1158
+ color: #fff;
1149
1159
  padding: 2px;
1150
1160
  margin: 5px; }
1151
1161
 
1152
1162
  three {
1153
- color: white;
1163
+ color: #fff;
1154
1164
  padding: 2px;
1155
1165
  margin: 3px; }
1156
1166
  CSS
@@ -1168,17 +1178,17 @@ three
1168
1178
  SASS
1169
1179
  assert_equal(<<CSS, render(<<SASS))
1170
1180
  one {
1171
- color: white;
1181
+ color: #fff;
1172
1182
  padding: 1px;
1173
1183
  margin: 4px; }
1174
1184
 
1175
1185
  two {
1176
- color: white;
1186
+ color: #fff;
1177
1187
  padding: 2px;
1178
1188
  margin: 5px; }
1179
1189
 
1180
1190
  three {
1181
- color: white;
1191
+ color: #fff;
1182
1192
  padding: 2px;
1183
1193
  margin: 3px; }
1184
1194
  CSS
@@ -1383,7 +1393,7 @@ CSS
1383
1393
  $variable: 0
1384
1394
  bar
1385
1395
  $local: 10
1386
- -no-op: set-a-variable(variable, 5)
1396
+ -no-op: set-a-global-variable(variable, 5)
1387
1397
  a: $variable
1388
1398
  SASS
1389
1399
  end
@@ -1617,31 +1627,6 @@ a
1617
1627
  SASS
1618
1628
  end
1619
1629
 
1620
- def test_variable_scope
1621
- silence_warnings {assert_equal(<<CSS, render(<<SASS))}
1622
- a {
1623
- b-1: c;
1624
- b-2: c;
1625
- d: 12; }
1626
-
1627
- b {
1628
- d: 17; }
1629
- CSS
1630
- $i: 12
1631
- a
1632
- @for $i from 1 through 2
1633
- b-\#{$i}: c
1634
- d: $i
1635
-
1636
- =foo
1637
- $i: 17
1638
-
1639
- b
1640
- +foo
1641
- d: $i
1642
- SASS
1643
- end
1644
-
1645
1630
  def test_hyphen_underscore_insensitive_variables
1646
1631
  assert_equal(<<CSS, render(<<SASS))
1647
1632
  d {
@@ -1684,7 +1669,7 @@ SASS
1684
1669
  end
1685
1670
 
1686
1671
  def test_argument_error
1687
- assert_raise(Sass::SyntaxError) { render("a\n b: hsl(1)") }
1672
+ assert_raises(Sass::SyntaxError) { render("a\n b: hsl(1)") }
1688
1673
  end
1689
1674
 
1690
1675
  def test_comments_at_the_top_of_a_document
@@ -2898,145 +2883,6 @@ CSS
2898
2883
  SASS
2899
2884
  end
2900
2885
 
2901
- # Encodings
2902
-
2903
- unless Sass::Util.ruby1_8?
2904
- def test_encoding_error
2905
- render("foo\nbar\nb\xFEaz".force_encoding("utf-8"))
2906
- assert(false, "Expected exception")
2907
- rescue Sass::SyntaxError => e
2908
- assert_equal(3, e.sass_line)
2909
- assert_equal('Invalid UTF-8 character "\xFE"', e.message)
2910
- end
2911
-
2912
- def test_ascii_incompatible_encoding_error
2913
- template = "foo\nbar\nb_z".encode("utf-16le")
2914
- template[9] = "\xFE".force_encoding("utf-16le")
2915
- render(template)
2916
- assert(false, "Expected exception")
2917
- rescue Sass::SyntaxError => e
2918
- assert_equal(3, e.sass_line)
2919
- assert_equal('Invalid UTF-16LE character "\xFE"', e.message)
2920
- end
2921
-
2922
- def test_same_charset_as_encoding
2923
- assert_renders_encoded(<<CSS, <<SASS)
2924
- @charset "UTF-8";
2925
- fóó {
2926
- a: b; }
2927
- CSS
2928
- @charset "utf-8"
2929
- fóó
2930
- a: b
2931
- SASS
2932
- end
2933
-
2934
- def test_different_charset_than_encoding
2935
- assert_renders_encoded(<<CSS.force_encoding("IBM866"), <<SASS)
2936
- @charset "IBM866";
2937
- fóó {
2938
- a: b; }
2939
- CSS
2940
- @charset "ibm866"
2941
- fóó
2942
- a: b
2943
- SASS
2944
- end
2945
-
2946
- def test_different_encoding_than_system
2947
- assert_renders_encoded(<<CSS.encode("IBM866"), <<SASS.encode("IBM866"))
2948
- @charset "IBM866";
2949
- тАЬ {
2950
- a: b; }
2951
- CSS
2952
- тАЬ
2953
- a: b
2954
- SASS
2955
- end
2956
-
2957
- def test_multibyte_charset
2958
- assert_renders_encoded(<<CSS.encode("UTF-16LE"), <<SASS.encode("UTF-16LE").force_encoding("UTF-8"))
2959
- @charset "UTF-16LE";
2960
- fóó {
2961
- a: b; }
2962
- CSS
2963
- @charset "utf-16le"
2964
- fóó
2965
- a: b
2966
- SASS
2967
- end
2968
-
2969
- def test_multibyte_charset_without_endian_specifier
2970
- assert_renders_encoded(<<CSS.encode("UTF-32BE"), <<SASS.encode("UTF-32BE").force_encoding("UTF-8"))
2971
- @charset "UTF-32BE";
2972
- fóó {
2973
- a: b; }
2974
- CSS
2975
- @charset "utf-32"
2976
- fóó
2977
- a: b
2978
- SASS
2979
- end
2980
-
2981
- def test_utf8_bom
2982
- assert_renders_encoded(<<CSS, <<SASS.force_encoding("BINARY"))
2983
- @charset "UTF-8";
2984
- fóó {
2985
- a: b; }
2986
- CSS
2987
- \uFEFFfóó
2988
- a: b
2989
- SASS
2990
- end
2991
-
2992
- def test_utf16le_bom
2993
- assert_renders_encoded(<<CSS.encode("UTF-16LE"), <<SASS.encode("UTF-16LE").force_encoding("BINARY"))
2994
- @charset "UTF-16LE";
2995
- fóó {
2996
- a: b; }
2997
- CSS
2998
- \uFEFFfóó
2999
- a: b
3000
- SASS
3001
- end
3002
-
3003
- def test_utf32be_bom
3004
- assert_renders_encoded(<<CSS.encode("UTF-32BE"), <<SASS.encode("UTF-32BE").force_encoding("BINARY"))
3005
- @charset "UTF-32BE";
3006
- fóó {
3007
- a: b; }
3008
- CSS
3009
- \uFEFFfóó
3010
- a: b
3011
- SASS
3012
- end
3013
-
3014
- # Encoding Regression Test
3015
-
3016
- def test_multibyte_prop_name
3017
- assert_equal(<<CSS, render(<<SASS))
3018
- @charset "UTF-8";
3019
- #bar {
3020
- cölor: blue; }
3021
- CSS
3022
- #bar
3023
- cölor: blue
3024
- SASS
3025
- end
3026
-
3027
- def test_multibyte_and_interpolation
3028
- assert_equal(<<CSS, render(<<SCSS, :syntax => :scss))
3029
- #bar {
3030
- background: a 0%; }
3031
- CSS
3032
- #bar {
3033
- // 
3034
- background: \#{a} 0%;
3035
- }
3036
- SCSS
3037
- end
3038
- end
3039
-
3040
2886
  def test_original_filename_set
3041
2887
  importer = MockImporter.new
3042
2888
  importer.add_import("imported", "div{color:red}")
@@ -3287,6 +3133,13 @@ test_debug_inspects_sass_objects_inline.scss:1 DEBUG: (a: 1, b: 2)
3287
3133
  END
3288
3134
  end
3289
3135
 
3136
+ def test_error_throws_sass_objects
3137
+ assert_raise_message(Sass::SyntaxError, "(a: 1, b: 2)") {render("@error (a: 1, b: 2)")}
3138
+ assert_raise_message(Sass::SyntaxError, "(a: 1, b: 2)") do
3139
+ render("$map: (a: 1, b: 2); @error $map", :syntax => :scss)
3140
+ end
3141
+ end
3142
+
3290
3143
  def test_default_arg_before_splat
3291
3144
  assert_equal <<CSS, render(<<SASS, :syntax => :scss)
3292
3145
  .foo-positional {
@@ -3315,6 +3168,90 @@ CSS
3315
3168
  SASS
3316
3169
  end
3317
3170
 
3171
+ def test_keyframes
3172
+ assert_equal <<CSS, render(<<SASS)
3173
+ @keyframes identifier {
3174
+ 0% {
3175
+ top: 0;
3176
+ left: 0; }
3177
+ 30% {
3178
+ top: 50px; }
3179
+ 68%, 72% {
3180
+ left: 50px; }
3181
+ 100% {
3182
+ top: 100px;
3183
+ left: 100%; } }
3184
+ CSS
3185
+ @keyframes identifier
3186
+ 0%
3187
+ top: 0
3188
+ left: 0
3189
+ \#{"30%"}
3190
+ top: 50px
3191
+ 68%, 72%
3192
+ left: 50px
3193
+ 100%
3194
+ top: 100px
3195
+ left: 100%
3196
+ SASS
3197
+ end
3198
+
3199
+ def test_prefixed_keyframes
3200
+ assert_equal <<CSS, render(<<SASS)
3201
+ @-moz-keyframes identifier {
3202
+ 0% {
3203
+ top: 0;
3204
+ left: 0; }
3205
+ 30% {
3206
+ top: 50px; }
3207
+ 68%, 72% {
3208
+ left: 50px; }
3209
+ 100% {
3210
+ top: 100px;
3211
+ left: 100%; } }
3212
+ CSS
3213
+ @-moz-keyframes identifier
3214
+ 0%
3215
+ top: 0
3216
+ left: 0
3217
+ \#{"30%"}
3218
+ top: 50px
3219
+ 68%, 72%
3220
+ left: 50px
3221
+ 100%
3222
+ top: 100px
3223
+ left: 100%
3224
+ SASS
3225
+ end
3226
+
3227
+ def test_uppercase_keyframes
3228
+ assert_equal <<CSS, render(<<SASS)
3229
+ @KEYFRAMES identifier {
3230
+ 0% {
3231
+ top: 0;
3232
+ left: 0; }
3233
+ 30% {
3234
+ top: 50px; }
3235
+ 68%, 72% {
3236
+ left: 50px; }
3237
+ 100% {
3238
+ top: 100px;
3239
+ left: 100%; } }
3240
+ CSS
3241
+ @KEYFRAMES identifier
3242
+ 0%
3243
+ top: 0
3244
+ left: 0
3245
+ \#{"30%"}
3246
+ top: 50px
3247
+ 68%, 72%
3248
+ left: 50px
3249
+ 100%
3250
+ top: 100px
3251
+ left: 100%
3252
+ SASS
3253
+ end
3254
+
3318
3255
  private
3319
3256
 
3320
3257
  def assert_hash_has(hash, expected)