Skip to content

Commit 3b5bdc1

Browse files
test: assign by ref
1 parent f4f4a67 commit 3b5bdc1

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/parser/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module.exports = {
116116
const result = cb();
117117
if (result) {
118118
this.ast.swapLocations(result, byref, result, this);
119-
result.byref = true;
119+
result.byref = true;
120120
}
121121
return result;
122122
},

test/snapshot/__snapshots__/assign.test.js.snap

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,30 @@ Program {
397397
"kind": "program",
398398
}
399399
`;
400+
401+
exports[`assign with ref 1`] = `
402+
Program {
403+
"children": Array [
404+
ExpressionStatement {
405+
"expression": Assign {
406+
"kind": "assign",
407+
"left": Variable {
408+
"curly": false,
409+
"kind": "variable",
410+
"name": "bar",
411+
},
412+
"operator": "=",
413+
"right": Variable {
414+
"byref": true,
415+
"curly": false,
416+
"kind": "variable",
417+
"name": "foo",
418+
},
419+
},
420+
"kind": "expressionstatement",
421+
},
422+
],
423+
"errors": Array [],
424+
"kind": "program",
425+
}
426+
`;

test/snapshot/assign.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ describe('assign', () => {
4646
it('>>=', () => {
4747
expect(parser.parseEval("$var >>= $var;")).toMatchSnapshot();
4848
});
49+
it('with ref', () => {
50+
expect(parser.parseEval("$bar = &$foo;")).toMatchSnapshot();
51+
});
4952
});

0 commit comments

Comments
 (0)