Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Tests for assignment/mutation of import.meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed May 28, 2017
1 parent 826ced9 commit 60ac623
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import.meta = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"throws": "Invalid left-hand side in assignment expression (1:0)",
"sourceType": "module",
"plugins": ["dynamicImport", "importMeta"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ const x = import.meta;
const url = import.meta.url;
import.meta;
import.meta.url;
import.meta.couldBeMutable = true;
141 changes: 135 additions & 6 deletions test/fixtures/experimental/import-meta/valid-in-module/expected.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"type": "File",
"start": 0,
"end": 81,
"end": 116,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 16
"line": 5,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 81,
"end": 116,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 16
"line": 5,
"column": 34
}
},
"sourceType": "module",
Expand Down Expand Up @@ -419,6 +419,135 @@
},
"computed": false
}
},
{
"type": "ExpressionStatement",
"start": 82,
"end": 116,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 34
}
},
"expression": {
"type": "AssignmentExpression",
"start": 82,
"end": 115,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 33
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 82,
"end": 108,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 26
}
},
"object": {
"type": "MetaProperty",
"start": 82,
"end": 93,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 11
}
},
"meta": {
"type": "Identifier",
"start": 82,
"end": 88,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 6
},
"identifierName": "import"
},
"name": "import"
},
"property": {
"type": "Identifier",
"start": 89,
"end": 93,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 11
},
"identifierName": "meta"
},
"name": "meta"
}
},
"property": {
"type": "Identifier",
"start": 94,
"end": 108,
"loc": {
"start": {
"line": 5,
"column": 12
},
"end": {
"line": 5,
"column": 26
},
"identifierName": "couldBeMutable"
},
"name": "couldBeMutable"
},
"computed": false
},
"right": {
"type": "BooleanLiteral",
"start": 111,
"end": 115,
"loc": {
"start": {
"line": 5,
"column": 29
},
"end": {
"line": 5,
"column": 33
}
},
"value": true
}
}
}
],
"directives": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ const x = import.meta;
const url = import.meta.url;
import.meta;
import.meta.url;
import.meta.couldBeMutable = true;
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"type": "File",
"start": 0,
"end": 81,
"end": 116,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 16
"line": 5,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 81,
"end": 116,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 16
"line": 5,
"column": 34
}
},
"sourceType": "module",
Expand Down Expand Up @@ -419,6 +419,135 @@
},
"computed": false
}
},
{
"type": "ExpressionStatement",
"start": 82,
"end": 116,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 34
}
},
"expression": {
"type": "AssignmentExpression",
"start": 82,
"end": 115,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 33
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 82,
"end": 108,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 26
}
},
"object": {
"type": "MetaProperty",
"start": 82,
"end": 93,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 11
}
},
"meta": {
"type": "Identifier",
"start": 82,
"end": 88,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 6
},
"identifierName": "import"
},
"name": "import"
},
"property": {
"type": "Identifier",
"start": 89,
"end": 93,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 11
},
"identifierName": "meta"
},
"name": "meta"
}
},
"property": {
"type": "Identifier",
"start": 94,
"end": 108,
"loc": {
"start": {
"line": 5,
"column": 12
},
"end": {
"line": 5,
"column": 26
},
"identifierName": "couldBeMutable"
},
"name": "couldBeMutable"
},
"computed": false
},
"right": {
"type": "BooleanLiteral",
"start": 111,
"end": 115,
"loc": {
"start": {
"line": 5,
"column": 29
},
"end": {
"line": 5,
"column": 33
}
},
"value": true
}
}
}
],
"directives": []
Expand Down

0 comments on commit 60ac623

Please sign in to comment.