Add tests for interpreter directive with retainLines and sourcemaps.
This commit is contained in:
parent
442ead701c
commit
c0013264b7
@ -0,0 +1,2 @@
|
||||
#!env node
|
||||
var someFirstLine;
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["transform-strict-mode"],
|
||||
"retainLines": true
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
#!env node
|
||||
"use strict";
|
||||
var someFirstLine;
|
||||
@ -0,0 +1,3 @@
|
||||
#!env node
|
||||
|
||||
console.log("Hello, world!");
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceMap": true
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
#!env node
|
||||
console.log("Hello, world!");
|
||||
@ -0,0 +1,14 @@
|
||||
{
|
||||
"mappings": "AAEAA,QAAQC,GAAR,CAAY,eAAZ",
|
||||
"names": [
|
||||
"console",
|
||||
"log"
|
||||
],
|
||||
"sources": [
|
||||
"source-maps/interpreter-directive-prefix/input.js"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"\n\nconsole.log(\"Hello, world!\");"
|
||||
],
|
||||
"version": 3
|
||||
}
|
||||
3
packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/input.js
vendored
Executable file
3
packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/input.js
vendored
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env babel-node
|
||||
|
||||
import {spawn} from 'foobar';
|
||||
3
packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/options.json
vendored
Normal file
3
packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceType": "module"
|
||||
}
|
||||
156
packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/output.json
vendored
Normal file
156
packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/output.json
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ImportDeclaration",
|
||||
"start": 27,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ImportSpecifier",
|
||||
"start": 35,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"imported": {
|
||||
"type": "Identifier",
|
||||
"start": 35,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "spawn"
|
||||
},
|
||||
"name": "spawn"
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 35,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "spawn"
|
||||
},
|
||||
"name": "spawn"
|
||||
}
|
||||
}
|
||||
],
|
||||
"source": {
|
||||
"type": "StringLiteral",
|
||||
"start": 47,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "foobar",
|
||||
"raw": "'foobar'"
|
||||
},
|
||||
"value": "foobar"
|
||||
},
|
||||
"leadingComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": "/usr/bin/env babel-node",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": "/usr/bin/env babel-node",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
3
packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/input.js
vendored
Executable file
3
packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/input.js
vendored
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env babel-node
|
||||
|
||||
var { spawn } = x;
|
||||
192
packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/output.json
vendored
Normal file
192
packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/output.json
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 27,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 31,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 31,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 33,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 33,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "spawn"
|
||||
},
|
||||
"name": "spawn"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 33,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "spawn"
|
||||
},
|
||||
"name": "spawn"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": {
|
||||
"type": "Identifier",
|
||||
"start": 43,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var",
|
||||
"leadingComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": "/usr/bin/env babel-node",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": "/usr/bin/env babel-node",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user