Skip to content

Commit

Permalink
test: encapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Oct 3, 2019
1 parent ebc6ad4 commit 74ee26f
Show file tree
Hide file tree
Showing 2 changed files with 272 additions and 26 deletions.
286 changes: 260 additions & 26 deletions test/snapshot/__snapshots__/encapsed.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,7 @@ Program {
"expression": Variable {
"curly": false,
"kind": "variable",
"name": Variable {
"curly": false,
"kind": "variable",
"name": "juice",
},
"name": "juice",
},
"kind": "encapsedpart",
"syntax": "simple",
Expand Down Expand Up @@ -248,16 +244,12 @@ Program {
EncapsedPart {
"curly": true,
"expression": Variable {
"curly": false,
"curly": true,
"kind": "variable",
"name": Variable {
"curly": true,
"curly": false,
"kind": "variable",
"name": Variable {
"curly": false,
"kind": "variable",
"name": "juice",
},
"name": "juice",
},
},
"kind": "encapsedpart",
Expand Down Expand Up @@ -308,18 +300,260 @@ Program {
},
EncapsedPart {
"curly": true,
"expression": Variable {
"curly": false,
"kind": "variable",
"name": Call {
"arguments": Array [],
"kind": "call",
"what": ClassReference {
"kind": "classreference",
"name": "call",
"resolution": "uqn",
"expression": Call {
"arguments": Array [],
"kind": "call",
"what": ClassReference {
"kind": "classreference",
"name": "call",
"resolution": "uqn",
},
},
"kind": "encapsedpart",
"syntax": "simple",
},
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": " string",
"unicode": false,
"value": " string",
},
"kind": "encapsedpart",
"syntax": null,
},
],
},
"kind": "expressionstatement",
},
],
"errors": Array [],
"kind": "program",
}
`;

exports[`encapsed dollar open curly braces #5 1`] = `
Program {
"children": Array [
ExpressionStatement {
"expression": Encapsed {
"kind": "encapsed",
"raw": "\\"string \${test[test]} string\\"",
"type": "string",
"value": Array [
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": "string ",
"unicode": false,
"value": "string ",
},
"kind": "encapsedpart",
"syntax": null,
},
EncapsedPart {
"curly": true,
"expression": OffsetLookup {
"kind": "offsetlookup",
"offset": ClassReference {
"kind": "classreference",
"name": "test",
"resolution": "uqn",
},
"what": Variable {
"curly": false,
"kind": "variable",
"name": "test",
},
},
"kind": "encapsedpart",
"syntax": "simple",
},
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": " string",
"unicode": false,
"value": " string",
},
"kind": "encapsedpart",
"syntax": null,
},
],
},
"kind": "expressionstatement",
},
],
"errors": Array [],
"kind": "program",
}
`;

exports[`encapsed dollar open curly braces #6 1`] = `
Program {
"children": Array [
ExpressionStatement {
"expression": Encapsed {
"kind": "encapsed",
"raw": "\\"string \${test[1]} string\\"",
"type": "string",
"value": Array [
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": "string ",
"unicode": false,
"value": "string ",
},
"kind": "encapsedpart",
"syntax": null,
},
EncapsedPart {
"curly": true,
"expression": OffsetLookup {
"kind": "offsetlookup",
"offset": Number {
"kind": "number",
"value": "1",
},
"what": Variable {
"curly": false,
"kind": "variable",
"name": "test",
},
},
"kind": "encapsedpart",
"syntax": "simple",
},
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": " string",
"unicode": false,
"value": " string",
},
"kind": "encapsedpart",
"syntax": null,
},
],
},
"kind": "expressionstatement",
},
],
"errors": Array [],
"kind": "program",
}
`;

exports[`encapsed dollar open curly braces #7 1`] = `
Program {
"children": Array [
ExpressionStatement {
"expression": Encapsed {
"kind": "encapsed",
"raw": "\\"string \${test[-1]} string\\"",
"type": "string",
"value": Array [
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": "string ",
"unicode": false,
"value": "string ",
},
"kind": "encapsedpart",
"syntax": null,
},
EncapsedPart {
"curly": true,
"expression": OffsetLookup {
"kind": "offsetlookup",
"offset": Unary {
"kind": "unary",
"type": "-",
"what": Number {
"kind": "number",
"value": "1",
},
},
"what": Variable {
"curly": false,
"kind": "variable",
"name": "test",
},
},
"kind": "encapsedpart",
"syntax": "simple",
},
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": " string",
"unicode": false,
"value": " string",
},
"kind": "encapsedpart",
"syntax": null,
},
],
},
"kind": "expressionstatement",
},
],
"errors": Array [],
"kind": "program",
}
`;

exports[`encapsed dollar open curly braces #8 1`] = `
Program {
"children": Array [
ExpressionStatement {
"expression": Encapsed {
"kind": "encapsed",
"raw": "\\"string \${test[$var]} string\\"",
"type": "string",
"value": Array [
EncapsedPart {
"curly": false,
"expression": String {
"isDoubleQuote": false,
"kind": "string",
"raw": "string ",
"unicode": false,
"value": "string ",
},
"kind": "encapsedpart",
"syntax": null,
},
EncapsedPart {
"curly": true,
"expression": OffsetLookup {
"kind": "offsetlookup",
"offset": Variable {
"curly": false,
"kind": "variable",
"name": "var",
},
"what": Variable {
"curly": false,
"kind": "variable",
"name": "test",
},
},
"kind": "encapsedpart",
"syntax": "simple",
Expand Down Expand Up @@ -370,9 +604,9 @@ Program {
EncapsedPart {
"curly": true,
"expression": Variable {
"curly": false,
"curly": "juice",
"kind": "variable",
"name": "juice",
"name": "variable",
},
"kind": "encapsedpart",
"syntax": "simple",
Expand Down Expand Up @@ -2620,9 +2854,9 @@ Program {
EncapsedPart {
"curly": true,
"expression": Variable {
"curly": false,
"curly": "var",
"kind": "variable",
"name": "var",
"name": "variable",
},
"kind": "encapsedpart",
"syntax": "simple",
Expand Down
12 changes: 12 additions & 0 deletions test/snapshot/encapsed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ describe("encapsed", function() {
it("dollar open curly braces #4", () => {
expect(parser.parseEval('"string ${call()} string";')).toMatchSnapshot();
});
it("dollar open curly braces #5", () => {
expect(parser.parseEval('"string ${test[test]} string";')).toMatchSnapshot();
});
it("dollar open curly braces #6", () => {
expect(parser.parseEval('"string ${test[1]} string";')).toMatchSnapshot();
});
it("dollar open curly braces #7", () => {
expect(parser.parseEval('"string ${test[-1]} string";')).toMatchSnapshot();
});
it("dollar open curly braces #8", () => {
expect(parser.parseEval('"string ${test[$var]} string";')).toMatchSnapshot();
});
it("curly", () => {
expect(parser.parseEval('"string {$juice} string";')).toMatchSnapshot();
});
Expand Down

0 comments on commit 74ee26f

Please sign in to comment.