Skip to content

Commit

Permalink
#29 add global Symbol.species if it is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Apr 27, 2016
1 parent 397fab1 commit ccd5a01
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ var getPromise = require("../test/getPromise");
var Promise = getPromise(name);
var testSuit = require("./testSuit");
var setPrototypeOf = require("setprototypeof");

var Symbol = global.Symbol || {};
if (!Symbol.species)
Symbol.species = "Symbol(species)";

var $val = {
val: "ok"
Expand Down Expand Up @@ -386,26 +389,23 @@ module.exports = testSuit("basic", function (it) {
});
});

if (Symbol.species) {
it("subclass PromiseCapability promise.then", true, function () {
var promise, FakePromise1, FakePromise2;
promise = new Promise(function (it){ it(42); });

promise.constructor = FakePromise1 = function a (it){
it(function () {}, function () {});
};
it("subclass PromiseCapability promise.then", true, function () {
var promise, FakePromise1, FakePromise2;
promise = new Promise(function (it){ it(42); });

FakePromise1[Symbol.species] = FakePromise2 = function b (it){
it(function () {}, function () {});
};
setPrototypeOf(FakePromise2, Promise);
promise.constructor = FakePromise1 = function a (it){
it(function () {}, function () {});
};

return promise.then(function () {}) instanceof FakePromise2;
});
FakePromise1[Symbol.species] = FakePromise2 = function b (it){
it(function () {}, function () {});
};
setPrototypeOf(FakePromise2, Promise);

}
return promise.then(function () {}) instanceof FakePromise2;
});

it("subclass PromiseCapability promise.then TypeError", "ok", function () {
it("subclass PromiseCapability fake constructor promise.then", "ok", function () {
var promise = new Promise(function (it){ it(42); });

promise.constructor = function () { };
Expand Down

0 comments on commit ccd5a01

Please sign in to comment.