Add tests for interpreter directive with retainLines and sourcemaps.

This commit is contained in:
Logan Smyth 2018-05-14 14:53:53 -07:00
parent 442ead701c
commit c0013264b7
14 changed files with 388 additions and 0 deletions

View File

@ -0,0 +1,2 @@
#!env node
var someFirstLine;

View File

@ -0,0 +1,4 @@
{
"plugins": ["transform-strict-mode"],
"retainLines": true
}

View File

@ -0,0 +1,3 @@
#!env node
"use strict";
var someFirstLine;

View File

@ -0,0 +1,3 @@
#!env node
console.log("Hello, world!");

View File

@ -0,0 +1,3 @@
{
"sourceMap": true
}

View File

@ -0,0 +1,2 @@
#!env node
console.log("Hello, world!");

View File

@ -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
}

View File

@ -0,0 +1,3 @@
#!/usr/bin/env babel-node
import {spawn} from 'foobar';

View File

@ -0,0 +1,3 @@
{
"sourceType": "module"
}

View 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
}
}
}
]
}

View File

@ -0,0 +1,3 @@
#!/usr/bin/env babel-node
var { spawn } = x;

View 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
}
}
}
]
}