Skip to content

Commit 39b74fa

Browse files
committed
Fix negation case
1 parent 1795a25 commit 39b74fa

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/operators.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ function processOperation (left, right, operator) {
6868
// complex
6969
var outType = rightType;
7070
var vec = right;
71-
var scalar = left;
7271
var l = this.types[outType].length;
7372
if (/mat/.test(outType)) l *= this.types[this.types[outType].type].length;
7473
var operands = [];
@@ -82,9 +81,10 @@ function processOperation (left, right, operator) {
8281
operands.push(calculate(leftOp, rightOp, operator));
8382
}
8483

85-
var calcStr = this.types[rightType].length == 1 ? calculate('_', 'this', operator) : calculate('this', '_', operator);
84+
var calcStr = calculate(null, '_', operator);
8685
return Descriptor(
87-
`${vec}.map(function (_) {return ${calcStr};}, ${scalar})`, {
86+
`${vec}.map(function (_) {return ${calcStr};})`,
87+
{
8888
components: operands,
8989
type: outType,
9090
complexity: vec.complexity + l * (2) + 1

test/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,10 @@ test('vec3 f() { return vec3(3.); } vec3 x = -f();', function (t) {
522522
function f () {
523523
return [3., 3., 3.];
524524
};
525-
var x = f().map(function (_) {return this - _;}, null);
525+
var x = f().map(function (_) {return -_;});
526526
`)
527+
console.log()
528+
t.deepEqual(eval(t.name + ';x;'), [-3,-3,-3])
527529

528530
t.end()
529531
})

0 commit comments

Comments
 (0)