mirror of
https://github.com/less/less.js.git
synced 2026-01-21 05:08:10 -05:00
error tests and test detached rulesets without a mixin call
This commit is contained in:
@@ -30,7 +30,7 @@ tree.Rule.prototype = {
|
||||
},
|
||||
toCSS: tree.toCSS,
|
||||
eval: function (env) {
|
||||
var strictMathBypass = false, name = this.name;
|
||||
var strictMathBypass = false, name = this.name, evaldValue;
|
||||
if (typeof name !== "string") {
|
||||
// expand 'primitive' name directly to get
|
||||
// things faster (~10% for benchmark.less):
|
||||
@@ -43,14 +43,25 @@ tree.Rule.prototype = {
|
||||
env.strictMath = true;
|
||||
}
|
||||
try {
|
||||
evaldValue = this.value.eval(env);
|
||||
|
||||
if (!this.variable && evaldValue.type === "Ruleset") {
|
||||
console.log(this.index);
|
||||
throw { message: "Rulesets cannot be evaluated on a property.",
|
||||
index: this.index, filename: this.currentFileInfo.filename };
|
||||
}
|
||||
|
||||
return new(tree.Rule)(name,
|
||||
this.value.eval(env),
|
||||
evaldValue,
|
||||
this.important,
|
||||
this.merge,
|
||||
this.index, this.currentFileInfo, this.inline);
|
||||
}
|
||||
catch(e) {
|
||||
e.index = e.index || this.index;
|
||||
if (typeof e.index !== 'number') {
|
||||
e.index = this.index;
|
||||
e.filename = this.currentFileInfo.filename;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -42,3 +42,6 @@ html.lt-ie9 header {
|
||||
visible-one: visible;
|
||||
visible-two: visible;
|
||||
}
|
||||
.without-mixins {
|
||||
b: 1;
|
||||
}
|
||||
|
||||
@@ -56,3 +56,10 @@ header {
|
||||
test-func: unit(90px);
|
||||
test-arithmetic: unit((9+9), px);
|
||||
});
|
||||
// without mixins
|
||||
@ruleset-2: {
|
||||
b: 1;
|
||||
};
|
||||
.without-mixins {
|
||||
@ruleset-2();
|
||||
}
|
||||
|
||||
6
test/less/errors/detached-ruleset-1.less
Normal file
6
test/less/errors/detached-ruleset-1.less
Normal file
@@ -0,0 +1,6 @@
|
||||
@a: {
|
||||
b: 1;
|
||||
};
|
||||
.a {
|
||||
a: @a;
|
||||
}
|
||||
4
test/less/errors/detached-ruleset-1.txt
Normal file
4
test/less/errors/detached-ruleset-1.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
SyntaxError: Rulesets cannot be evaluated on a property. in {path}detached-ruleset-1.less on line 5, column 3:
|
||||
4 .a {
|
||||
5 a: @a;
|
||||
6 }
|
||||
6
test/less/errors/detached-ruleset-2.less
Normal file
6
test/less/errors/detached-ruleset-2.less
Normal file
@@ -0,0 +1,6 @@
|
||||
@a: {
|
||||
b: 1;
|
||||
};
|
||||
.a {
|
||||
a: @a();
|
||||
}
|
||||
4
test/less/errors/detached-ruleset-2.txt
Normal file
4
test/less/errors/detached-ruleset-2.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
ParseError: Unrecognised input in {path}detached-ruleset-2.less on line 5, column 3:
|
||||
4 .a {
|
||||
5 a: @a();
|
||||
6 }
|
||||
4
test/less/errors/detached-ruleset-3.less
Normal file
4
test/less/errors/detached-ruleset-3.less
Normal file
@@ -0,0 +1,4 @@
|
||||
@a: {
|
||||
b: 1;
|
||||
};
|
||||
@a();
|
||||
4
test/less/errors/detached-ruleset-3.txt
Normal file
4
test/less/errors/detached-ruleset-3.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
SyntaxError: properties must be inside selector blocks, they cannot be in the root. in {path}detached-ruleset-3.less on line 2, column 3:
|
||||
1 @a: {
|
||||
2 b: 1;
|
||||
3 };
|
||||
5
test/less/errors/detached-ruleset-4.less
Normal file
5
test/less/errors/detached-ruleset-4.less
Normal file
@@ -0,0 +1,5 @@
|
||||
.mixin-definition(@a: {
|
||||
b: 1;
|
||||
}) {
|
||||
@a();
|
||||
}
|
||||
3
test/less/errors/detached-ruleset-4.txt
Normal file
3
test/less/errors/detached-ruleset-4.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
ParseError: Unrecognised input in {path}detached-ruleset-4.less on line 1, column 18:
|
||||
1 .mixin-definition(@a: {
|
||||
2 b: 1;
|
||||
4
test/less/errors/detached-ruleset-5.less
Normal file
4
test/less/errors/detached-ruleset-5.less
Normal file
@@ -0,0 +1,4 @@
|
||||
.mixin-definition(@b) {
|
||||
@a();
|
||||
}
|
||||
.mixin-definition({color: red;});
|
||||
3
test/less/errors/detached-ruleset-5.txt
Normal file
3
test/less/errors/detached-ruleset-5.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
SyntaxError: variable @a is undefined in {path}detached-ruleset-5.less on line 4, column 1:
|
||||
3 }
|
||||
4 .mixin-definition({color: red;});
|
||||
5
test/less/errors/detached-ruleset-6.less
Normal file
5
test/less/errors/detached-ruleset-6.less
Normal file
@@ -0,0 +1,5 @@
|
||||
.a {
|
||||
b: {
|
||||
color: red;
|
||||
};
|
||||
}
|
||||
4
test/less/errors/detached-ruleset-6.txt
Normal file
4
test/less/errors/detached-ruleset-6.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
ParseError: Unrecognised input in {path}detached-ruleset-6.less on line 2, column 3:
|
||||
1 .a {
|
||||
2 b: {
|
||||
3 color: red;
|
||||
Reference in New Issue
Block a user