Skip to content

Commit 162e8e8

Browse files
committed
glayzzle#345 - test byref list assign
1 parent 0ab0cbd commit 162e8e8

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Test syntax parsing with PHP 73 support https://wiki.php.net/rfc/list_reference_assignment 1`] = `
4+
Program {
5+
"children": Array [
6+
ExpressionStatement {
7+
"expression": Assign {
8+
"kind": "assign",
9+
"left": List {
10+
"items": Array [
11+
Variable {
12+
"curly": false,
13+
"kind": "variable",
14+
"name": "a",
15+
},
16+
ByRef {
17+
"kind": "byref",
18+
"what": Variable {
19+
"curly": false,
20+
"kind": "variable",
21+
"name": "b",
22+
},
23+
},
24+
],
25+
"kind": "list",
26+
"shortForm": true,
27+
},
28+
"operator": "=",
29+
"right": Variable {
30+
"curly": false,
31+
"kind": "variable",
32+
"name": "array",
33+
},
34+
},
35+
"kind": "expressionstatement",
36+
},
37+
ExpressionStatement {
38+
"expression": Assign {
39+
"kind": "assign",
40+
"left": List {
41+
"items": Array [
42+
Variable {
43+
"curly": false,
44+
"kind": "variable",
45+
"name": "a",
46+
},
47+
ByRef {
48+
"kind": "byref",
49+
"what": Variable {
50+
"curly": false,
51+
"kind": "variable",
52+
"name": "b",
53+
},
54+
},
55+
],
56+
"kind": "list",
57+
"shortForm": false,
58+
},
59+
"operator": "=",
60+
"right": Variable {
61+
"curly": false,
62+
"kind": "variable",
63+
"name": "array",
64+
},
65+
},
66+
"kind": "expressionstatement",
67+
},
68+
],
69+
"errors": Array [],
70+
"kind": "program",
71+
}
72+
`;

test/snapshot/php73.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const parser = require('../main');
2+
3+
describe('Test syntax parsing with PHP 73 support', function() {
4+
5+
it('https://wiki.php.net/rfc/list_reference_assignment', function() {
6+
var ast = parser.parseEval('[$a, &$b] = $array; list($a, &$b) = $array;', {
7+
parser: {
8+
php7: true,
9+
php74: false
10+
}
11+
});
12+
expect(ast).toMatchSnapshot();
13+
});
14+
});

0 commit comments

Comments
 (0)