first commit

This commit is contained in:
Sebastian McKenzie
2014-09-28 23:39:22 +10:00
commit c97696c224
167 changed files with 2007 additions and 0 deletions

7
test/api.js Normal file
View File

@@ -0,0 +1,7 @@
suite("api", function () {
test("whitelist");
test("blacklist");
test("tolerant");
});

51
test/classes.js Normal file
View File

@@ -0,0 +1,51 @@
var transform = require("../lib/6to5/transform");
var assert = require("assert");
suite("classes", function () {
test("no calling super properties", function () {
assert.throws(function () {
transform.test([
"class Test extends Foo {",
" constructor() {",
" super.test.whatever();",
" }",
"}"
]);
}, /cannot access super properties/, "unexpected error");
});
test("no accessing super properties", function () {
assert.throws(function () {
transform.test([
"class Test extends Foo {",
" constructor() {",
" super.test.whatever;",
" }",
"}"
]);
}, /cannot access super properties/, "unexpected error");
});
test("accessing super without having one", function () {
assert.throws(function () {
transform.test([
"class Test {",
" constructor() {",
" super();",
" }",
"}"
]);
}, /cannot access super as this class has none/, "unexpected error");
});
test("defining constructor as a mutator", function () {
assert.throws(function () {
transform.test([
"class Test {",
" get constructor() {",
" }",
"}"
]);
}, /unknown kind for constructor method/, "unexpected error");
});
});

3
test/errors.js Normal file
View File

@@ -0,0 +1,3 @@
suite("errors", function () {
});

View File

@@ -0,0 +1 @@
var t = () => 5 + 5;

View File

@@ -0,0 +1,3 @@
var t = function () {
return 5 + 5;
};

View File

@@ -0,0 +1 @@
var t = () => {};

View File

@@ -0,0 +1,2 @@
var t = function () {
};

View File

@@ -0,0 +1 @@
arr.map(i => i + 1);

View File

@@ -0,0 +1,3 @@
arr.map(function (i) {
return i + 1;
});

View File

@@ -0,0 +1 @@
var t = (i, x) => i * x;

View File

@@ -0,0 +1,3 @@
var t = function (i, x) {
return i * x;
};

View File

@@ -0,0 +1 @@
var t = i => i * 5;

View File

@@ -0,0 +1,3 @@
var t = function (i) {
return i * 5;
};

View File

@@ -0,0 +1 @@
var t = (i) => i * 5;

View File

@@ -0,0 +1,3 @@
var t = function (i) {
return i * 5;
};

View File

@@ -0,0 +1 @@
var t = x => this.x + x;

View File

@@ -0,0 +1,3 @@
var t = function (x) {
return this.x + x;
}.bind(this);

View File

@@ -0,0 +1,5 @@
{
let val = 1;
let multiplier = 5;
console.log(val * multiplier);
}

View File

@@ -0,0 +1,7 @@
{
(function () {
var val = 1;
var multiplier = 5;
console.log(val * multiplier);
}());
}

View File

@@ -0,0 +1,4 @@
{
let val = 1;
console.log(val * 2);
}

View File

@@ -0,0 +1,6 @@
{
(function () {
var val = 1;
console.log(val * 2);
}());
}

View File

@@ -0,0 +1,4 @@
(function () {
let i = 5;
console.log(i);
}());

View File

@@ -0,0 +1,4 @@
(function () {
var i = 5;
console.log(i);
}());

View File

@@ -0,0 +1,3 @@
for (let i = 0; i < 9; i++) {
console.log(i);
}

View File

@@ -0,0 +1,5 @@
(function () {
for (var i = 0; i < 9; i++) {
console.log(i);
}
}());

View File

@@ -0,0 +1,5 @@
var arr = [1, 2, 3];
for (let i in arr) {
let val = arr[i];
console.log(val * 2);
}

View File

@@ -0,0 +1,13 @@
var arr = [
1,
2,
3
];
(function () {
for (var i in arr) {
(function () {
var val = arr[i];
console.log(val * 2);
}());
}
}());

View File

@@ -0,0 +1 @@
let arr = [1, 2, 3];

View File

@@ -0,0 +1,5 @@
var arr = [
1,
2,
3
];

View File

@@ -0,0 +1,5 @@
var arr = [1, 2, 3];
for (let i in arr) {
let val = arr[i];
console.log(val * this.multiplier);
}

View File

@@ -0,0 +1,13 @@
var arr = [
1,
2,
3
];
(function () {
for (var i in arr) {
(function () {
var val = arr[i];
console.log(val * this.multiplier);
}.call(this));
}
}.call(this));

View File

@@ -0,0 +1,8 @@
class Test extends Foo {
constructor() {
woops.super.test();
super();
super.test();
foob(super);
}
}

View File

@@ -0,0 +1,17 @@
var Test = function (Foo) {
function Test() {
woops.super.test();
Foo.call(this);
Foo.prototype.test.call(this);
foob(Foo);
}
Test.prototype = Object.create(Foo.prototype, {
constructor: {
value: Test,
enumerable: false,
writable: true,
configurable: true
}
});
return Test;
}(Foo);

View File

@@ -0,0 +1,5 @@
class Test {
constructor() {
this.state = "test";
}
}

View File

@@ -0,0 +1,6 @@
var Test = function () {
function Test() {
this.state = "test";
}
return Test;
}();

View File

@@ -0,0 +1,8 @@
class Test {
get test() {
return 5 + 5;
}
set test(val) {
this._test = val;
}
}

View File

@@ -0,0 +1,15 @@
var Test = function () {
function Test() {
}
Object.defineProperties(Test.prototype, {
test: {
get: function () {
return 5 + 5;
},
set: function (val) {
this._test = val;
}
}
});
return Test;
}();

View File

@@ -0,0 +1,5 @@
class Test {
get test() {
return 5 + 5;
}
}

View File

@@ -0,0 +1,12 @@
var Test = function () {
function Test() {
}
Object.defineProperties(Test.prototype, {
test: {
get: function () {
return 5 + 5;
}
}
});
return Test;
}();

View File

@@ -0,0 +1,5 @@
class Test {
test() {
return 5 + 5;
}
}

View File

@@ -0,0 +1,8 @@
var Test = function () {
function Test() {
}
Test.prototype.test = function () {
return 5 + 5;
};
return Test;
}();

View File

@@ -0,0 +1,5 @@
class Test {
set test(val) {
this._test = val;
}
}

View File

@@ -0,0 +1,12 @@
var Test = function () {
function Test() {
}
Object.defineProperties(Test.prototype, {
test: {
set: function (val) {
this._test = val;
}
}
});
return Test;
}();

View File

@@ -0,0 +1 @@
class Test { }

View File

@@ -0,0 +1,5 @@
var Test = function () {
function Test() {
}
return Test;
}();

View File

@@ -0,0 +1 @@
class Test extends Foo { }

View File

@@ -0,0 +1,13 @@
var Test = function (Foo) {
function Test() {
}
Test.prototype = Object.create(Foo.prototype, {
constructor: {
value: Test,
enumerable: false,
writable: true,
configurable: true
}
});
return Test;
}(Foo);

View File

@@ -0,0 +1,3 @@
wow;
// um yeah lol
test.wow();

View File

@@ -0,0 +1,3 @@
wow;
// um yeah lol
test.wow();

View File

@@ -0,0 +1,5 @@
wow;
/*
um yeah lol
*/
test.wow();

View File

@@ -0,0 +1,5 @@
wow;
/*
um yeah lol
*/
test.wow();

View File

@@ -0,0 +1,7 @@
var t = function (t = "foo", f = 5) {
return t + " bar " + f;
};
var a = function (t, f = 5) {
return t + " bar " + f;
};

View File

@@ -0,0 +1,12 @@
var t = function (t, f) {
if (f === undefined)
f = 5;
if (t === undefined)
t = "foo";
return t + " bar " + f;
};
var a = function (t, f) {
if (f === undefined)
f = 5;
return t + " bar " + f;
};

View File

@@ -0,0 +1,3 @@
var t = function (t = "foo") {
return t + " bar";
};

View File

@@ -0,0 +1,5 @@
var t = function (t) {
if (t === undefined)
t = "foo";
return t + " bar";
};

View File

@@ -0,0 +1 @@
export { encrypt as enc } from "crypto";

View File

@@ -0,0 +1 @@
exports.enc = require("crypto").encrypt;

View File

@@ -0,0 +1,5 @@
export default test;
export default function (foo, bar) {
};

View File

@@ -0,0 +1,5 @@
exports = module.exports = test;
exports = module.exports = function (foo, bar) {
};

View File

@@ -0,0 +1 @@
export { foo, bar } from "crypto";

View File

@@ -0,0 +1,2 @@
exports.foo = require("crypto").foo;
exports.bar = require("crypto").bar;

View File

@@ -0,0 +1,3 @@
export function wow(foo, bar) {
}

View File

@@ -0,0 +1,3 @@
exports.wow = function wow(foo, bar) {
};

View File

@@ -0,0 +1 @@
export var foo = "test";

View File

@@ -0,0 +1,7 @@
var foo = "test";
Object.defineProperty(exports, "foo", {
get: function () {
return foo;
}
});

View File

@@ -0,0 +1 @@
export * from "crypto";

View File

@@ -0,0 +1,5 @@
(function (obj) {
for (var i in obj) {
exports[i] = obj[i];
}
}(require("crypto")));

View File

@@ -0,0 +1 @@
import { encrypt as enc } from "crypto";

View File

@@ -0,0 +1 @@
var enc = require("crypto").encrypt;

View File

@@ -0,0 +1 @@
import { encrypt, decrypt } from "crypto";

View File

@@ -0,0 +1,2 @@
var encrypt = require("crypto").encrypt;
var decrypt = require("crypto").decrypt;

View File

@@ -0,0 +1 @@
import $ from "jquery";

View File

@@ -0,0 +1 @@
var $ = require("jquery");

View File

@@ -0,0 +1 @@
module crypto from "crypto";

View File

@@ -0,0 +1 @@
var crypto = require("crypto");

View File

@@ -0,0 +1,8 @@
var obj = {
get foo() {
return 5 + 5;
},
set foo(value) {
this._foo = value;
}
};

View File

@@ -0,0 +1,13 @@
var obj = function (obj) {
Object.defineProperties(obj, {
foo: {
get: function () {
return 5 + 5;
},
set: function (value) {
this._foo = value;
}
}
});
return obj;
}({});

View File

@@ -0,0 +1,5 @@
var obj = {
get foo() {
return 5 + 5;
}
};

View File

@@ -0,0 +1,10 @@
var obj = function (obj) {
Object.defineProperties(obj, {
foo: {
get: function () {
return 5 + 5;
}
}
});
return obj;
}({});

View File

@@ -0,0 +1,5 @@
var obj = {
method() {
return 5 + 5;
}
};

View File

@@ -0,0 +1,5 @@
var obj = {
method: function () {
return 5 + 5;
}
};

View File

@@ -0,0 +1,5 @@
var obj = {
set foo(value) {
this._foo = value;
}
};

View File

@@ -0,0 +1,10 @@
var obj = function (obj) {
Object.defineProperties(obj, {
foo: {
set: function (value) {
this._foo = value;
}
}
});
return obj;
}({});

View File

@@ -0,0 +1,3 @@
var t = function (f, ...items) {
};

View File

@@ -0,0 +1,3 @@
var t = function (f) {
var items = Array.prototype.slice.call(arguments, 1);
};

View File

@@ -0,0 +1,3 @@
var t = function (...items) {
};

View File

@@ -0,0 +1,3 @@
var t = function () {
var items = Array.prototype.slice.call(arguments);
};

View File

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

View File

@@ -0,0 +1,9 @@
function foo() {
return bar("test", ...arguments);
}
function bar(one, two, three) {
return [one, two, three];
}
foo("foo", "bar");

View File

@@ -0,0 +1,11 @@
function foo() {
return bar.apply(null, ["test"].concat(Array.prototype.slice.call(arguments)));
}
function bar(one, two, three) {
return [
one,
two,
three
];
}
foo("foo", "bar");

View File

@@ -0,0 +1 @@
var lyrics = ["head", "and", "toes", ...parts];

View File

@@ -0,0 +1,5 @@
var lyrics = [
"head",
"and",
"toes"
].concat(parts);

View File

@@ -0,0 +1 @@
foob.add(foo, bar, ...numbers);

View File

@@ -0,0 +1,4 @@
foob.add.apply(foob, [
foo,
bar
].concat(numbers));

View File

@@ -0,0 +1 @@
foob.add(...numbers);

View File

@@ -0,0 +1 @@
foob.add.apply(foob, numbers);

View File

@@ -0,0 +1 @@
add(foo, bar, ...numbers);

View File

@@ -0,0 +1,4 @@
add.apply(null, [
foo,
bar
].concat(numbers));

View File

@@ -0,0 +1 @@
add(...numbers);

View File

@@ -0,0 +1 @@
add.apply(null, numbers);

Some files were not shown because too many files have changed in this diff Show More