make super behaviour more spec compliant - fixes #32
This commit is contained in:
50
test/bin.js
Normal file
50
test/bin.js
Normal file
@@ -0,0 +1,50 @@
|
||||
var child = require("child_process");
|
||||
var fs = require("fs");
|
||||
|
||||
var tmpLoc = __dirname + "/tmp";
|
||||
|
||||
var readTree = function () {
|
||||
|
||||
};
|
||||
|
||||
var run = function (name, args, callback) {
|
||||
args = [__dirname + "/../bin." + name].concat(args);
|
||||
var spawn = child.spawn(process.execPath, args);
|
||||
|
||||
var data = "";
|
||||
|
||||
spawn.stdout.on("write", function (chunk) {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
spawn.on("close", function () {
|
||||
callback(data);
|
||||
});
|
||||
};
|
||||
|
||||
before(function () {
|
||||
if (!fs.existsSync(tmpLoc)) fs.mkdirSync(tmpLoc);
|
||||
process.chdir(tmpLoc);
|
||||
});
|
||||
|
||||
suite("bin/6to5", function () {
|
||||
test("--source-maps-inline");
|
||||
|
||||
test("--source-maps");
|
||||
|
||||
test("--whitelist");
|
||||
|
||||
test("--blacklist");
|
||||
|
||||
test("--out-file");
|
||||
|
||||
test("--out-dir");
|
||||
|
||||
test("stdout");
|
||||
});
|
||||
|
||||
suite("bin/6to5-node", function () {
|
||||
test("--eval");
|
||||
|
||||
test("--print");
|
||||
});
|
||||
@@ -5,4 +5,8 @@ class Test extends Foo {
|
||||
super.test();
|
||||
foob(super);
|
||||
}
|
||||
|
||||
test() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,8 @@ var Test = function (Foo) {
|
||||
}
|
||||
});
|
||||
Test.__proto__ = Foo;
|
||||
Test.prototype.test = function () {
|
||||
Foo.prototype.test.call(this);
|
||||
};
|
||||
return Test;
|
||||
}(Foo);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super.test;
|
||||
super.test.whatever;
|
||||
}
|
||||
}
|
||||
18
test/fixtures/classes/accessing-super-properties/expected.js
vendored
Normal file
18
test/fixtures/classes/accessing-super-properties/expected.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
var Test = function(Foo) {
|
||||
function Test() {
|
||||
Foo.prototype.test;
|
||||
Foo.prototype.test.whatever;
|
||||
}
|
||||
|
||||
Test.prototype = Object.create(Foo.prototype, {
|
||||
constructor: {
|
||||
value: Test,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
Test.__proto__ = Foo;
|
||||
return Test;
|
||||
}(Foo);
|
||||
@@ -1,5 +1,6 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super.test.whatever();
|
||||
super.test();
|
||||
}
|
||||
}
|
||||
16
test/fixtures/classes/calling-super-properties/expected.js
vendored
Normal file
16
test/fixtures/classes/calling-super-properties/expected.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var Test = function(Foo) {
|
||||
function Test() {
|
||||
Foo.prototype.test.whatever();
|
||||
Foo.prototype.test.call(this);
|
||||
}
|
||||
Test.prototype = Object.create(Foo.prototype, {
|
||||
constructor: {
|
||||
value: Test,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
Test.__proto__ = Foo;
|
||||
return Test;
|
||||
}(Foo);
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "cannot access super properties"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "cannot access super properties"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
var BaseController = function (Chaplin) {
|
||||
function BaseController() {
|
||||
Chaplin.Controller.call(this, arguments);
|
||||
}
|
||||
BaseController.prototype = Object.create(Chaplin.Controller.prototype, {
|
||||
constructor: {
|
||||
@@ -15,6 +16,7 @@ var BaseController = function (Chaplin) {
|
||||
|
||||
var BaseController2 = function (Chaplin) {
|
||||
function BaseController2() {
|
||||
Chaplin.Controller.Another.call(this, arguments);
|
||||
}
|
||||
BaseController2.prototype = Object.create(Chaplin.Controller.Another.prototype, {
|
||||
constructor: {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
var Q = function(_ref) {
|
||||
function Q() {}
|
||||
function Q() {
|
||||
_ref.call(this, arguments);
|
||||
}
|
||||
|
||||
Q.prototype = Object.create(_ref.prototype, {
|
||||
constructor: {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var Test = function (Foo) {
|
||||
function Test() {
|
||||
Foo.call(this, arguments);
|
||||
}
|
||||
Test.prototype = Object.create(Foo.prototype, {
|
||||
constructor: {
|
||||
|
||||
Reference in New Issue
Block a user