Skip to content

Commit

Permalink
Preparing unit tests for #186 (detached rulesets)
Browse files Browse the repository at this point in the history
  • Loading branch information
meri committed Apr 9, 2014
1 parent a9b4a2a commit d0d1d99
Show file tree
Hide file tree
Showing 8 changed files with 423 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/test/java/com/github/sommeri/less4j/SimpleCssTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* from the master branch.
*
*/
@Ignore
//@Ignore
@RunWith(Parameterized.class)
public class SimpleCssTest extends AbstractFileBasedTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
selector {
property: 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@detached-ruleset1: { property: 1; };
@detached-ruleset2: { property: 2; };
@list: @detached-ruleset1 @detached-ruleset2;

selector {
@set: extract(@list, 2);
@set();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.selector {
background: green;
}
@media (min-width: 1200) {
.selector {
padding: 0;
}
}
.call-with-parentheses {
background: red;
}
.call-with-parentheses .selector {
background: green;
}
@media (min-width: 1200) {
.call-with-parentheses .selector {
padding: 0;
}
}
@media screen {
background: red;

.selector {
background: green;
}
}
@media screen and (min-width: 1200) {
.selector {
padding: 0;
}
}
.mixin-with-arguments-enclosure .custom-mixin-argument {
custom: custom;
}
.see-caller use-place {
caller-variable: value;
property: default;
property: global default;
}
.see-caller use-place {
caller-variable: declaration;
variable: declaration;
}
.see-caller-caller use-place {
property: default;
property: global default;
}
.default {
property: default;
}
.custom {
property: custom;
}
.default {
property: global default;
}
.custom {
property: custom;
}
.caller {
property: caller;
}
.caller .default {
property: caller;
}
.caller .custom {
property: custom;
}
.caller {
value: in detached;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
@one-rule: { background: red; };
@ruleset: { .selector { background: green; } };
@ruleset-second: { .selector { size: 2; } };
@media: { @media (min-width: 1200) { .selector { padding: 0; }} };

@empty: {};

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

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

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

//mixin arguments
.mixin-with-arguments-enclosure {
.mixin(@parameter) {
@parameter();
}

.custom-mixin-argument {
.mixin({custom: custom;});
}
}

//scope - see caller
.see-caller {
@detached-ruleset: {
caller-variable: @variable;
.mixin();
};

use-place {
@detached-ruleset();

//define variable and mixin
@variable: value;
.mixin() {
position: caller;
}
}
}

//scope - local win
.see-caller {
@detached-ruleset: {
caller-variable: @variable;
.mixin();
};

@variable: declaration;
.mixin() {
variable: declaration;
}

use-place {
@detached-ruleset();

//define variable and mixin
@variable: value;
.mixin() {
position: caller;
}
}
}
//scope - called mixin sees things from detached
.see-caller-caller {
@detached-ruleset: {
@variable: in detached;
.mixin();
.in-detached() {
sees: me;
}
};

use-place {
@detached-ruleset();

//define variable and mixin
.mixin() {
position: @variable;
.in-detached();
}
}
}

//detached with mixin
@with-mixin-default: {
.mixin(@parameter: default) {
property: @parameter;
}
.default {
.mixin();
}
.custom {
.mixin(custom);
}
};
@with-mixin-default();

@global-default: global default;
@with-mixin-global-default: {
.mixin(@parameter: @global-default) {
property: @parameter;
}
.default {
.mixin();
}
.custom {
.mixin(custom);
}
};
@with-mixin-global-default();

@with-mixin-caller-default: {
.mixin(@parameter: @caller-default) {
property: @parameter;
}
.default {
.mixin();
}
.custom {
.mixin(custom);
}
};
.caller {
@caller-default: caller;
@with-mixin-caller-default();
}
//unlock mixin see things defined in his scope first
@with-mixin-unlocking: {
.mixin() {
value: @value;
}
@value: in detached;
};
.caller {
@value: caller;
@with-mixin-unlocking();
.mixin();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.mixin(@parameter: {default: default;}) {
@parameter();
}

.default-mixin-argument {
.mixin();
}

.custom-mixin-argument {
.mixin({custom: custom;});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.wrap-selector {
color: black;
one: 1px;
four: magic-frame;
visible-one: visible;
visible-two: visible;
}
.wrap-selector {
color: red;
visible-one: visible;
visible-two: visible;
}
.wrap-selector {
color: black;
background: white;
visible-one: visible;
visible-two: visible;
}
header {
background: blue;
}
@media screen and (min-width: 1200) {
header {
background: red;
}
}
html.lt-ie9 header {
background: red;
}
.wrap-selector {
test: extra-wrap;
visible-one: visible;
visible-two: visible;
}
.wrap-selector .wrap-selector {
test: wrapped-twice;
visible-one: visible;
visible-two: visible;
}
.wrap-selector {
test-func: 90;
test-arithmetic: 18px;
visible-one: visible;
visible-two: visible;
}
.without-mixins {
b: 1;
}
@media (orientation: portrait) and tv {
.my-selector {
background-color: black;
}
}
@media (orientation: portrait) and widescreen and print and tv {
.triple-wrapped-mq {
triple: true;
}
}
@media (orientation: portrait) and widescreen and tv {
.triple-wrapped-mq {
triple: true;
}
}
@media (orientation: portrait) and tv {
.triple-wrapped-mq {
triple: true;
}
}
.a {
test: test;
}
Loading

0 comments on commit d0d1d99

Please sign in to comment.