diff --git a/src/test/java/com/github/sommeri/less4j/SimpleCssTest.java b/src/test/java/com/github/sommeri/less4j/SimpleCssTest.java index 30cba7c1..e5a27935 100644 --- a/src/test/java/com/github/sommeri/less4j/SimpleCssTest.java +++ b/src/test/java/com/github/sommeri/less4j/SimpleCssTest.java @@ -19,7 +19,7 @@ * from the master branch. * */ -@Ignore +//@Ignore @RunWith(Parameterized.class) public class SimpleCssTest extends AbstractFileBasedTest { diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-ruleset-in-list.css b/src/test/resources/compile-basic-features/detached-rulesets/detached-ruleset-in-list.css new file mode 100644 index 00000000..56a74cb1 --- /dev/null +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-ruleset-in-list.css @@ -0,0 +1,3 @@ +selector { + property: 2; +} diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-ruleset-in-list.less b/src/test/resources/compile-basic-features/detached-rulesets/detached-ruleset-in-list.less new file mode 100644 index 00000000..29dc0054 --- /dev/null +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-ruleset-in-list.less @@ -0,0 +1,8 @@ +@detached-ruleset1: { property: 1; }; +@detached-ruleset2: { property: 2; }; +@list: @detached-ruleset1 @detached-ruleset2; + +selector { + @set: extract(@list, 2); + @set(); +} \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-basics.css b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-basics.css new file mode 100644 index 00000000..decc2c38 --- /dev/null +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-basics.css @@ -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; +} diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-basics.less b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-basics.less new file mode 100644 index 00000000..122d7aa4 --- /dev/null +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-basics.less @@ -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(); +} diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-incompatible.less b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-incompatible.less new file mode 100644 index 00000000..9439f803 --- /dev/null +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-incompatible.less @@ -0,0 +1,11 @@ +.mixin(@parameter: {default: default;}) { + @parameter(); +} + +.default-mixin-argument { + .mixin(); +} + +.custom-mixin-argument { + .mixin({custom: custom;}); +} \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-lessjs.css b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-lessjs.css new file mode 100644 index 00000000..8d4be02b --- /dev/null +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-lessjs.css @@ -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; +} diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-lessjs.less b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-lessjs.less new file mode 100644 index 00000000..3c004c47 --- /dev/null +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-lessjs.less @@ -0,0 +1,103 @@ +@ruleset: { + color: black; + background: white; + }; + +@a: 1px; +.wrap-mixin(@ruleset) { + @a: hidden and if you see this in the output its a bug; + @b: visible; + @d: magic-frame; // same behaviour as mixin calls - falls back to this frame + .wrap-selector { + @c: visible; + @ruleset(); + visible-one: @b; + visible-two: @c; + } +}; + +.wrap-mixin({ + color: black; + one: @a; + @b: hidden and if you see this in the output its a bug; + @c: hidden and if you see this in the output its a bug; + four: @d; +}); + +.wrap-mixin(@ruleset: { + color: red; +}); + +.wrap-mixin(@ruleset); + +.desktop-and-old-ie(@rules) { + @media screen and (min-width: 1200) { @rules(); } + html.lt-ie9 & { @rules(); } +} + +header { + background: blue; + + .desktop-and-old-ie({ + background: red; + }); +} + +.wrap-mixin-calls-wrap(@ruleset) { + .wrap-mixin(@ruleset); +}; + +.wrap-mixin({ + test: extra-wrap; + .wrap-mixin-calls-wrap({ + test: wrapped-twice; + }); +}); + +.wrap-mixin({ + test-func: unit(90px); + test-arithmetic: unit((9+9), px); +}); +// without mixins +@ruleset-2: { + b: 1; +}; +.without-mixins { + @ruleset-2(); +} +@my-ruleset: { + .my-selector { + @media tv { + background-color: black; + } + } + }; +@media (orientation:portrait) { + @my-ruleset(); + .wrap-media-mixin({ + @media tv { + .triple-wrapped-mq { + triple: true; + } + } + }); +} +.wrap-media-mixin(@ruleset) { + @media widescreen { + @media print { + @ruleset(); + } + @ruleset(); + } + @ruleset(); +} +// unlocking mixins +@my-mixins: { + .mixin() { + test: test; + } +}; +@my-mixins(); +.a { + .mixin(); +} \ No newline at end of file