Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e63dbaa646 | ||
|
|
4a720625d9 | ||
|
|
ad428b107a | ||
|
|
c0299320f0 | ||
|
|
efaee3d5d9 | ||
|
|
12bee73070 | ||
|
|
82c18a837d | ||
|
|
fed51e8246 | ||
|
|
71f17e464f |
@@ -11,11 +11,17 @@
|
||||
|
||||
_Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
## 3.2.1
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix block scoping transformer rewriting breaks and continues to inner labels.
|
||||
|
||||
## 3.2.0
|
||||
|
||||
* **Bug Fix**
|
||||
* Fixed scope tracking for default parameters IIFE.
|
||||
* Fixed block scoped functions.
|
||||
* Improved `bin/6to5` path resolution.
|
||||
* **New Feature**
|
||||
* You can now trigger super setters in classes. Thanks [@kruppel](https://github.com/kruppel)!
|
||||
* Add `resolveSourceMap` option.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var commander = require("commander");
|
||||
var transform = require("../../lib/6to5/transformation/transform");
|
||||
var transform = require("../../lib/6to5/transformation");
|
||||
var util = require("../../lib/6to5/util");
|
||||
var fs = require("fs");
|
||||
var each = require("lodash/collection/each");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var transform = module.exports = require("./transformation/transform");
|
||||
var transform = module.exports = require("./transformation");
|
||||
|
||||
transform.version = require("../../package").version;
|
||||
|
||||
|
||||
@@ -1,7 +1,31 @@
|
||||
//exports.canRun = function (ast, userAgent) {
|
||||
module.exports = detect;
|
||||
|
||||
//};
|
||||
//var useragent = require("useragent");
|
||||
var traverse = require("../traverse");
|
||||
|
||||
//exports.whoCanRun = function (ast, userAgent) {
|
||||
var SYNTAX_KEYS = require("./syntax-keys");
|
||||
var visitors = traverse.explode(require("./visitors"));
|
||||
|
||||
//};
|
||||
function detect(ast) {
|
||||
var stats = {
|
||||
syntax: {},
|
||||
builtins: {}
|
||||
};
|
||||
|
||||
var detectedSyntax = function (name) {
|
||||
stats.syntax[name] = true;
|
||||
};
|
||||
|
||||
traverse(ast, {
|
||||
enter: function (node, parent) {
|
||||
if (SYNTAX_KEYS[node.type]) {
|
||||
detectedSyntax(SYNTAX_KEYS[node.type]);
|
||||
}
|
||||
|
||||
var visitor = visitors[node.type];
|
||||
if (visitor) visitor(node, parent, detectedSyntax);
|
||||
}
|
||||
});
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
84
lib/6to5/detection/syntax-keys.json
Normal file
84
lib/6to5/detection/syntax-keys.json
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"ArrowFunctionExpression": "es6.arrowFunctions",
|
||||
|
||||
"AwaitExpression": "es7.asyncFunctions",
|
||||
|
||||
"ClassBody": "es6.classes",
|
||||
"ClassDeclaration": "es6.classes",
|
||||
"ClassExpression": "es6.classes",
|
||||
"MethodDefinition": "es6.classes",
|
||||
|
||||
"ComprehensionBlock": "es7.comprehensions",
|
||||
"ComprehensionExpression": "es7.comprehensions",
|
||||
|
||||
"ForOfStatement": "es6.forOf",
|
||||
|
||||
"ExportBatchSpecifier": "es6.modules",
|
||||
"ExportDeclaration": "es6.modules",
|
||||
"ExportSpecifier": "es6.modules",
|
||||
"ImportBatchSpecifier": "es6.modules",
|
||||
"ImportDeclaration": "es6.modules",
|
||||
"ImportSpecifier": "es6.modules",
|
||||
|
||||
"ArrayPattern": "es6.destructuring",
|
||||
"AssignmentPattern": "es6.destructuring",
|
||||
"ObjectPattern": "es6.destructuring",
|
||||
|
||||
"RestElement": "es6.parameters.rest",
|
||||
|
||||
"SpreadElement": "es6.spread",
|
||||
|
||||
"SpreadProperty": "es7.objectSpread",
|
||||
|
||||
"TaggedTemplateExpression": "es6.templateLiterals",
|
||||
"TemplateElement": "es6.templateLiterals",
|
||||
"TemplateLiteral": "es6.templateLiterals",
|
||||
|
||||
"VirtualPropertyExpression": "es7.abstractReferences",
|
||||
"PrivateDeclaration": "es7.abstractReferences",
|
||||
|
||||
"YieldExpression": "es6.generators",
|
||||
|
||||
"AnyTypeAnnotation": "flow",
|
||||
"ArrayTypeAnnotation": "flow",
|
||||
"BooleanTypeAnnotation": "flow",
|
||||
"ClassProperty": "flow",
|
||||
"DeclareClass": "flow",
|
||||
"DeclareFunction": "flow",
|
||||
"DeclareModule": "flow",
|
||||
"DeclareVariable": "flow",
|
||||
"FunctionTypeAnnotation": "flow",
|
||||
"FunctionTypeParam": "flow",
|
||||
"GenericTypeAnnotation": "flow",
|
||||
"InterfaceExtends": "flow",
|
||||
"InterfaceDeclaration": "flow",
|
||||
"IntersectionTypeAnnotation": "flow",
|
||||
"NullableTypeAnnotation": "flow",
|
||||
"NumberTypeAnnotation": "flow",
|
||||
"StringLiteralTypeAnnotation": "flow",
|
||||
"StringTypeAnnotation": "flow",
|
||||
"TupleTypeAnnotation": "flow",
|
||||
"TypeofTypeAnnotation": "flow",
|
||||
"TypeAlias": "flow",
|
||||
"TypeAnnotation": "flow",
|
||||
"TypeParameterDeclaration": "flow",
|
||||
"TypeParameterInstantiation": "flow",
|
||||
"ObjectTypeAnnotation": "flow",
|
||||
"ObjectTypeCallProperty": "flow",
|
||||
"ObjectTypeIndexer": "flow",
|
||||
"ObjectTypeProperty": "flow",
|
||||
"QualifiedTypeIdentifier": "flow",
|
||||
"UnionTypeAnnotation": "flow",
|
||||
"VoidTypeAnnotation": "flow",
|
||||
|
||||
"JSXAttribute": "jsx",
|
||||
"JSXClosingElement": "jsx",
|
||||
"JSXElement": "jsx",
|
||||
"JSXEmptyExpression": "jsx",
|
||||
"JSXExpressionContainer": "jsx",
|
||||
"JSXIdentifier": "jsx",
|
||||
"JSXMemberExpression": "jsx",
|
||||
"JSXNamespacedName": "jsx",
|
||||
"JSXOpeningElement": "jsx",
|
||||
"JSXSpreadAttribute": "jsx"
|
||||
}
|
||||
54
lib/6to5/detection/visitors.js
Normal file
54
lib/6to5/detection/visitors.js
Normal file
@@ -0,0 +1,54 @@
|
||||
var t = require("../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.AssignmentExpression = function (node, parent, detected) {
|
||||
if (node.operator === "**=") {
|
||||
detected("es6.exponentation");
|
||||
}
|
||||
};
|
||||
|
||||
exports.BinaryExpression = function (node, parent, detected) {
|
||||
if (node.operator === "**") {
|
||||
detected("es6.exponentation");
|
||||
}
|
||||
};
|
||||
|
||||
exports.VariableDeclaration = function (node, parent, detected) {
|
||||
if (node.kind === "let" || node.kind === "const") {
|
||||
detected("es6.blockScoping");
|
||||
}
|
||||
|
||||
if (node.kind === "const") {
|
||||
detected("es6.constants");
|
||||
}
|
||||
};
|
||||
|
||||
exports.Property = function (node, parent, detected) {
|
||||
if (node.shorthand || node.method) {
|
||||
detected("es6.properties.shorthand");
|
||||
}
|
||||
|
||||
if (node.kind === "set" || node.kind === "get") {
|
||||
detected("es5.properties.mutators");
|
||||
}
|
||||
|
||||
if (node.computed) {
|
||||
detected("es6.properties.computed");
|
||||
}
|
||||
};
|
||||
|
||||
exports.AssignmentPattern = function (node, parent, detected) {
|
||||
if (t.isFunction(parent) && _.contains(parent.params, node)) {
|
||||
detected("es6.parameters.default");
|
||||
}
|
||||
};
|
||||
|
||||
exports.Function = function (node, parent, detected) {
|
||||
if (node.generator) {
|
||||
detected("es6.generators");
|
||||
}
|
||||
|
||||
if (node.async) {
|
||||
detected("es7.asyncFunctions");
|
||||
}
|
||||
};
|
||||
@@ -4,8 +4,8 @@ module.exports = File;
|
||||
|
||||
var SHEBANG_REGEX = /^\#\!.*/;
|
||||
|
||||
var transform = require("./transformation/transform");
|
||||
var generate = require("./generation/generator");
|
||||
var transform = require("./transformation");
|
||||
var generate = require("./generation");
|
||||
var clone = require("./helpers/clone");
|
||||
var Scope = require("./traverse/scope");
|
||||
var util = require("./util");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var transform = require("./transformation/transform");
|
||||
var transform = require("./transformation");
|
||||
var util = require("./util");
|
||||
var fs = require("fs");
|
||||
var isFunction = require("lodash/lang/isFunction");
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
module.exports = Transformer;
|
||||
|
||||
var TransformerPass = require("./transformer-pass");
|
||||
var t = require("../types");
|
||||
var isFunction = require("lodash/lang/isFunction");
|
||||
var traverse = require("../traverse");
|
||||
var isObject = require("lodash/lang/isObject");
|
||||
var each = require("lodash/collection/each");
|
||||
|
||||
@@ -31,6 +31,8 @@ Transformer.prototype.normalise = function (transformer) {
|
||||
transformer = { ast: transformer };
|
||||
}
|
||||
|
||||
traverse.explode(transformer);
|
||||
|
||||
each(transformer, function (fns, type) {
|
||||
// hidden property
|
||||
if (type[0] === "_") {
|
||||
@@ -46,13 +48,6 @@ Transformer.prototype.normalise = function (transformer) {
|
||||
if (!fns.exit) fns.exit = function () { };
|
||||
|
||||
transformer[type] = fns;
|
||||
|
||||
var aliases = t.FLIPPED_ALIAS_KEYS[type];
|
||||
if (aliases) {
|
||||
each(aliases, function (alias) {
|
||||
transformer[alias] = fns;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return transformer;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
var traverse = require("../../../traverse");
|
||||
var object = require("../../../helpers/object");
|
||||
var clone = require("lodash/lang/clone");
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
var values = require("lodash/object/values");
|
||||
@@ -311,9 +310,9 @@ var loopVisitor = {
|
||||
var replace;
|
||||
|
||||
if (t.isLoop(node)) {
|
||||
state = clone(state);
|
||||
state.ignoreLabeless = true;
|
||||
traverse(node, loopVisitor, scope, state);
|
||||
state.ignoreLabeless = false;
|
||||
}
|
||||
|
||||
if (t.isFunction(node) || t.isLoop(node)) {
|
||||
@@ -324,9 +323,15 @@ var loopVisitor = {
|
||||
|
||||
if (loopText) {
|
||||
if (node.label) {
|
||||
// we shouldn't be transforming this because it exists somewhere inside
|
||||
if (state.innerLabels.indexOf(node.label.name) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
loopText = loopText + "|" + node.label.name;
|
||||
} else {
|
||||
// we shouldn't be dealing with this
|
||||
// we shouldn't be transforming these statements because
|
||||
// they don't refer to the actual loop we're scopifying
|
||||
if (state.ignoreLabeless) return;
|
||||
|
||||
// break statements mean something different in this context
|
||||
@@ -352,6 +357,14 @@ var loopVisitor = {
|
||||
}
|
||||
};
|
||||
|
||||
var loopLabelVisitor = {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isLabeledStatement(node)) {
|
||||
state.innerLabels.push(node.label.name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If we're inside of a loop then traverse it and check if it has one of
|
||||
* the following node types `ReturnStatement`, `BreakStatement`,
|
||||
@@ -365,12 +378,15 @@ LetScoping.prototype.checkLoop = function () {
|
||||
var state = {
|
||||
hasBreakContinue: false,
|
||||
ignoreLabeless: false,
|
||||
innerLabels: [],
|
||||
hasReturn: false,
|
||||
isLoop: !!this.loopParent,
|
||||
map: {}
|
||||
};
|
||||
|
||||
traverse(this.block, loopLabelVisitor, this.scope, state);
|
||||
traverse(this.block, loopVisitor, this.scope, state);
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
|
||||
@@ -237,6 +237,20 @@ traverse.removeProperties = function (tree) {
|
||||
return tree;
|
||||
};
|
||||
|
||||
traverse.explode = function (obj) {
|
||||
for (var type in obj) {
|
||||
var fns = obj[type];
|
||||
|
||||
var aliases = t.FLIPPED_ALIAS_KEYS[type];
|
||||
if (aliases) {
|
||||
for (var i = 0; i < aliases.length; i++) {
|
||||
obj[aliases[i]] = fns;
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
function hasBlacklistedType(node, parent, scope, context, state) {
|
||||
if (node.type === state.type) {
|
||||
state.has = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "3.2.0",
|
||||
"version": "3.2.1",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://6to5.org/",
|
||||
"repository": "6to5/6to5",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5-runtime",
|
||||
"description": "6to5 selfContained runtime",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.0",
|
||||
"repository": "6to5/6to5",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var transform = require("../lib/6to5/transformation/transform");
|
||||
var transform = require("../lib/6to5/transformation");
|
||||
var File = require("../lib/6to5/file");
|
||||
var util = require("../lib/6to5/util");
|
||||
var fs = require("fs");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var genHelpers = require("./_generator-helpers");
|
||||
var transform = require("../lib/6to5/transformation/transform");
|
||||
var transform = require("../lib/6to5/transformation");
|
||||
var sourceMap = require("source-map");
|
||||
var codeFrame = require("../lib/6to5/helpers/code-frame");
|
||||
var esvalid = require("esvalid");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var transform = require("../lib/6to5/transformation/transform");
|
||||
var transform = require("../lib/6to5/transformation");
|
||||
var assert = require("assert");
|
||||
var File = require("../lib/6to5/file");
|
||||
|
||||
|
||||
140
test/detection.js
Normal file
140
test/detection.js
Normal file
@@ -0,0 +1,140 @@
|
||||
var detect = require("../lib/6to5/detection");
|
||||
var assert = require("assert");
|
||||
var util = require("../lib/6to5/util");
|
||||
|
||||
suite("detection", function () {
|
||||
var checkSyntax = function (code, name) {
|
||||
var ast = util.parse({
|
||||
experimental: true
|
||||
}, code);
|
||||
|
||||
assert.ok(detect(ast).syntax[name]);
|
||||
};
|
||||
|
||||
test("es5.properties.mutators", function () {
|
||||
checkSyntax("var obj = { get foo() {} };", "es5.properties.mutators");
|
||||
checkSyntax("var obj = { set foo() {} };", "es5.properties.mutators");
|
||||
});
|
||||
|
||||
test("es6.exponentation", function () {
|
||||
checkSyntax("x ** 2;", "es6.exponentation");
|
||||
checkSyntax("x **= 2;", "es6.exponentation");
|
||||
});
|
||||
|
||||
test("es6.blockScoping", function () {
|
||||
checkSyntax("let foo;", "es6.blockScoping");
|
||||
checkSyntax("let foo = bar;", "es6.blockScoping");
|
||||
checkSyntax("const foo = bar;", "es6.blockScoping");
|
||||
});
|
||||
|
||||
test("es6.constants", function () {
|
||||
checkSyntax("const foo = bar;", "es6.constants");
|
||||
});
|
||||
|
||||
test("es6.properties.shorthand", function () {
|
||||
checkSyntax("var obj = { foo };", "es6.properties.shorthand");
|
||||
checkSyntax("var obj = { foo };", "es6.properties.shorthand");
|
||||
});
|
||||
|
||||
test("es6.properties.computed", function () {
|
||||
checkSyntax("var obj = { [foo]: bar };", "es6.properties.computed");
|
||||
checkSyntax("var obj = { ['foo']: bar };", "es6.properties.computed");
|
||||
});
|
||||
|
||||
test("es6.parameters.default", function () {
|
||||
checkSyntax("var obj = (foo = bar) => {};", "es6.parameters.default");
|
||||
checkSyntax("var obj = function (foo = bar) {};", "es6.parameters.default");
|
||||
checkSyntax("function foo(foo = bar) {}", "es6.parameters.default");
|
||||
});
|
||||
|
||||
test("es6.arrowFunctions", function () {
|
||||
checkSyntax("var foo = x => x;", "es6.arrowFunctions");
|
||||
checkSyntax("var foo = x => { return x * x };", "es6.arrowFunctions");
|
||||
checkSyntax("var foo = (x) => x;", "es6.arrowFunctions");
|
||||
checkSyntax("var foo = (a, b) => { return a * b };", "es6.arrowFunctions");
|
||||
});
|
||||
|
||||
test("es6.classes", function () {
|
||||
checkSyntax("class Foo {}", "es6.classes");
|
||||
checkSyntax("var Foo = class {};", "es6.classes");
|
||||
});
|
||||
|
||||
test("es6.forOf", function () {
|
||||
checkSyntax("for (var val of foo);", "es6.forOf");
|
||||
checkSyntax("for (val of foo);", "es6.forOf");
|
||||
});
|
||||
|
||||
test("es6.modules", function () {
|
||||
checkSyntax("import 'foo';", "es6.modules");
|
||||
checkSyntax("import foo from 'foo';", "es6.modules");
|
||||
checkSyntax("import * as foo from 'foo';", "es6.modules");
|
||||
checkSyntax("import { foo } from 'foo';", "es6.modules");
|
||||
checkSyntax("export { foo } from 'foo';", "es6.modules");
|
||||
checkSyntax("export var foo = 5;", "es6.modules");
|
||||
checkSyntax("export class Foo {}", "es6.modules");
|
||||
checkSyntax("export function foo() {}", "es6.modules");
|
||||
checkSyntax("export default class Foo {}", "es6.modules");
|
||||
checkSyntax("export default function foo() {}", "es6.modules");
|
||||
});
|
||||
|
||||
test("es6.destructuring", function () {
|
||||
checkSyntax("[a, b] = [];", "es6.destructuring");
|
||||
checkSyntax("var [a, b] = [];", "es6.destructuring");
|
||||
checkSyntax("({ a, b }) = {};", "es6.destructuring");
|
||||
checkSyntax("var { a, b } = {};", "es6.destructuring");
|
||||
checkSyntax("function foo(foo = bar) {}", "es6.destructuring");
|
||||
});
|
||||
|
||||
test("es6.parameters.rest", function () {
|
||||
checkSyntax("function foo(...items) {}", "es6.parameters.rest");
|
||||
checkSyntax("var foo = (...items) => {}", "es6.parameters.rest");
|
||||
});
|
||||
|
||||
test("es6.spread", function () {
|
||||
checkSyntax("new Foo(...items);", "es6.spread");
|
||||
checkSyntax("foo(...items);", "es6.spread");
|
||||
checkSyntax("[...items];", "es6.spread");
|
||||
});
|
||||
|
||||
test("es6.templateLiterals", function () {
|
||||
checkSyntax("`foobar`;", "es6.templateLiterals");
|
||||
checkSyntax("foobar`foobar`;", "es6.templateLiterals");
|
||||
});
|
||||
|
||||
test("es6.generators", function () {
|
||||
checkSyntax("function* foo() {}", "es6.generators");
|
||||
checkSyntax("var foo = function* () {};", "es6.generators");
|
||||
});
|
||||
|
||||
test("es7.asyncFunctions", function () {
|
||||
checkSyntax("async function foo() {}", "es7.asyncFunctions");
|
||||
checkSyntax("var foo = async function() {};", "es7.asyncFunctions");
|
||||
checkSyntax("var foo = async () => {};", "es7.asyncFunctions");
|
||||
});
|
||||
|
||||
test("es7.comprehensions", function () {
|
||||
checkSyntax("[for (i of test) i]", "es7.comprehensions");
|
||||
checkSyntax("(for (i of test) i)", "es7.comprehensions");
|
||||
});
|
||||
|
||||
test("es7.objectSpread", function () {
|
||||
checkSyntax("var foo = { ...bar };", "es7.objectSpread");
|
||||
});
|
||||
|
||||
test("es7.abstractReferences", function () {
|
||||
checkSyntax("class Foo { private A; }", "es7.abstractReferences");
|
||||
checkSyntax("foo::bar();", "es7.abstractReferences");
|
||||
checkSyntax("delete foo::bar;", "es7.abstractReferences");
|
||||
checkSyntax("foo::bar;", "es7.abstractReferences");
|
||||
checkSyntax("foo::bar = baz;", "es7.abstractReferences");
|
||||
});
|
||||
|
||||
test("flow", function () {
|
||||
|
||||
});
|
||||
|
||||
test("jsx", function () {
|
||||
checkSyntax("<div />", "jsx");
|
||||
checkSyntax("<Element />", "jsx");
|
||||
});
|
||||
});
|
||||
14
test/fixtures/transformation/es6-block-scoping-exec/nested-labels-4.js
vendored
Normal file
14
test/fixtures/transformation/es6-block-scoping-exec/nested-labels-4.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
(function () {
|
||||
var stack = [];
|
||||
|
||||
loop1:
|
||||
for (let j = 0; j < 10; j++) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
stack.push(() => [i, j]);
|
||||
break loop1;
|
||||
}
|
||||
}
|
||||
|
||||
assert.deepEqual(stack.length, 1);
|
||||
assert.deepEqual(stack[0](), [0, 0]);
|
||||
})();
|
||||
@@ -1,11 +0,0 @@
|
||||
if (true) {
|
||||
const x = 1;
|
||||
switch (x) {
|
||||
case 1: {
|
||||
function y() {
|
||||
assert(x, 1);
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
var generate = require("../lib/6to5/generation/generator");
|
||||
var generate = require("../lib/6to5/generation");
|
||||
var assert = require("assert");
|
||||
var helper = require("./_helper");
|
||||
var util = require("../lib/6to5/util");
|
||||
|
||||
@@ -2,7 +2,7 @@ require("./_helper").assertVendor("compat-table");
|
||||
|
||||
require("../polyfill");
|
||||
|
||||
var transform = require("../lib/6to5/transformation/transform");
|
||||
var transform = require("../lib/6to5/transformation");
|
||||
var assert = require("assert");
|
||||
var data = require("../vendor/compat-table/data-es6");
|
||||
var _ = require("lodash");
|
||||
|
||||
@@ -2,7 +2,7 @@ if (!process.env.ALL_6TO5_TESTS) return;
|
||||
|
||||
require("./_helper").assertVendor("regenerator");
|
||||
|
||||
var transform = require("../lib/6to5/transformation/transform");
|
||||
var transform = require("../lib/6to5/transformation");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ if (process.env.SIMPLE_6TO5_TESTS) return;
|
||||
|
||||
require("./_helper").assertVendor("test262");
|
||||
|
||||
var transform = require("../lib/6to5/transformation/transform");
|
||||
var transform = require("../lib/6to5/transformation");
|
||||
var readdir = require("fs-readdir-recursive");
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
|
||||
@@ -12,44 +12,4 @@ suite("types", function () {
|
||||
assert.ok(!t.isFalsyExpression(t.literal(5)));
|
||||
assert.ok(!t.isFalsyExpression(t.identifier("foobar")));
|
||||
});
|
||||
|
||||
test("toSequenceExpression");
|
||||
|
||||
test("shallowEqual");
|
||||
|
||||
test("appendToMemberExpression");
|
||||
|
||||
test("prependToMemberExpression");
|
||||
|
||||
test("isDynamic");
|
||||
|
||||
test("isReferenced");
|
||||
|
||||
test("isValidIdentifier");
|
||||
|
||||
test("toIdentifier");
|
||||
|
||||
test("ensureBlock");
|
||||
|
||||
test("toStatement");
|
||||
|
||||
test("toBlock");
|
||||
|
||||
test("getUid");
|
||||
|
||||
test("getIds");
|
||||
|
||||
test("isLet");
|
||||
|
||||
test("isVar");
|
||||
|
||||
test("removeComments");
|
||||
|
||||
test("inheritsComments");
|
||||
|
||||
test("inherits");
|
||||
|
||||
test("getSpecifierName");
|
||||
|
||||
test("isSpecifierDefault");
|
||||
});
|
||||
|
||||
20
test/util.js
20
test/util.js
@@ -22,6 +22,10 @@ suite("util", function () {
|
||||
assert.ok(util.canCompile("/test.es"));
|
||||
assert.ok(util.canCompile("/scripts/test.es"));
|
||||
|
||||
assert.ok(util.canCompile("test.jsx"));
|
||||
assert.ok(util.canCompile("/test.jsx"));
|
||||
assert.ok(util.canCompile("/scripts/test.jsx"));
|
||||
|
||||
assert.ok(!util.canCompile("test"));
|
||||
assert.ok(!util.canCompile("test.css"));
|
||||
assert.ok(!util.canCompile("/test.css"));
|
||||
@@ -75,24 +79,8 @@ suite("util", function () {
|
||||
}, /illegal type for regexify/);
|
||||
});
|
||||
|
||||
test("getIds");
|
||||
|
||||
test("toStatement");
|
||||
|
||||
test("toBlock");
|
||||
|
||||
test("toIdentifier", function () {
|
||||
assert.equal(t.toIdentifier(t.identifier("swag")), "swag");
|
||||
assert.equal(t.toIdentifier("swag-lord"), "swagLord");
|
||||
});
|
||||
|
||||
test("isDynamic");
|
||||
|
||||
test("isReferenced");
|
||||
|
||||
test("removeProperties");
|
||||
|
||||
test("ensureBlock");
|
||||
|
||||
test("pushMutatorMap");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user