sass 3.3.0.alpha.231 → 3.3.0.alpha.243

Sign up to get free protection for your applications and to get access to all the features.
@@ -975,6 +975,10 @@ MSG
975
975
  assert_equal("color", evaluate("type-of(#fff)"))
976
976
  assert_equal("color", evaluate("type-of($value: #fff)"))
977
977
  assert_equal("null", evaluate("type-of(null)"))
978
+ assert_equal("list", evaluate("type-of(1 2 3)"))
979
+ assert_equal("list", evaluate("type-of((1, 2, 3))"))
980
+ assert_equal("list", evaluate("type-of(())"))
981
+ assert_equal("map", evaluate("type-of((foo: bar))"))
978
982
  end
979
983
 
980
984
  def test_feature_exists
@@ -1024,6 +1028,8 @@ MSG
1024
1028
  assert_equal("1", evaluate("length(#f00)"))
1025
1029
  assert_equal("0", evaluate("length(())"))
1026
1030
  assert_equal("4", evaluate("length(1 2 () 3)"))
1031
+
1032
+ assert_equal("2", evaluate("length((foo: bar, bar: baz))"))
1027
1033
  end
1028
1034
 
1029
1035
  def test_nth
@@ -1041,6 +1047,9 @@ MSG
1041
1047
  assert_error_message("List index is 2 but list is only 1 item long for `nth'", "nth(foo, 2)")
1042
1048
  assert_error_message("List index is 1 but list has no items for `nth'", "nth((), 1)")
1043
1049
  assert_error_message("$n: \"foo\" is not a number for `nth'", "nth(1 2 3, foo)")
1050
+
1051
+ assert_equal("foo bar", evaluate("nth((foo: bar, bar: baz), 1)"))
1052
+ assert_equal("bar baz", evaluate("nth((foo: bar, bar: baz), 2)"))
1044
1053
  end
1045
1054
 
1046
1055
  def test_join
@@ -1080,6 +1089,19 @@ MSG
1080
1089
 
1081
1090
  assert_error_message("Separator name must be space, comma, or auto for `join'", "join(1, 2, baboon)")
1082
1091
  assert_error_message("$separator: 12 is not a string for `join'", "join(1, 2, 12)")
1092
+
1093
+ assert_equal("foo bar, bar baz, baz bip, bip bop",
1094
+ perform("join((foo: bar, bar: baz), (baz: bip, bip: bop))").to_sass)
1095
+ assert_equal("(foo bar) (bar baz) (baz bip) (bip bop)",
1096
+ perform("join((foo: bar, bar: baz), (baz: bip, bip: bop), space)").to_sass)
1097
+ assert_equal("foo bar (baz bip) (bip bop)",
1098
+ perform("join(foo bar, (baz: bip, bip: bop))").to_sass)
1099
+ assert_equal("foo bar, bar baz, bip, bop",
1100
+ perform("join((foo: bar, bar: baz), bip bop)").to_sass)
1101
+ assert_equal("baz bip, bip bop",
1102
+ perform("join((), (baz: bip, bip: bop))").to_sass)
1103
+ assert_equal("foo bar, bar baz",
1104
+ perform("join((foo: bar, bar: baz), ())").to_sass)
1083
1105
  end
1084
1106
 
1085
1107
  def test_append
@@ -1115,12 +1137,19 @@ MSG
1115
1137
 
1116
1138
  assert_error_message("Separator name must be space, comma, or auto for `append'", "append(1, 2, baboon)")
1117
1139
  assert_error_message("$separator: 12 is not a string for `append'", "append(1, 2, 12)")
1140
+
1141
+ assert_equal("1 2 (foo: bar)", perform("append(1 2, (foo: bar))").to_sass)
1142
+ assert_equal("foo bar, bar baz, 1", perform("append((foo: bar, bar: baz), 1)").to_sass)
1143
+ assert_equal("foo bar, bar baz, (baz: bip)",
1144
+ perform("append((foo: bar, bar: baz), (baz: bip))").to_sass)
1118
1145
  end
1119
1146
 
1120
1147
  def test_zip
1121
1148
  assert_equal("1 3 5, 2 4 6", evaluate("zip(1 2, 3 4, 5 6)"))
1122
1149
  assert_equal("1 4 7, 2 5 8", evaluate("zip(1 2 3, 4 5 6, 7 8)"))
1123
1150
  assert_equal("1 2 3", evaluate("zip(1, 2, 3)"))
1151
+ assert_equal("(foo bar) 1 3, (bar baz) 2 4",
1152
+ perform("zip((foo: bar, bar: baz), 1 2, 3 4)").to_sass)
1124
1153
  end
1125
1154
 
1126
1155
  def test_index
@@ -1131,6 +1160,9 @@ MSG
1131
1160
  assert_equal("false", evaluate("index(1px solid blue, 1em)"))
1132
1161
  assert_equal("false", evaluate("index(1px solid blue, notfound)"))
1133
1162
  assert_equal("false", evaluate("index(1px, #00f)"))
1163
+
1164
+ assert_equal("1", evaluate("index((foo: bar, bar: baz), (foo bar))"))
1165
+ assert_equal("false", evaluate("index((foo: bar, bar: baz), (foo: bar))"))
1134
1166
  end
1135
1167
 
1136
1168
  def test_list_separator
@@ -1141,6 +1173,8 @@ MSG
1141
1173
  assert_equal("space", evaluate("list-separator(#f00)"))
1142
1174
  assert_equal("space", evaluate("list-separator(())"))
1143
1175
  assert_equal("space", evaluate("list-separator(1 2 () 3)"))
1176
+
1177
+ assert_equal("comma", evaluate("list-separator((foo: bar, bar: baz))"))
1144
1178
  end
1145
1179
 
1146
1180
  def test_if
@@ -1224,6 +1258,98 @@ MSG
1224
1258
  end
1225
1259
  end
1226
1260
 
1261
+ def test_map_get
1262
+ assert_equal "1", evaluate("map-get((foo: 1, bar: 2), foo)")
1263
+ assert_equal "2", evaluate("map-get((foo: 1, bar: 2), bar)")
1264
+ assert_equal "null", perform("map-get((foo: 1, bar: 2), baz)").to_sass
1265
+ assert_equal "null", perform("map-get((), foo)").to_sass
1266
+
1267
+ assert_warning(<<WARNING) do
1268
+ DEPRECATION WARNING: Passing lists of pairs to map-get is deprecated and will
1269
+ be removed in future versions of Sass. Use Sass maps instead. For details, see
1270
+ http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1271
+ WARNING
1272
+ assert_equal "1", evaluate("map-get((foo 1) (bar 2), foo)")
1273
+ end
1274
+ end
1275
+
1276
+ def test_map_merge
1277
+ assert_equal("(foo: 1, bar: 2, baz: 3)",
1278
+ perform("map-merge((foo: 1, bar: 2), (baz: 3))").to_sass)
1279
+ assert_equal("(foo: 1, bar: 2)",
1280
+ perform("map-merge((), (foo: 1, bar: 2))").to_sass)
1281
+ assert_equal("(foo: 1, bar: 2)",
1282
+ perform("map-merge((foo: 1, bar: 2), ())").to_sass)
1283
+
1284
+ assert_warning(<<WARNING) do
1285
+ DEPRECATION WARNING: Passing lists of pairs to map-merge is deprecated and will
1286
+ be removed in future versions of Sass. Use Sass maps instead. For details, see
1287
+ http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1288
+ WARNING
1289
+ assert_equal("(foo: 1, bar: 2, baz: 3)",
1290
+ perform("map-merge((foo 1, bar 2), (baz: 3))").to_sass)
1291
+ end
1292
+
1293
+ assert_warning(<<WARNING) do
1294
+ DEPRECATION WARNING: Passing lists of pairs to map-merge is deprecated and will
1295
+ be removed in future versions of Sass. Use Sass maps instead. For details, see
1296
+ http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1297
+ WARNING
1298
+ assert_equal("(baz: 3, foo: 1, bar: 2)",
1299
+ perform("map-merge((baz: 3), (foo 1, bar 2))").to_sass)
1300
+ end
1301
+ end
1302
+
1303
+ def test_map_keys
1304
+ assert_equal("foo, bar",
1305
+ perform("map-keys((foo: 1, bar: 2))").to_sass)
1306
+ assert_equal("()", perform("map-keys(())").to_sass)
1307
+
1308
+ assert_warning(<<WARNING) do
1309
+ DEPRECATION WARNING: Passing lists of pairs to map-keys is deprecated and will
1310
+ be removed in future versions of Sass. Use Sass maps instead. For details, see
1311
+ http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1312
+ WARNING
1313
+ assert_equal("foo, bar",
1314
+ perform("map-keys((foo 1, bar 2))").to_sass)
1315
+ end
1316
+ end
1317
+
1318
+ def test_map_values
1319
+ assert_equal("1, 2", perform("map-values((foo: 1, bar: 2))").to_sass)
1320
+ assert_equal("1, 2, 2",
1321
+ perform("map-values((foo: 1, bar: 2, baz: 2))").to_sass)
1322
+ assert_equal("()", perform("map-values(())").to_sass)
1323
+
1324
+ assert_warning(<<WARNING) do
1325
+ DEPRECATION WARNING: Passing lists of pairs to map-values is deprecated and will
1326
+ be removed in future versions of Sass. Use Sass maps instead. For details, see
1327
+ http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1328
+ WARNING
1329
+ assert_equal("1, 2", perform("map-values((foo 1, bar 2))").to_sass)
1330
+ end
1331
+ end
1332
+
1333
+ def test_map_has_key
1334
+ assert_equal "true", evaluate("map-has-key((foo: 1, bar: 1), foo)")
1335
+ assert_equal "false", evaluate("map-has-key((foo: 1, bar: 1), baz)")
1336
+ assert_equal "false", evaluate("map-has-key((), foo)")
1337
+
1338
+ assert_warning(<<WARNING) do
1339
+ DEPRECATION WARNING: Passing lists of pairs to map-has-key is deprecated and will
1340
+ be removed in future versions of Sass. Use Sass maps instead. For details, see
1341
+ http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#maps.
1342
+ WARNING
1343
+ assert_equal("true", evaluate("map-has-key((foo 1, bar 1), foo)"))
1344
+ end
1345
+ end
1346
+
1347
+ def test_partial_list_of_pairs_doesnt_work_as_a_map
1348
+ assert_raises(Sass::SyntaxError) {evaluate("map-get((foo bar, baz bang, bip), 1)")}
1349
+ assert_raises(Sass::SyntaxError) {evaluate("map-get((foo bar, baz bang, bip bap bop), 1)")}
1350
+ assert_raises(Sass::SyntaxError) {evaluate("map-get((foo bar), 1)")}
1351
+ end
1352
+
1227
1353
  def test_assert_unit
1228
1354
  ctx = Sass::Script::Functions::EvaluationContext.new(Sass::Environment.new(nil, {}))
1229
1355
  ctx.assert_unit Sass::Script::Value::Number.new(10, ["px"], []), "px"
@@ -83,6 +83,22 @@ class SassScriptConversionTest < Test::Unit::TestCase
83
83
  assert_renders "foo(a, b, (a, b, c)...)"
84
84
  end
85
85
 
86
+ def test_map
87
+ assert_renders "(foo: bar)"
88
+ assert_renders "(foo: bar, baz: bip)"
89
+ assert_renders "(foo: bar, baz: (bip: bap))"
90
+ end
91
+
92
+ def test_map_in_list
93
+ assert_renders "(foo: bar) baz"
94
+ assert_renders "(foo: bar), (baz: bip)"
95
+ end
96
+
97
+ def test_list_in_map
98
+ assert_renders "(foo: bar baz)"
99
+ assert_renders "(foo: (bar, baz), bip: bop)"
100
+ end
101
+
86
102
  def self.test_precedence(outer, inner)
87
103
  op_outer = Sass::Script::Lexer::OPERATORS_REVERSE[outer]
88
104
  op_inner = Sass::Script::Lexer::OPERATORS_REVERSE[inner]
@@ -492,6 +492,47 @@ SASS
492
492
  assert_equal "1 2 3", resolve("null 1 2 3")
493
493
  end
494
494
 
495
+ def test_map_cannot_have_duplicate_keys
496
+ assert_raise_message(Sass::SyntaxError, 'Duplicate key "foo" in map (foo: bar, foo: baz).') do
497
+ eval("(foo: bar, foo: baz)")
498
+ end
499
+ assert_raise_message(Sass::SyntaxError, 'Duplicate key "foo" in map (foo: bar, fo + o: baz).') do
500
+ eval("(foo: bar, fo + o: baz)")
501
+ end
502
+ assert_raise_message(Sass::SyntaxError, 'Duplicate key "foo" in map (foo: bar, "foo": baz).') do
503
+ eval("(foo: bar, 'foo': baz)")
504
+ end
505
+ assert_raise_message(Sass::SyntaxError, 'Duplicate key 2px in map (2px: bar, 1px + 1px: baz).') do
506
+ eval("(2px: bar, 1px + 1px: baz)")
507
+ end
508
+ assert_raise_message(Sass::SyntaxError, 'Duplicate key #0000ff in map (blue: bar, blue: baz).') do
509
+ eval("(blue: bar, #00f: baz)")
510
+ end
511
+ end
512
+
513
+ def test_non_duplicate_map_keys
514
+ # These shouldn't throw errors
515
+ eval("(foo: foo, bar: bar)")
516
+ eval("(2px: foo, 2: bar)")
517
+ eval("(2px: foo, 2em: bar)")
518
+ eval("('2px': foo, 2px: bar)")
519
+ end
520
+
521
+ def test_map_syntax_errors
522
+ assert_raise_message(Sass::SyntaxError, 'Invalid CSS after "(foo:": expected expression (e.g. 1px, bold), was ")"') do
523
+ eval("(foo:)")
524
+ end
525
+ assert_raise_message(Sass::SyntaxError, 'Invalid CSS after "(": expected ")", was ":bar)"') do
526
+ eval("(:bar)")
527
+ end
528
+ assert_raise_message(Sass::SyntaxError, 'Invalid CSS after "(foo, bar": expected ")", was ": baz)"') do
529
+ eval("(foo, bar: baz)")
530
+ end
531
+ assert_raise_message(Sass::SyntaxError, 'Invalid CSS after "(foo: bar, baz": expected ":", was ")"') do
532
+ eval("(foo: bar, baz)")
533
+ end
534
+ end
535
+
495
536
  def test_deep_argument_error_not_unwrapped
496
537
  # JRuby (as of 1.6.7.2) offers no way of distinguishing between
497
538
  # argument errors caused by programming errors in a function and
@@ -262,6 +262,31 @@ c {
262
262
  SCSS
263
263
  end
264
264
 
265
+ def test_destructuring_each_directive
266
+ assert_equal <<CSS, render(<<SCSS)
267
+ a {
268
+ foo: 1px;
269
+ bar: 2px;
270
+ baz: 3px; }
271
+
272
+ c {
273
+ foo: "Value is bar";
274
+ bar: "Value is baz";
275
+ bang: "Value is "; }
276
+ CSS
277
+ a {
278
+ @each $name, $number in (foo: 1px, bar: 2px, baz: 3px) {
279
+ \#{$name}: $number;
280
+ }
281
+ }
282
+ c {
283
+ @each $key, $value in (foo bar) (bar, baz) bang {
284
+ \#{$key}: "Value is \#{$value}";
285
+ }
286
+ }
287
+ SCSS
288
+ end
289
+
265
290
  def test_css_import_directive
266
291
  assert_equal "@import url(foo.css);\n", render('@import "foo.css";')
267
292
  assert_equal "@import url(foo.css);\n", render("@import 'foo.css';")
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass
3
3
  version: !ruby/object:Gem::Version
4
- hash: 592302787
4
+ hash: 592302827
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 3
9
9
  - 0
10
10
  - alpha
11
- - 231
12
- version: 3.3.0.alpha.231
11
+ - 243
12
+ version: 3.3.0.alpha.243
13
13
  platform: ruby
14
14
  authors:
15
15
  - Nathan Weizenbaum
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2013-08-23 00:00:00 -04:00
22
+ date: 2013-08-29 00:00:00 -04:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -131,6 +131,7 @@ files:
131
131
  - lib/sass/script/tree/string_interpolation.rb
132
132
  - lib/sass/script/tree/unary_operation.rb
133
133
  - lib/sass/script/tree/variable.rb
134
+ - lib/sass/script/tree/map_literal.rb
134
135
  - lib/sass/script/value.rb
135
136
  - lib/sass/script/value/arg_list.rb
136
137
  - lib/sass/script/value/base.rb
@@ -140,6 +141,7 @@ files:
140
141
  - lib/sass/script/value/null.rb
141
142
  - lib/sass/script/value/number.rb
142
143
  - lib/sass/script/value/string.rb
144
+ - lib/sass/script/value/map.rb
143
145
  - lib/sass/scss.rb
144
146
  - lib/sass/scss/css_parser.rb
145
147
  - lib/sass/scss/parser.rb
@@ -155,9 +157,7 @@ files:
155
157
  - lib/sass/selector/simple_sequence.rb
156
158
  - lib/sass/shared.rb
157
159
  - lib/sass/supports.rb
158
- - lib/sass/source/map.rb
159
- - lib/sass/source/position.rb
160
- - lib/sass/source/range.rb
160
+ - lib/sass/version.rb
161
161
  - lib/sass/tree/charset_node.rb
162
162
  - lib/sass/tree/comment_node.rb
163
163
  - lib/sass/tree/content_node.rb
@@ -192,14 +192,16 @@ files:
192
192
  - lib/sass/tree/visitors/to_css.rb
193
193
  - lib/sass/tree/warn_node.rb
194
194
  - lib/sass/tree/while_node.rb
195
- - lib/sass/stack.rb
195
+ - lib/sass/source/map.rb
196
+ - lib/sass/source/position.rb
197
+ - lib/sass/source/range.rb
196
198
  - lib/sass/util/multibyte_string_scanner.rb
197
199
  - lib/sass/util/normalized_map.rb
198
200
  - lib/sass/util/ordered_hash.rb
199
201
  - lib/sass/util/subset_map.rb
200
202
  - lib/sass/util/test.rb
201
- - lib/sass/version.rb
202
203
  - lib/sass/features.rb
204
+ - lib/sass/stack.rb
203
205
  - bin/sass
204
206
  - bin/sass-convert
205
207
  - bin/scss