Skip to content

Commit

Permalink
Added unit tests for detached rulesets. #186
Browse files Browse the repository at this point in the history
  • Loading branch information
jurcovicovam committed Jun 20, 2014
1 parent 821540a commit 1e2f3b2
Show file tree
Hide file tree
Showing 18 changed files with 217 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,48 @@
interpolation: "@{detached}";
}
//*** should this work? ****
.mixin() {
@detached: { extreme: simplicity; };
}
.selector {
@detached();
.mixin();
}
//********************************************88
.mixin() {
@detached: { scope: @see-here; };
}
.selector {
@see-here: yes;
.nested {
.mixin();
@detached();
}
}
//************************************************************
.mixin() {
@detached: { scope-detached: @see-here; };
.nested() {
scope-mixin: @see-here;
}
}
.definer-wrapper() {
@see-here: yes;
.mixin();
}
.selector {
.definer-wrapper();
@detached();
.nested();
}
//********************************************88
* test if it works from imported !!!!!!!!!!!!!!!!!!!!
* test if it works when variables copy detached forever !!!!!!!!!!!!!!!!!!!!
* test if it works from list correctly -- e.g. including various callers scopes
* test if @defaults works correctly -- e.g. including various callers scopes
*/
@Ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
selector {
property-1: passing-through;
property-2: in-unlocker;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#namespace {
@variable: in-unlocker;
.unlocker {
@detached-ruleset2: { property-2: @variable; };
}
}
#namespace > .unlocker();

@detached-ruleset1: { property-1: @variable; };
@list: @detached-ruleset1 @detached-ruleset2;

.mixin(@list) {
@detached1: extract(@list, 1);
@detached1();
@detached2: extract(@list, 2);
@detached2();
}

.indirect-mixin(@list) {
@variable: passing-through;
.mixin(@list);
}

selector {
@variable: in-caller;
.indirect-mixin(@list)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
selector {
property: passing-through;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@detached-ruleset1: { property: 1; };
@detached-ruleset2: { property: @variable; };
@list: @detached-ruleset1 @detached-ruleset2;

.mixin(@list) {
@detached: extract(@list, 2);
@detached();
}

.indirect-mixin(@list) {
@variable: passing-through;
.mixin(@list);
}

selector {
@variable: in-caller;
.indirect-mixin(@list)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
selector {
property-1: in-list-unlocker;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@detached-ruleset1: { property-1: @variable; };
.list-namespacer {
@variable: in-list-unlocker;
.listUnlocker {
@list: @detached-ruleset1 something-else;
}
}

.mixin(@list) {
@detached1: extract(@list, 1);
@detached1();
}

.indirect-mixin(@list) {
.mixin(@list);
}

selector {
.list-namespacer > .listUnlocker();
.indirect-mixin(@list)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
}
}
@media screen {
background: red;

.selector {
background: green;
}
Expand All @@ -29,6 +27,19 @@
padding: 0;
}
}
@media screen {
.outer {
background: red;
}
.outer .selector {
background: green;
}
}
@media screen and (min-width: 1200) {
.outer .selector {
padding: 0;
}
}
.mixin-with-arguments-enclosure .custom-mixin-argument {
custom: custom;
}
Expand All @@ -37,7 +48,7 @@
property: default;
property: global default;
}
.see-caller use-place {
.see-caller-local-win use-place {
caller-variable: declaration;
variable: declaration;
}
Expand All @@ -57,18 +68,18 @@
.custom {
property: custom;
}
.caller {
property: caller;
}
.caller .default {
property: caller;
property-in-caller: caller;
}
.caller .custom {
property: custom;
property-in-caller: custom;
}
.caller .default {
property-overwritten: overwritten;
}
.caller {
value: in detached;
}
.selector-indirect {
color: #aabbcc;
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
@one-rule: { background: red; };
@ruleset: { .selector { background: green; } };
@ruleset-second: { .selector { size: 2; } };
@media: { @media (min-width: 1200) { .selector { padding: 0; }} };
@media-var: { @media (min-width: 1200) { .selector { padding: 0; }} };

@empty: {};

//call on top
@ruleset();
@empty();
@media();
@media-var();

//call from ruleset
.call-with-parentheses {
@empty();
@one-rule();
@ruleset();
@media();
@media-var();
}

//call from media
@media screen {
@empty();
@one-rule();
@ruleset();
@media();
@media-var();
}

.outer {
@media screen {
@empty();
@one-rule();
@ruleset();
@media-var();
}
}

//mixin arguments
Expand Down Expand Up @@ -56,7 +64,7 @@
}

//scope - local win
.see-caller {
.see-caller-local-win {
@detached-ruleset: {
caller-variable: @variable;
.mixin();
Expand Down Expand Up @@ -128,7 +136,7 @@

@with-mixin-caller-default: {
.mixin(@parameter: @caller-default) {
property: @parameter;
property-in-caller: @parameter;
}
.default {
.mixin();
Expand All @@ -137,9 +145,19 @@
.mixin(custom);
}
};
@with-mixin-caller-default-overwritten: {
@caller-default:overwritten;
.mixin(@parameter: @caller-default) {
property-overwritten: @parameter;
}
.default {
.mixin();
}
};
.caller {
@caller-default: caller;
@with-mixin-caller-default();
@with-mixin-caller-default-overwritten();
}

//unlock mixin see things defined in his scope first
Expand All @@ -158,7 +176,7 @@
//detached returned from mixin
.return-detached() {
@color: #aabbcc;
@detached: {color: @color;}
@detached: {color: @color;};
}
.selector-indirect {
.return-detached();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//does not exists
.does-not-exists {
!#error#!
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Errors produced by compilation of testCase
ERROR 3:2 Could not find detached ruleset for "@does-not-exists".
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//does not exists
.does-not-exists {
@does-not-exists();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
b: {
color: red;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
visible-one: @b;
visible-two: @c;
}
};
}

.wrap-mixin({
color: black;
Expand Down Expand Up @@ -45,7 +45,7 @@ header {

.wrap-mixin-calls-wrap(@ruleset) {
.wrap-mixin(@ruleset);
};
}

.wrap-mixin({
test: extra-wrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
}
.selector-indirect {
color: #ff0000;
}
.multiple-imports .selector {
scope: yes;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//can mixin find detached ruleset in callers scope?
.whoReallyCalls(@detached) {
@detached();
}
Expand Down Expand Up @@ -25,3 +26,17 @@
@detached: { color: @color; };
}

//does it sees through multiple imports?
.multiple-imports {
.mixin() {
@detached: { scope: @see-here; };
}
.definer-wrapper() {
@see-here: yes;
.mixin();
}
.selector {
.definer-wrapper();
@detached();
}
}
6 changes: 2 additions & 4 deletions src/test/resources/minitests/debug1.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@keyframes /* 1 */ sunrise {
h1 {
color: #ff00ff;
}
.wrap-selector {
visible-one: visible;
}
Loading

0 comments on commit 1e2f3b2

Please sign in to comment.