Skip to content

Commit

Permalink
Add specs for bracketed lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Apr 29, 2016
1 parent 2aa064d commit fa503bd
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/sass_3_5/bracket_lists/expected_output.css
@@ -0,0 +1,20 @@
.bracketed-lists {
empty: [];
single: [foo];
multiple: [foo, bar];
nested: [[foo], [[bar, baz]]];
space-separated: [foo bar baz];
trailing-comma: [foo, bar];
nth-comma: bar;
nth-space: bar;
comma-separator: comma;
space-separator: space;
set-nth: [foo, qux, baz];
append: [foo, bar, baz];
append-with-separator: [foo bar baz];
inspect-empty: [];
inspect-simple: [foo, bar];
inspect-nested-bracketed: [[foo]];
inspect-nested-unbracketed: [(foo bar)];
inspect-nested-unbracketed-comma: [foo bar,];
inspect-nested-unbracketed-singleton: [(foo,)]; }
28 changes: 28 additions & 0 deletions spec/sass_3_5/bracket_lists/input.scss
@@ -0,0 +1,28 @@
.bracketed-lists {
empty: [];
single: [foo];
multiple: [foo, bar];
nested: [[foo], [[bar, baz]]];
space-separated: [foo bar baz];
trailing-comma: [foo, bar,];

// List functions treat it like a list.
nth-comma: nth([foo, bar], 2);
nth-space: nth([foo bar], 2);
comma-separator: list-separator([foo, bar]);
space-separator: list-separator([foo bar]);

// List functions preserve bracketedness.
set-nth: set-nth([foo, bar, baz], 2, qux);
append: append([foo, bar], baz);
append-with-separator: append([foo, bar], baz, $separator: space);

// Inspection produces valid input. This also verifies that nested lists of
// various sorts are parsed properly.
inspect-empty: inspect([]);
inspect-simple: inspect([foo, bar]);
inspect-nested-bracketed: inspect([[foo]]);
inspect-nested-unbracketed: inspect([(foo bar)]);
inspect-nested-unbracketed-comma: inspect([foo bar,]);
inspect-nested-unbracketed-singleton: inspect([(foo,)]);
}
7 changes: 7 additions & 0 deletions spec/sass_3_5/functions/is_bracketed/expected_output.css
@@ -0,0 +1,7 @@
.is-bracketed {
unbracketed-empty: false;
unbracketed-singleton: false;
unbracketed-multiple: false;
bracketed-empty: true;
bracketed-singleton: true;
bracketed-multiple: true; }
8 changes: 8 additions & 0 deletions spec/sass_3_5/functions/is_bracketed/input.scss
@@ -0,0 +1,8 @@
.is-bracketed {
unbracketed-empty: is-bracketed(());
unbracketed-singleton: is-bracketed(foo);
unbracketed-multiple: is-bracketed(foo bar);
bracketed-empty: is-bracketed([]);
bracketed-singleton: is-bracketed([foo]);
bracketed-multiple: is-bracketed([foo bar]);
}
4 changes: 4 additions & 0 deletions spec/sass_3_5/functions/join/error/README.md
@@ -0,0 +1,4 @@
As of 3.5, `join()` is unique in that it takes multiple optional arguments that
can be passed independently of one another. This may necessitate unusual
implementation, so we go out of our way to verify that it disallows invalid
calls.
3 changes: 3 additions & 0 deletions spec/sass_3_5/functions/join/error/named/error
@@ -0,0 +1,3 @@
Error: Unknown argument $invalid (true) for `join'
on line 2 of /sass/spec/sass_3_5/functions/join/error/named/input.scss
Use --trace for backtrace.
Empty file.
2 changes: 2 additions & 0 deletions spec/sass_3_5/functions/join/error/named/input.scss
@@ -0,0 +1,2 @@
.join-named-error {
error: join(foo, bar, $invalid: true); }
1 change: 1 addition & 0 deletions spec/sass_3_5/functions/join/error/named/status
@@ -0,0 +1 @@
65
3 changes: 3 additions & 0 deletions spec/sass_3_5/functions/join/error/positional/error
@@ -0,0 +1,3 @@
Error: wrong number of arguments (5 for 2..4) for `join'
on line 2 of /sass/spec/sass_3_5/functions/join/error/positional/input.scss
Use --trace for backtrace.
Empty file.
2 changes: 2 additions & 0 deletions spec/sass_3_5/functions/join/error/positional/input.scss
@@ -0,0 +1,2 @@
.join-positional-error {
error: join(foo, bar, comma, true, false); }
1 change: 1 addition & 0 deletions spec/sass_3_5/functions/join/error/positional/status
@@ -0,0 +1 @@
65
3 changes: 3 additions & 0 deletions spec/sass_3_5/functions/join/error/positional_and_named/error
@@ -0,0 +1,3 @@
Error: wrong number of arguments (5 for 2..4) for `join'
on line 2 of /sass/spec/sass_3_5/functions/join/error/positional_and_named/input.scss
Use --trace for backtrace.
Empty file.
@@ -0,0 +1,2 @@
.join-positional-and-named-error {
error: join(foo, bar, comma, true, false, $invalid: true); }
@@ -0,0 +1 @@
65
11 changes: 11 additions & 0 deletions spec/sass_3_5/functions/join/valid/expected_output.css
@@ -0,0 +1,11 @@
.join {
both-bracketed: [foo bar baz bang];
first-bracketed: [foo bar baz bang];
second-bracketed: foo bar baz bang;
bracketed-true: [foo bar];
bracketed-false: foo bar;
separator-and-bracketed: [foo, bar];
bracketed-and-separator: [foo, bar];
separator-and-bracketed-positional: [foo, bar];
unusual-bracketed-type: [foo bar];
bracketed-null: foo bar; }
17 changes: 17 additions & 0 deletions spec/sass_3_5/functions/join/valid/input.scss
@@ -0,0 +1,17 @@
// 3.5 added the $bracketed parameter to join() and made it generally
// bracketed-list-aware.
.join {
both-bracketed: join([foo bar], [baz bang]);
first-bracketed: join([foo bar], baz bang);
second-bracketed: join(foo bar, [baz bang]);
bracketed-true: join(foo, bar, $bracketed: true);
bracketed-false: join([foo], [bar], $bracketed: false);
separator-and-bracketed: join(foo, bar, $separator: comma, $bracketed: true);
bracketed-and-separator: join(foo, bar, $bracketed: true, $separator: comma);
separator-and-bracketed-positional:
join(foo, bar, comma, true);

// All values are valid in boolean contexts.
unusual-bracketed-type: join(foo, bar, $bracketed: foo);
bracketed-null: join([foo], [bar], $bracketed: null);
}

0 comments on commit fa503bd

Please sign in to comment.