Skip to content

Commit

Permalink
Export the global object.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 26, 2014
1 parent ad80c34 commit b5b52ad
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1984,5 +1984,7 @@
addIterator(Object.getPrototypeOf((new globals.Map()).keys()));
addIterator(Object.getPrototypeOf((new globals.Set()).keys()));
}

return globals;
}));

6 changes: 6 additions & 0 deletions test/array.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
var exported = require('../');

var runArrayTests = function () {
describe('Array', function () {
var list = [5, 10, 15, 20];

it('is on the exported object', function () {
expect(exported.Array).to.equal(Array);
});

describe('@@iterator', function () {
it('uses Symbol.iterator if available', function () {
var a = [];
Expand Down
9 changes: 9 additions & 0 deletions test/collections.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Big thanks to V8 folks for test ideas.
// v8/test/mjsunit/harmony/collections.js
var exported = require('../');

var Assertion = expect().constructor;
Assertion.addMethod('theSameSet', function (otherArray) {
Expand Down Expand Up @@ -53,6 +54,10 @@ describe('Collections', function () {
map = null;
});

it('is on the exported object', function () {
expect(exported.Map).to.equal(Map);
});

it('should exist in global namespace', function () {
expect(typeof Map).to.equal('function');
});
Expand Down Expand Up @@ -438,6 +443,10 @@ describe('Collections', function () {
set = null;
});

it('is on the exported object', function () {
expect(exported.Set).to.equal(Set);
});

it('should exist in global namespace', function () {
expect(typeof Set).to.equal('function');
});
Expand Down
6 changes: 6 additions & 0 deletions test/math.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var exported = require('../');

var Assertion = expect().constructor;
Assertion.prototype.almostEqual = function (obj, precision) {
var allowedDiff = precision || 1e-11;
Expand All @@ -15,6 +17,10 @@ var valueOfIsNaN = { valueOf: function () { return NaN; } };
var valueOfIsInfinity = { valueOf: function () { return Infinity; } };

describe('Math', function () {
it('is on the exported object', function () {
expect(exported.Math).to.equal(Math);
});

describe('#acosh()', function () {
it('should be correct', function () {
expect(Number.isNaN(Math.acosh(NaN))).to.equal(true);
Expand Down
6 changes: 6 additions & 0 deletions test/number.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var exported = require('../');

describe('Number', function (undefined) {
var integers = [5295, -5295, -9007199254740991, 9007199254740991, 0, -0];
var nonIntegers = [-9007199254741992, 9007199254741992, 5.9];
Expand All @@ -10,6 +12,10 @@ describe('Number', function (undefined) {
expect(item).to.equal(false);
};

it('is on the exported object', function () {
expect(exported.Number).to.equal(Number);
});

describe('Number constants', function () {
it('should have max safe integer', function () {
expect(Number.MAX_SAFE_INTEGER).to.equal(Math.pow(2, 53) - 1);
Expand Down
6 changes: 6 additions & 0 deletions test/object.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
var exported = require('../');

describe('Object', function (undefined) {
it('is on the exported object', function () {
expect(exported.Object).to.equal(Object);
});

describe('Object.keys()', function () {
it('works on strings', function () {
expect(Object.keys('foo')).to.eql(['0', '1', '2']);
Expand Down
5 changes: 5 additions & 0 deletions test/promise.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* This file is for testing implementation regressions of Promises. */
var exported = require('../');

describe('Promise', function () {
it('is on the exported object', function () {
expect(exported.Promise).to.equal(Promise);
});

it('ignores non-function .then arguments', function () {
expect(function () {
Promise.reject(42).then(null,5).then(null, function () {});
Expand Down
7 changes: 7 additions & 0 deletions test/string.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var exported = require('../');

var runStringTests = function () {
'use strict';
describe('String', function () {
Expand All @@ -10,6 +12,11 @@ var runStringTests = function () {
expect(function () { return fn.apply(undefined); }).to['throw'](TypeError);
expect(function () { return fn.apply(null); }).to['throw'](TypeError);
};

it('is on the exported object', function () {
expect(exported.String).to.equal(String);
});

describe('#repeat()', function () {
it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('repeat');
Expand Down

0 comments on commit b5b52ad

Please sign in to comment.