From 34df55f754c313621052f1ec02fe0f1d3e2b0b99 Mon Sep 17 00:00:00 2001 From: jurcovicovam Date: Sat, 28 Jun 2014 22:47:22 +0200 Subject: [PATCH] Added unit tests #186 --- .../expressions/ExpressionsEvaluator.java | 6 +-- .../less4j/compiler/DetachedRulesetsTest.java | 5 --- .../detached-rulesets-as-argument.css | 10 ++++- .../detached-rulesets-as-argument.err | 3 +- .../detached-rulesets-as-argument.less | 40 ++++++++++++++----- 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/github/sommeri/less4j/core/compiler/expressions/ExpressionsEvaluator.java b/src/main/java/com/github/sommeri/less4j/core/compiler/expressions/ExpressionsEvaluator.java index 9731f685..812f1d32 100644 --- a/src/main/java/com/github/sommeri/less4j/core/compiler/expressions/ExpressionsEvaluator.java +++ b/src/main/java/com/github/sommeri/less4j/core/compiler/expressions/ExpressionsEvaluator.java @@ -168,8 +168,8 @@ public Expression evaluate(IndirectVariable input) { printer.append(reference); String realName = printer.toString(); - Variable realVariable = new Variable(input.getUnderlyingStructure(), "@" + realName); - return evaluate(realVariable); + Variable directVariable = new Variable(input.getUnderlyingStructure(), "@" + realName); + return evaluate(directVariable); } public Expression evaluate(Expression input) { @@ -207,11 +207,9 @@ public Expression evaluate(Expression input) { case EMBEDDED_SCRIPT: return evaluate((EmbeddedScript) input); - //FIXME: !!!!!!!!!!! now, this is probably wrong, just hotefixing prototype case DETACHED_RULESET: return evaluate((DetachedRuleset) input); - //the value is already there, nothing to evaluate -- TODO - probably bug, should create clone() case IDENTIFIER_EXPRESSION: case COLOR_EXPRESSION: case NUMBER: diff --git a/src/test/java/com/github/sommeri/less4j/compiler/DetachedRulesetsTest.java b/src/test/java/com/github/sommeri/less4j/compiler/DetachedRulesetsTest.java index 7b765c9b..7b236b7e 100644 --- a/src/test/java/com/github/sommeri/less4j/compiler/DetachedRulesetsTest.java +++ b/src/test/java/com/github/sommeri/less4j/compiler/DetachedRulesetsTest.java @@ -5,11 +5,6 @@ import org.junit.runners.Parameterized.Parameters; -/* - * TODO: test if @defaults works correctly -- e.g. including various callers scopes -* TODO: test order detached mixin imports who sees who and who overwrites who -* FIXME: !!!!!!!!!!!!! test mixin returned from detached ruleset - */ public class DetachedRulesetsTest extends BasicFeaturesTest { private static final String standardCases = "src/test/resources/compile-basic-features/detached-rulesets/"; diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.css b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.css index 4bfc3056..abe34c66 100644 --- a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.css +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.css @@ -1,6 +1,12 @@ -.default-mixin-argument { +#basic-case .default-mixin-argument { default: default; } -.custom-mixin-argument { +#basic-case .custom-mixin-argument { custom: custom; +} +#sees-caller-scope .default-mixin-argument { + from-default: sees; +} +#sees-caller-scope .custom-mixin-argument { + from-custom: sees; } \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.err b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.err index 13919355..ce4324fc 100644 --- a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.err +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.err @@ -1,2 +1,3 @@ Warnings produced by compilation of testCase -WARNING 1:20 This works, but is incompatible with less.js. Less.js does not allow detached rulesets as default mixin parameter values. \ No newline at end of file +WARNING 2:22 This works, but is incompatible with less.js. Less.js does not allow detached rulesets as default mixin parameter values. +WARNING 16:22 This works, but is incompatible with less.js. Less.js does not allow detached rulesets as default mixin parameter values. \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.less b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.less index ab4efd87..629f083b 100644 --- a/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.less +++ b/src/test/resources/compile-basic-features/detached-rulesets/detached-rulesets-as-argument.less @@ -1,11 +1,33 @@ -.mixin(@parameter: {default: default;}) { - @parameter(); +#basic-case { + .mixin(@parameter: {default: default;}) { + @parameter(); + } + + .default-mixin-argument { + .mixin(); + } + + .custom-mixin-argument { + .mixin({custom: custom;}); + } } - -.default-mixin-argument { - .mixin(); -} - -.custom-mixin-argument { - .mixin({custom: custom;}); +//sees-caller-scope +#sees-caller-scope { + .mixin(@parameter: {.inCaller();}) { + @parameter(); + } + + .default-mixin-argument { + .inCaller() { + from-default: sees; + } + .mixin(); + } + + .custom-mixin-argument { + .inCaller() { + from-custom: sees; + } + .mixin({.inCaller();}); + } } \ No newline at end of file