[Pkg-javascript-commits] [node-es6-shim] 01/05: New upstream version 0.35.2+ds
Julien Puydt
julien.puydt at laposte.net
Wed Dec 7 15:59:53 UTC 2016
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-es6-shim.
commit c2e987a2b8f3ffab3051471a256332788583fdb9
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Wed Dec 7 16:54:41 2016 +0100
New upstream version 0.35.2+ds
---
.eslintrc | 5 ++
.travis.yml | 50 ++++++++++---
CHANGELOG.md | 8 +++
es6-sham.js | 2 +-
es6-shim.js | 160 ++++++++++++++++++++++++++++-------------
package.json | 22 +++---
test-sham/.eslintrc | 8 +++
test-sham/function.js | 6 +-
test/.eslintrc | 14 +++-
test/array.js | 28 ++++----
test/date.js | 2 -
test/json.js | 1 -
test/map.js | 12 ++--
test/math.js | 58 +++++++--------
test/number.js | 35 ++++-----
test/object.js | 23 ++++--
test/promise.js | 2 -
test/promise/evil-promises.js | 2 -
test/promise/promises-aplus.js | 2 -
test/promise/promises-es6.js | 2 -
test/promise/race.js | 2 -
test/promise/reject.js | 2 -
test/promise/resolve.js | 2 -
test/promise/simple.js | 2 -
test/reflect.js | 2 -
test/regexp.js | 26 ++++---
test/set.js | 16 ++---
test/string.js | 26 +++----
test/worker-test.js | 2 +-
29 files changed, 316 insertions(+), 206 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index aaa44b4..04e56e2 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -9,13 +9,16 @@
"consistent-return": [1],
"dot-notation": [2, { "allowKeywords": false }],
"eqeqeq": [2, "allow-null"],
+ "func-name-matching": [0],
"global-require": [0],
"id-length": [2, { "min": 1, "max": 40 }],
"indent": [2, 2],
"max-depth": [2, 5],
+ "max-lines": [1],
"max-params": [2, 4],
"max-nested-callbacks": [2, 5],
"max-statements": [1, 25],
+ "max-statements-per-line": [2, { "max": 2 }],
"new-cap": [2, { "capIsNewExceptions": ["Call", "Construct", "CreateHTML", "GetIterator", "GetMethod", "IsCallable", "IsConstructor", "IsPromise", "IsRegExp", "IteratorClose", "IteratorComplete", "IteratorNext", "IteratorStep", "Map", "OrigNumber", "RequireObjectCoercible", "SameValue", "SameValueZero", "Set", "SpeciesConstructor", "ToInteger", "ToLength", "ToNumber", "ToObject", "ToString", "ToUint32", "TypeIsObject"] }],
"no-constant-condition": [1],
"no-continue": [1],
@@ -39,7 +42,9 @@
"no-unused-vars": [1, { "vars": "all", "args": "after-used" }],
"no-use-before-define": [1],
"no-useless-call": [0],
+ "object-curly-newline": [1],
"operator-linebreak": [2, "after"],
+ "sort-keys": [0],
"spaced-comment": [0],
"strict": [0]
}
diff --git a/.travis.yml b/.travis.yml
index fa8eab8..b1b92db 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,19 @@
language: node_js
node_js:
+ - "7.2"
+ - "7.1"
+ - "7.0"
+ - "6.9"
+ - "6.8"
+ - "6.7"
+ - "6.6"
+ - "6.5"
+ - "6.4"
+ - "6.3"
+ - "6.2"
- "6.1"
- "6.0"
+ - "5.12"
- "5.11"
- "5.10"
- "5.9"
@@ -14,6 +26,8 @@ node_js:
- "5.2"
- "5.1"
- "5.0"
+ - "4.6"
+ - "4.5"
- "4.4"
- "4.3"
- "4.2"
@@ -38,6 +52,7 @@ node_js:
- "iojs-v1.2"
- "iojs-v1.1"
- "iojs-v1.0"
+ - "0.12"
- "0.11"
- "0.10"
- "0.9"
@@ -47,25 +62,38 @@ node_js:
before_install:
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm at 1.4.28 ;; 2.*) npm install -g npm at 2 ;; esac ; fi'
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi'
- - '[ "${TRAVIS_RUN_SAUCE}" != "true" ] || npm install -g grunt-cli'
+ - 'if [ "${SAUCE-}" = "true" ]; then npm install -g grunt-cli; fi'
script:
- - 'if [ "${TRAVIS_RUN_SAUCE}" == "true" ]; then npm run sauce ; elif [ "${TRAVIS_NODE_VERSION}" != "0.11" ] && [ "${TRAVIS_RUN_LINT_ONLY}" != "true" ]; then npm run tests-only ; else npm test ; fi'
+ - 'if [ "${SAUCE-}" = "true" ]; then npm run sauce; fi'
+ - 'if [ "${PRETEST-}" = "true" ]; then npm run pretest; fi'
+ - 'if [ "${TEST-}" = "true"]; then npm run tests-only; fi'
# NOTE: sauce_connect is disabled, because it applies to every test and we only need it on one of them.
# It's available inside `npm run sauce`
# addons:
# sauce_connect: true
sudo: false
+env:
+ - TEST=true
matrix:
fast_finish: true
include:
- - node_js: "0.12"
- env: TRAVIS_RUN_SAUCE=false TRAVIS_RUN_LINT_ONLY=true
- - node_js: "0.12"
- env: TRAVIS_RUN_SAUCE=true TRAVIS_RUN_LINT_ONLY=false
- - node_js: "0.12"
- env: TRAVIS_RUN_SAUCE=false TRAVIS_RUN_LINT_ONLY=false
+ - node_js: "node"
+ env: PRETEST=true
+ - node_js: "node"
+ env: SAUCE=true
allow_failures:
+ - node_js: "7.1"
+ - node_js: "7.0"
+ - node_js: "6.8"
+ - node_js: "6.7"
+ - node_js: "6.6"
+ - node_js: "6.5"
+ - node_js: "6.4"
+ - node_js: "6.3"
+ - node_js: "6.2"
+ - node_js: "6.1"
- node_js: "6.0"
+ - node_js: "5.11"
- node_js: "5.10"
- node_js: "5.9"
- node_js: "5.8"
@@ -77,6 +105,8 @@ matrix:
- node_js: "5.2"
- node_js: "5.1"
- node_js: "5.0"
+ - node_js: "4.5"
+ - node_js: "4.4"
- node_js: "4.3"
- node_js: "4.2"
- node_js: "4.1"
@@ -101,8 +131,8 @@ matrix:
- node_js: "0.9"
- node_js: "0.6"
- node_js: "0.4"
- - node_js: "0.12"
- env: TRAVIS_RUN_SAUCE=true TRAVIS_RUN_LINT_ONLY=false
+ - node_js: "node"
+ env: SAUCE=true
env:
global:
- secure: YD4HLTE93NhSxa+64MYHhnbJ2ZkREp/HGiFGE4q+AWShqAiehtqE/K3hQUe7p0+1/2/34avhm2bz31j508ayCobm6SSUhpleJH58IK3v4LI2o9qtM+2N/MPJFOIvbziHqOM6fPluowU0k3OSdEAp4U+6S23wKSuXzcUSK8upAiM=
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 184c526..0bba71b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# es6-shim 0.35.2 (3 December 2016)
+* [Fix] ensure `document.all` is not treated as a non-object-coercible (#428)
+* [Performance] Use original map for data backing when possible (#429, #422)
+* [Dev Deps] update `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`, `jshint`, `mocha`, `promises-plus-tests`, `uglify-js`
+* [Tests] up to `node` `v7.2`, `v5.12`, `v4.6`; improve test matrix
+* [Tests] avoid function name inference in node 7+
+* [Tests] add Firefox Nightly error messages to fix false failure
+
# es6-shim 0.35.1 (12 May 2016)
* [Fix] Functions are objects (#418)
* [Fix] use `createDataPropertyOrThrow` in `Array.from`, rather than `[[Put]]` (#415)
diff --git a/es6-sham.js b/es6-sham.js
index 00f6b55..ce0b30b 100644
--- a/es6-sham.js
+++ b/es6-sham.js
@@ -155,7 +155,7 @@
enumerable: false,
get: function () {
var str = _call(functionToString, this);
- var match = _call(_strMatch, str, /\s*function\s+([^\(\s]*)\s*/);
+ var match = _call(_strMatch, str, /\s*function\s+([^(\s]*)\s*/);
var name = match && match[1];
Object.defineProperty(this, 'name', {
configurable: true,
diff --git a/es6-shim.js b/es6-shim.js
index d9b8758..30b9031 100644
--- a/es6-shim.js
+++ b/es6-shim.js
@@ -205,6 +205,12 @@
var ArrayIterator; // make our implementation private
var noop = function () {};
+ var OrigMap = globals.Map;
+ var origMapDelete = OrigMap && OrigMap.prototype['delete'];
+ var origMapGet = OrigMap && OrigMap.prototype.get;
+ var origMapHas = OrigMap && OrigMap.prototype.has;
+ var origMapSet = OrigMap && OrigMap.prototype.set;
+
var Symbol = globals.Symbol || {};
var symbolSpecies = Symbol.species || '@@species';
@@ -256,6 +262,7 @@
Value.preserveToString(object[property], original);
};
+ // eslint-disable-next-line no-restricted-properties
var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && Type.symbol(Symbol());
// This is a private name in the es6 spec, equal to '[Symbol.iterator]'
@@ -279,6 +286,17 @@
var $String = String;
+ /* global document */
+ var domAll = (typeof document === 'undefined' || !document) ? null : document.all;
+ /* jshint eqnull:true */
+ var isNullOrUndefined = domAll == null ? function isNullOrUndefined(x) {
+ /* jshint eqnull:true */
+ return x == null;
+ } : function isNullOrUndefinedAndNotDocumentAll(x) {
+ /* jshint eqnull:true */
+ return x == null && x !== domAll;
+ };
+
var ES = {
// http://www.ecma-international.org/ecma-262/6.0/#sec-call
Call: function Call(F, V) {
@@ -290,8 +308,7 @@
},
RequireObjectCoercible: function (x, optMessage) {
- /* jshint eqnull:true */
- if (x == null) {
+ if (isNullOrUndefined(x)) {
throw new TypeError(optMessage || 'Cannot call method on ' + x);
}
return x;
@@ -310,7 +327,7 @@
if (x === void 0 || x === null || x === true || x === false) {
return false;
}
- return typeof x === 'function' || typeof x === 'object';
+ return typeof x === 'function' || typeof x === 'object' || x === domAll;
},
ToObject: function (o, optMessage) {
@@ -390,7 +407,7 @@
GetMethod: function (o, p) {
var func = ES.ToObject(o)[p];
- if (func === void 0 || func === null) {
+ if (isNullOrUndefined(func)) {
return void 0;
}
if (!ES.IsCallable(func)) {
@@ -470,7 +487,7 @@
throw new TypeError('Bad constructor');
}
var S = C[symbolSpecies];
- if (S === void 0 || S === null) {
+ if (isNullOrUndefined(S)) {
return defaultConstructor;
}
if (!ES.IsConstructor(S)) {
@@ -514,6 +531,7 @@
if (Type.symbol(Symbol[name])) {
return Symbol[name];
}
+ // eslint-disable-next-line no-restricted-properties
var sym = Symbol['for']('Symbol.' + name);
Object.defineProperty(Symbol, name, {
configurable: false,
@@ -531,7 +549,7 @@
});
var searchShim = function search(regexp) {
var O = ES.RequireObjectCoercible(this);
- if (regexp !== null && typeof regexp !== 'undefined') {
+ if (!isNullOrUndefined(regexp)) {
var searcher = ES.GetMethod(regexp, symbolSearch);
if (typeof searcher !== 'undefined') {
return ES.Call(searcher, regexp, [O]);
@@ -549,7 +567,7 @@
});
var replaceShim = function replace(searchValue, replaceValue) {
var O = ES.RequireObjectCoercible(this);
- if (searchValue !== null && typeof searchValue !== 'undefined') {
+ if (!isNullOrUndefined(searchValue)) {
var replacer = ES.GetMethod(searchValue, symbolReplace);
if (typeof replacer !== 'undefined') {
return ES.Call(replacer, searchValue, [O, replaceValue]);
@@ -567,7 +585,7 @@
});
var splitShim = function split(separator, limit) {
var O = ES.RequireObjectCoercible(this);
- if (separator !== null && typeof separator !== 'undefined') {
+ if (!isNullOrUndefined(separator)) {
var splitter = ES.GetMethod(separator, symbolSplit);
if (typeof splitter !== 'undefined') {
return ES.Call(splitter, separator, [O, limit]);
@@ -595,7 +613,7 @@
var matchShim = function match(regexp) {
var O = ES.RequireObjectCoercible(this);
- if (regexp !== null && typeof regexp !== 'undefined') {
+ if (!isNullOrUndefined(regexp)) {
var matcher = ES.GetMethod(regexp, symbolMatch);
if (typeof matcher !== 'undefined') {
return ES.Call(matcher, regexp, [O]);
@@ -891,7 +909,7 @@
};
var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
var nonWSregex = new RegExp('[' + nonWS + ']', 'g');
- var isBadHexRegex = /^[\-+]0x[0-9a-f]+$/i;
+ var isBadHexRegex = /^[-+]0x[0-9a-f]+$/i;
var hasStringTrimBug = nonWS.trim().length !== nonWS.length;
defineProperty(String.prototype, 'trim', trimShim, hasStringTrimBug);
@@ -1405,12 +1423,12 @@
POSITIVE_INFINITY: OrigNumber.POSITIVE_INFINITY
});
/* globals Number: true */
- /* eslint-disable no-undef */
+ /* eslint-disable no-undef, no-global-assign */
/* jshint -W020 */
Number = NumberShim;
Value.redefine(globals, 'Number', NumberShim);
/* jshint +W020 */
- /* eslint-enable no-undef */
+ /* eslint-enable no-undef, no-global-assign */
/* globals Number: false */
}
@@ -1781,7 +1799,10 @@
if (supportsDescriptors && (!regExpSupportsFlagsWithRegex || regExpNeedsToSupportSymbolMatch)) {
var flagsGetter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get;
var sourceDesc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source') || {};
- var legacySourceGetter = function () { return this.source; }; // prior to it being a getter, it's own + nonconfigurable
+ var legacySourceGetter = function () {
+ // prior to it being a getter, it's own + nonconfigurable
+ return this.source;
+ };
var sourceGetter = ES.IsCallable(sourceDesc.get) ? sourceDesc.get : legacySourceGetter;
var OrigRegExp = RegExp;
@@ -1810,12 +1831,12 @@
$input: true // Chrome < v39 & Opera < 26 have a nonstandard "$input" property
});
/* globals RegExp: true */
- /* eslint-disable no-undef */
+ /* eslint-disable no-undef, no-global-assign */
/* jshint -W020 */
RegExp = RegExpShim;
Value.redefine(globals, 'RegExp', RegExpShim);
/* jshint +W020 */
- /* eslint-enable no-undef */
+ /* eslint-enable no-undef, no-global-assign */
/* globals RegExp: false */
}
@@ -1857,7 +1878,7 @@
if (numberIsNaN(x) || value < 1) { return NaN; }
if (x === 1) { return 0; }
if (x === Infinity) { return x; }
- return _log(x / E + _sqrt(x + 1) * _sqrt(x - 1) / E) + 1;
+ return _log((x / E) + (_sqrt(x + 1) * _sqrt(x - 1) / E)) + 1;
},
asinh: function asinh(value) {
@@ -1865,7 +1886,7 @@
if (x === 0 || !globalIsFinite(x)) {
return x;
}
- return x < 0 ? -asinh(-x) : _log(x + _sqrt(x * x + 1));
+ return x < 0 ? -asinh(-x) : _log(x + _sqrt((x * x) + 1));
},
atanh: function atanh(value) {
@@ -1890,7 +1911,7 @@
} else {
result = _exp(_log(x) / 3);
// from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods
- result = (x / (result * result) + (2 * result)) / 3;
+ result = ((x / (result * result)) + (2 * result)) / 3;
}
return negate ? -result : result;
},
@@ -2005,7 +2026,7 @@
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
- return (al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0;
+ return (al * bl) + ((((ah * bl) + (al * bh)) << 16) >>> 0) | 0;
},
fround: function fround(x) {
@@ -2016,10 +2037,12 @@
var sign = _sign(v);
var abs = _abs(v);
if (abs < BINARY_32_MIN_VALUE) {
- return sign * roundTiesToEven(abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON;
+ return sign * roundTiesToEven(
+ abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON
+ ) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON;
}
// Veltkamp's splitting (?)
- var a = (1 + BINARY_32_EPSILON / Number.EPSILON) * abs;
+ var a = (1 + (BINARY_32_EPSILON / Number.EPSILON)) * abs;
var result = a - (a - abs);
if (result > BINARY_32_MAX_VALUE || numberIsNaN(result)) {
return sign * Infinity;
@@ -2037,7 +2060,7 @@
// Chrome 40 loses Math.acosh precision with high numbers
defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity);
// Firefox 38 on Windows
- defineProperty(Math, 'cbrt', MathShims.cbrt, Math.abs(1 - Math.cbrt(1e-300) / 1e-100) / Number.EPSILON > 8);
+ defineProperty(Math, 'cbrt', MathShims.cbrt, Math.abs(1 - (Math.cbrt(1e-300) / 1e-100)) / Number.EPSILON > 8);
// node 0.11 has an imprecise Math.sinh with very small numbers
defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17);
// FF 35 on Linux reports 22025.465794806725 for Math.expm1(10)
@@ -2046,15 +2069,19 @@
var origMathRound = Math.round;
// breaks in e.g. Safari 8, Internet Explorer 11, Opera 12
- var roundHandlesBoundaryConditions = Math.round(0.5 - Number.EPSILON / 4) === 0 && Math.round(-0.5 + Number.EPSILON / 3.99) === 1;
+ var roundHandlesBoundaryConditions = Math.round(0.5 - (Number.EPSILON / 4)) === 0 &&
+ Math.round(-0.5 + (Number.EPSILON / 3.99)) === 1;
// When engines use Math.floor(x + 0.5) internally, Math.round can be buggy for large integers.
// This behavior should be governed by "round to nearest, ties to even mode"
// see http://www.ecma-international.org/ecma-262/6.0/#sec-terms-and-definitions-number-type
// These are the boundary cases where it breaks.
var smallestPositiveNumberWhereRoundBreaks = inverseEpsilon + 1;
- var largestPositiveNumberWhereRoundBreaks = 2 * inverseEpsilon - 1;
- var roundDoesNotIncreaseIntegers = [smallestPositiveNumberWhereRoundBreaks, largestPositiveNumberWhereRoundBreaks].every(function (num) {
+ var largestPositiveNumberWhereRoundBreaks = (2 * inverseEpsilon) - 1;
+ var roundDoesNotIncreaseIntegers = [
+ smallestPositiveNumberWhereRoundBreaks,
+ largestPositiveNumberWhereRoundBreaks
+ ].every(function (num) {
return Math.round(num) === num;
});
defineProperty(Math, 'round', function round(x) {
@@ -2586,7 +2613,9 @@
var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) {
return S.resolve(42).then(function () {}) instanceof S;
});
- var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () { globals.Promise.reject(42).then(null, 5).then(null, noop); });
+ var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () {
+ globals.Promise.reject(42).then(null, 5).then(null, noop);
+ });
var promiseRequiresObjectContext = throwsError(function () { globals.Promise.call(3, noop); });
// Promise.resolve() was errata'ed late in the ES6 process.
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1170742
@@ -2630,11 +2659,11 @@
!promiseRequiresObjectContext || promiseResolveBroken ||
!getsThenSynchronously || hasBadResolverPromise) {
/* globals Promise: true */
- /* eslint-disable no-undef */
+ /* eslint-disable no-undef, no-global-assign */
/* jshint -W020 */
Promise = PromiseShim;
/* jshint +W020 */
- /* eslint-enable no-undef */
+ /* eslint-enable no-undef, no-global-assign */
/* globals Promise: false */
overrideNative(globals, 'Promise', PromiseShim);
}
@@ -2685,11 +2714,11 @@
if (supportsDescriptors) {
- var fastkey = function fastkey(key) {
- if (!preservesInsertionOrder) {
+ var fastkey = function fastkey(key, skipInsertionOrderCheck) {
+ if (!skipInsertionOrderCheck && !preservesInsertionOrder) {
return null;
}
- if (typeof key === 'undefined' || key === null) {
+ if (isNullOrUndefined(key)) {
return '^' + ES.ToString(key);
} else if (typeof key === 'string') {
return '$' + key;
@@ -2724,7 +2753,7 @@
});
} else {
var iter, adder;
- if (iterable !== null && typeof iterable !== 'undefined') {
+ if (!isNullOrUndefined(iterable)) {
adder = map.set;
if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); }
iter = ES.GetIterator(iterable);
@@ -2758,7 +2787,7 @@
});
} else {
var iter, adder;
- if (iterable !== null && typeof iterable !== 'undefined') {
+ if (!isNullOrUndefined(iterable)) {
adder = set.add;
if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); }
iter = ES.GetIterator(iterable);
@@ -2858,8 +2887,9 @@
var map = emulateES6construct(this, Map, Map$prototype, {
_es6map: true,
_head: null,
- _storage: emptyObject(),
- _size: 0
+ _map: OrigMap ? new OrigMap() : null,
+ _size: 0,
+ _storage: emptyObject()
});
var head = new MapEntry(null, null);
@@ -2885,10 +2915,20 @@
defineProperties(Map$prototype, {
get: function get(key) {
requireMapSlot(this, 'get');
- var fkey = fastkey(key);
+ var entry;
+ var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
- var entry = this._storage[fkey];
+ entry = this._storage[fkey];
+ if (entry) {
+ return entry.value;
+ } else {
+ return;
+ }
+ }
+ if (this._map) {
+ // fast object key path
+ entry = origMapGet.call(this._map, key);
if (entry) {
return entry.value;
} else {
@@ -2906,11 +2946,15 @@
has: function has(key) {
requireMapSlot(this, 'has');
- var fkey = fastkey(key);
+ var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
return typeof this._storage[fkey] !== 'undefined';
}
+ if (this._map) {
+ // fast object key path
+ return origMapHas.call(this._map, key);
+ }
var head = this._head;
var i = head;
while ((i = i.next) !== head) {
@@ -2926,7 +2970,7 @@
var head = this._head;
var i = head;
var entry;
- var fkey = fastkey(key);
+ var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
if (typeof this._storage[fkey] !== 'undefined') {
@@ -2937,6 +2981,16 @@
i = head.prev;
// fall through
}
+ } else if (this._map) {
+ // fast object key path
+ if (origMapHas.call(this._map, key)) {
+ origMapGet.call(this._map, key).value = value;
+ } else {
+ entry = new MapEntry(key, value);
+ origMapSet.call(this._map, key, entry);
+ i = head.prev;
+ // fall through
+ }
}
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
@@ -2960,7 +3014,7 @@
requireMapSlot(this, 'delete');
var head = this._head;
var i = head;
- var fkey = fastkey(key);
+ var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
if (typeof this._storage[fkey] === 'undefined') {
@@ -2969,6 +3023,14 @@
i = this._storage[fkey].prev;
delete this._storage[fkey];
// fall through
+ } else if (this._map) {
+ // fast object key path
+ if (!origMapHas.call(this._map, key)) {
+ return false;
+ }
+ i = origMapGet.call(this._map, key).prev;
+ origMapDelete.call(this._map, key);
+ // fall through
}
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
@@ -2984,6 +3046,7 @@
clear: function clear() {
requireMapSlot(this, 'clear');
+ this._map = OrigMap ? new OrigMap() : null;
this._size = 0;
this._storage = emptyObject();
var head = this._head;
@@ -3191,12 +3254,11 @@
// Safari 8, for example, doesn't accept an iterable.
var mapAcceptsArguments = valueOrFalseIfThrows(function () { return new Map([[1, 2]]).get(1) === 2; });
if (!mapAcceptsArguments) {
- var OrigMapNoArgs = globals.Map;
globals.Map = function Map() {
if (!(this instanceof Map)) {
throw new TypeError('Constructor Map requires "new"');
}
- var m = new OrigMapNoArgs();
+ var m = new OrigMap();
if (arguments.length > 0) {
addIterableToMap(Map, m, arguments[0]);
}
@@ -3204,9 +3266,9 @@
Object.setPrototypeOf(m, globals.Map.prototype);
return m;
};
- globals.Map.prototype = create(OrigMapNoArgs.prototype);
+ globals.Map.prototype = create(OrigMap.prototype);
defineProperty(globals.Map.prototype, 'constructor', globals.Map, true);
- Value.preserveToString(globals.Map, OrigMapNoArgs);
+ Value.preserveToString(globals.Map, OrigMap);
}
var testMap = new Map();
var mapUsesSameValueZero = (function () {
@@ -3217,15 +3279,12 @@
}());
var mapSupportsChaining = testMap.set(1, 2) === testMap;
if (!mapUsesSameValueZero || !mapSupportsChaining) {
- var origMapSet = Map.prototype.set;
overrideNative(Map.prototype, 'set', function set(k, v) {
_call(origMapSet, this, k === 0 ? 0 : k, v);
return this;
});
}
if (!mapUsesSameValueZero) {
- var origMapGet = Map.prototype.get;
- var origMapHas = Map.prototype.has;
defineProperties(Map.prototype, {
get: function get(k) {
return _call(origMapGet, this, k === 0 ? 0 : k);
@@ -3271,7 +3330,8 @@
m.set(42, 42);
return m instanceof M;
});
- var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible
+ // without Object.setPrototypeOf, subclassing is not possible
+ var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing;
var mapRequiresNew = (function () {
try {
return !(globals.Map() instanceof globals.Map);
@@ -3280,7 +3340,6 @@
}
}());
if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) {
- var OrigMap = globals.Map;
globals.Map = function Map() {
if (!(this instanceof Map)) {
throw new TypeError('Constructor Map requires "new"');
@@ -3302,7 +3361,8 @@
s.add(42, 42);
return s instanceof S;
});
- var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible
+ // without Object.setPrototypeOf, subclassing is not possible
+ var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing;
var setRequiresNew = (function () {
try {
return !(globals.Set() instanceof globals.Set);
diff --git a/package.json b/package.json
index a5f8f26..6e58306 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "es6-shim",
- "version": "0.35.1",
+ "version": "0.35.2",
"author": "Paul Miller (http://paulmillr.com)",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [
@@ -23,8 +23,8 @@
},
"main": "es6-shim",
"scripts": {
- "pretest": "npm run --silent lint",
- "test": "evalmd *.md && npm run --silent tests-only",
+ "pretest": "npm run --silent lint && evalmd *.md",
+ "test": "npm run --silent tests-only",
"tests-only": "npm run --silent test:shim && npm run --silent test:sham",
"test:shim": "mocha test/*.js test/*/*.js",
"test:sham": "mocha test-sham/*.js",
@@ -69,19 +69,19 @@
"dependencies": {},
"devDependencies": {
"chai": "^3.5.0",
- "es5-shim": "^4.5.8",
- "eslint": "^2.9.0",
- "@ljharb/eslint-config": "^4.0.0",
+ "es5-shim": "^4.5.9",
+ "eslint": "^3.11.1",
+ "@ljharb/eslint-config": "^9.0.1",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-watch": "^1.0.0",
"grunt-saucelabs": "^8.6.2",
- "jscs": "^3.0.3",
- "jshint": "^2.9.2",
- "mocha": "^2.4.5",
- "promises-aplus-tests": "^2.1.1",
+ "jscs": "^3.0.7",
+ "jshint": "^2.9.4",
+ "mocha": "^3.2.0",
+ "promises-aplus-tests": "^2.1.2",
"promises-es6-tests": "^0.5.0",
- "uglify-js": "^2.6.2",
+ "uglify-js": "2.7.3",
"evalmd": "^0.0.17"
}
}
diff --git a/test-sham/.eslintrc b/test-sham/.eslintrc
new file mode 100644
index 0000000..1a13a3e
--- /dev/null
+++ b/test-sham/.eslintrc
@@ -0,0 +1,8 @@
+{
+ "env": {
+ "mocha": true
+ },
+ "globals": {
+ "expect": false
+ }
+}
diff --git a/test-sham/function.js b/test-sham/function.js
index 4720d51..878d057 100644
--- a/test-sham/function.js
+++ b/test-sham/function.js
@@ -1,4 +1,4 @@
-/* global describe, it, expect, require */
+var identity = function (x) { return x; };
describe('Function', function () {
describe('#name', function () {
@@ -18,7 +18,7 @@ describe('Function', function () {
});
it('returns empty string for anonymous functions', function () {
- var anon = function () {};
+ var anon = identity(function () {});
expect(anon.name).to.equal('');
// pre-ES6, this property is nonconfigurable.
@@ -35,7 +35,7 @@ describe('Function', function () {
it('returns "anomymous" for Function functions', function () {
/* eslint no-new-func: 1 */
/* jshint evil: true */
- var func = Function('');
+ var func = identity(Function(''));
/* jshint evil: false */
expect(typeof func.name).to.equal('string');
expect(func.name === 'anonymous' || func.name === '').to.equal(true);
diff --git a/test/.eslintrc b/test/.eslintrc
index 55e2e45..956230c 100644
--- a/test/.eslintrc
+++ b/test/.eslintrc
@@ -1,6 +1,18 @@
{
"rules": {
"array-callback-return": 0,
- "max-statements-per-line": [2, { "max": 2 }]
+ "func-name-matching": 0,
+ "max-statements-per-line": [2, { "max": 2 }],
+ "no-restricted-properties": 1,
+ "symbol-description": 0,
+ },
+ "env": {
+ "mocha": true
+ },
+ "globals": {
+ "Symbol": false,
+ "Promise": false,
+ "expect": false,
+ "assert": false
}
}
diff --git a/test/array.js b/test/array.js
index 5b516bd..264f449 100644
--- a/test/array.js
+++ b/test/array.js
@@ -1,5 +1,3 @@
-/* global describe, it, expect, require, beforeEach, afterEach */
-
var runArrayTests = function (it) {
'use strict';
@@ -46,7 +44,7 @@ var runArrayTests = function (it) {
});
describe('.from()', function () {
- if (!Array.hasOwnProperty('from')) {
+ if (!Object.prototype.hasOwnProperty.call(Array, 'from')) {
return it('exists', function () {
expect(Array).to.have.property('from');
});
@@ -257,6 +255,7 @@ var runArrayTests = function (it) {
});
ifSupportsDescriptorsIt('works when Object.prototype has a throwing setter', function () {
+ // TODO: breaks in Chrome 17, IE 9, Safari 5.1-6
var key = 10;
/* eslint no-extend-native: 0 */
Object.defineProperty(Object.prototype, key, {
@@ -264,7 +263,10 @@ var runArrayTests = function (it) {
get: function () {},
set: function (v) { throw new EvalError('boom'); }
});
- expect(function () { var arr = []; arr[key] = 42; }).to['throw'](EvalError); // assert thrower
+ expect(function () {
+ var arr = [];
+ arr[key] = 42;
+ }).to['throw'](EvalError); // assert thrower
expect(function () { Array.from({ length: key + 1 }); }).not.to['throw']();
@@ -274,7 +276,7 @@ var runArrayTests = function (it) {
});
describe('.of()', function () {
- if (!Array.hasOwnProperty('of')) {
+ if (!Object.prototype.hasOwnProperty.call(Array, 'of')) {
return it('exists', function () {
expect(Array).to.have.property('of');
});
@@ -327,7 +329,7 @@ var runArrayTests = function (it) {
});
describe('#copyWithin()', function () {
- if (!Array.prototype.hasOwnProperty('copyWithin')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'copyWithin')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('copyWithin');
});
@@ -416,7 +418,7 @@ var runArrayTests = function (it) {
});
describe('#find()', function () {
- if (!Array.prototype.hasOwnProperty('find')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'find')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('find');
});
@@ -515,7 +517,7 @@ var runArrayTests = function (it) {
});
describe('#findIndex()', function () {
- if (!Array.prototype.hasOwnProperty('findIndex')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'findIndex')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('findIndex');
});
@@ -614,7 +616,7 @@ var runArrayTests = function (it) {
});
describe('ArrayIterator', function () {
- if (!Array.prototype.hasOwnProperty('keys')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'keys')) {
return it('can be tested', function () {
expect(Array.prototype).to.have.property('keys');
});
@@ -640,7 +642,7 @@ var runArrayTests = function (it) {
});
describe('#keys()', function () {
- if (!Array.prototype.hasOwnProperty('keys')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'keys')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('keys');
});
@@ -711,7 +713,7 @@ var runArrayTests = function (it) {
});
describe('#values()', function () {
- if (!Array.prototype.hasOwnProperty('values')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'values')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('values');
});
@@ -782,7 +784,7 @@ var runArrayTests = function (it) {
});
describe('#entries()', function () {
- if (!Array.prototype.hasOwnProperty('entries')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'entries')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('entries');
});
@@ -859,7 +861,7 @@ var runArrayTests = function (it) {
});
describe('#fill()', function () {
- if (!Array.prototype.hasOwnProperty('fill')) {
+ if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'fill')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('fill');
});
diff --git a/test/date.js b/test/date.js
index 4251a0b..5e5f640 100644
--- a/test/date.js
+++ b/test/date.js
@@ -1,5 +1,3 @@
-/* global describe, it, expect, require */
-
describe('Date', function () {
it('when invalid, dates should toString to "Invalid Date"', function () {
expect(String(new Date(NaN))).to.equal('Invalid Date');
diff --git a/test/json.js b/test/json.js
index 462e22a..765d747 100644
--- a/test/json.js
+++ b/test/json.js
@@ -1,4 +1,3 @@
-/* global describe, it, xit, expect, require */
describe('JSON', function () {
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
diff --git a/test/map.js b/test/map.js
index d3d4476..33e5000 100644
--- a/test/map.js
+++ b/test/map.js
@@ -1,5 +1,3 @@
-/* global describe, it, xit, expect, require, beforeEach, afterEach */
-
// Big thanks to V8 folks for test ideas.
// v8/test/mjsunit/harmony/collections.js
@@ -52,7 +50,7 @@ describe('Map', function () {
return result;
};
- var prototypePropIsEnumerable = (function () {}).propertyIsEnumerable('prototype');
+ var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype');
var expectNotEnumerable = function (object) {
if (prototypePropIsEnumerable && typeof object === 'function') {
expect(Object.keys(object)).to.eql(['prototype']);
@@ -293,7 +291,7 @@ describe('Map', function () {
});
describe('#keys()', function () {
- if (!Map.prototype.hasOwnProperty('keys')) {
+ if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'keys')) {
return it('exists', function () {
expect(Map.prototype).to.have.property('keys');
});
@@ -313,7 +311,7 @@ describe('Map', function () {
});
describe('#values()', function () {
- if (!Map.prototype.hasOwnProperty('values')) {
+ if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'values')) {
return it('exists', function () {
expect(Map.prototype).to.have.property('values');
});
@@ -333,7 +331,7 @@ describe('Map', function () {
});
describe('#entries()', function () {
- if (!Map.prototype.hasOwnProperty('entries')) {
+ if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'entries')) {
return it('exists', function () {
expect(Map.prototype).to.have.property('entries');
});
@@ -352,7 +350,7 @@ describe('Map', function () {
});
it('throws when called on a non-Map', function () {
- var expectedMessage = /^(Method )?Map.prototype.entries called on incompatible receiver |^entries method called on incompatible |^Cannot create a Map entry iterator for a non-Map object.|^Map\.prototype\.entries: 'this' is not a Map object$/;
+ var expectedMessage = /^(Method )?Map.prototype.entries called on incompatible receiver |^entries method called on incompatible |^Cannot create a Map entry iterator for a non-Map object.|^Map\.prototype\.entries: 'this' is not a Map object$|^std_Map_iterator method called on incompatible \w+$/;
var nonMaps = [true, false, 'abc', NaN, new Set([1, 2]), { a: true }, [1], Object('abc'), Object(NaN)];
nonMaps.forEach(function (nonMap) {
expect(function () { return Map.prototype.entries.call(nonMap); }).to['throw'](TypeError, expectedMessage);
diff --git a/test/math.js b/test/math.js
index 9b2b47f..0afa336 100644
--- a/test/math.js
+++ b/test/math.js
@@ -1,5 +1,3 @@
-/* global describe, it, xit, expect, require */
-
var Assertion = expect().constructor;
Assertion.prototype.almostEqual = function (obj, precision) {
'use strict';
@@ -36,7 +34,7 @@ describe('Math', function () {
});
describe('.acosh()', function () {
- if (!Math.hasOwnProperty('acosh')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'acosh')) {
return it('exists', function () {
expect(Math).to.have.property('acosh');
});
@@ -70,7 +68,7 @@ describe('Math', function () {
});
describe('.asinh()', function () {
- if (!Math.hasOwnProperty('asinh')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'asinh')) {
return it('exists', function () {
expect(Math).to.have.property('asinh');
});
@@ -112,7 +110,7 @@ describe('Math', function () {
});
describe('.atanh()', function () {
- if (!Math.hasOwnProperty('atanh')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'atanh')) {
return it('exists', function () {
expect(Math).to.have.property('atanh');
});
@@ -148,7 +146,7 @@ describe('Math', function () {
});
describe('.cbrt()', function () {
- if (!Math.hasOwnProperty('cbrt')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'cbrt')) {
return it('exists', function () {
expect(Math).to.have.property('cbrt');
});
@@ -184,7 +182,7 @@ describe('Math', function () {
});
describe('.clz32()', function () {
- if (!Math.hasOwnProperty('clz32')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'clz32')) {
return it('exists', function () {
expect(Math).to.have.property('clz32');
});
@@ -252,7 +250,7 @@ describe('Math', function () {
});
describe('.cosh()', function () {
- if (!Math.hasOwnProperty('cosh')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'cosh')) {
return it('exists', function () {
expect(Math).to.have.property('cosh');
});
@@ -296,7 +294,7 @@ describe('Math', function () {
});
describe('.expm1()', function () {
- if (!Math.hasOwnProperty('expm1')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'expm1')) {
return it('exists', function () {
expect(Math).to.have.property('expm1');
});
@@ -342,7 +340,7 @@ describe('Math', function () {
});
describe('.hypot()', function () {
- if (!Math.hasOwnProperty('hypot')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'hypot')) {
return it('exists', function () {
expect(Math).to.have.property('hypot');
});
@@ -398,7 +396,7 @@ describe('Math', function () {
});
describe('.log2()', function () {
- if (!Math.hasOwnProperty('log2')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'log2')) {
return it('exists', function () {
expect(Math).to.have.property('log2');
});
@@ -435,7 +433,7 @@ describe('Math', function () {
});
describe('.log10', function () {
- if (!Math.hasOwnProperty('log10')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'log10')) {
return it('exists', function () {
expect(Math).to.have.property('log10');
});
@@ -469,7 +467,7 @@ describe('Math', function () {
});
describe('.log1p', function () {
- if (!Math.hasOwnProperty('log1p')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'log1p')) {
return it('exists', function () {
expect(Math).to.have.property('log1p');
});
@@ -503,7 +501,7 @@ describe('Math', function () {
});
describe('.sign()', function () {
- if (!Math.hasOwnProperty('sign')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'sign')) {
return it('exists', function () {
expect(Math).to.have.property('sign');
});
@@ -550,7 +548,7 @@ describe('Math', function () {
});
describe('.sinh()', function () {
- if (!Math.hasOwnProperty('sinh')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'sinh')) {
return it('exists', function () {
expect(Math).to.have.property('sinh');
});
@@ -581,7 +579,7 @@ describe('Math', function () {
});
describe('.tanh()', function () {
- if (!Math.hasOwnProperty('tanh')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'tanh')) {
return it('exists', function () {
expect(Math).to.have.property('tanh');
});
@@ -615,7 +613,7 @@ describe('Math', function () {
});
describe('.trunc()', function () {
- if (!Math.hasOwnProperty('trunc')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'trunc')) {
return it('exists', function () {
expect(Math).to.have.property('trunc');
});
@@ -652,7 +650,7 @@ describe('Math', function () {
});
describe('.imul()', function () {
- if (!Math.hasOwnProperty('imul')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'imul')) {
return it('exists', function () {
expect(Math).to.have.property('imul');
});
@@ -749,30 +747,30 @@ describe('Math', function () {
it('returns 0 for (0,0.5)', function () {
expect(Math.round(0.5)).not.to.equal(0);
- expect(Math.round(0.5 - EPSILON / 4)).to.equal(0);
- expect(Math.round(0 + EPSILON / 4)).to.equal(0);
+ expect(Math.round(0.5 - (EPSILON / 4))).to.equal(0);
+ expect(Math.round(0 + (EPSILON / 4))).to.equal(0);
});
it('returns -0 for (-0.5,0)', function () {
expect(Math.round(-0.5)).to.equal(0);
- expect(Math.round(-0.5 - EPSILON / 3.99)).not.to.equal(0);
- expect(isNegativeZero(Math.round(-0.5 + EPSILON / 3.99))).to.equal(true);
- expect(isNegativeZero(Math.round(0 - EPSILON / 3.99))).to.equal(true);
+ expect(Math.round(-0.5 - (EPSILON / 3.99))).not.to.equal(0);
+ expect(isNegativeZero(Math.round(-0.5 + (EPSILON / 3.99)))).to.equal(true);
+ expect(isNegativeZero(Math.round(0 - (EPSILON / 3.99)))).to.equal(true);
});
it('returns 1 / Number.EPSILON + 1 for 1 / Number.EPSILON + 1', function () {
- var inverseEpsilonPlus1 = 1 / EPSILON + 1;
+ var inverseEpsilonPlus1 = (1 / EPSILON) + 1;
expect(Math.round(inverseEpsilonPlus1)).to.equal(inverseEpsilonPlus1);
});
it('returns 2 / Number.EPSILON - 1 for 2 / Number.EPSILON - 1', function () {
- var twiceInverseEpsilonMinus1 = 2 / EPSILON - 1;
+ var twiceInverseEpsilonMinus1 = (2 / EPSILON) - 1;
expect(Math.round(twiceInverseEpsilonMinus1)).to.equal(twiceInverseEpsilonMinus1);
});
});
describe('.fround()', function () {
- if (!Math.hasOwnProperty('fround')) {
+ if (!Object.prototype.hasOwnProperty.call(Math, 'fround')) {
return it('exists', function () {
expect(Math).to.have.property('fround');
});
@@ -832,7 +830,9 @@ describe('Math', function () {
var maxFloat32 = 3.4028234663852886e+38;
expect(Math.fround(maxFloat32)).to.equal(maxFloat32);
expect(Math.fround(-maxFloat32)).to.equal(-maxFloat32);
- expect(Math.fround(maxFloat32 + Math.pow(2, Math.pow(2, 8 - 1) - 1 - 23 - 2))).to.equal(maxFloat32); // round-nearest rounds down to maxFloat32
+
+ // round-nearest rounds down to maxFloat32
+ expect(Math.fround(maxFloat32 + Math.pow(2, Math.pow(2, 8 - 1) - 1 - 23 - 2))).to.equal(maxFloat32);
});
it('rounds properly with the min float 32', function () {
@@ -841,8 +841,8 @@ describe('Math', function () {
expect(Math.fround(-minFloat32)).to.equal(-minFloat32);
expect(Math.fround(minFloat32 / 2)).to.equal(0);
expect(Math.fround(-minFloat32 / 2)).to.equal(0);
- expect(Math.fround(minFloat32 / 2 + Math.pow(2, -202))).to.equal(minFloat32);
- expect(Math.fround(-minFloat32 / 2 - Math.pow(2, -202))).to.equal(-minFloat32);
+ expect(Math.fround((minFloat32 / 2) + Math.pow(2, -202))).to.equal(minFloat32);
+ expect(Math.fround((-minFloat32 / 2) - Math.pow(2, -202))).to.equal(-minFloat32);
});
});
});
diff --git a/test/number.js b/test/number.js
index fe11a0b..9ccf98f 100644
--- a/test/number.js
+++ b/test/number.js
@@ -1,5 +1,3 @@
-/* global describe, it, xit, expect, require */
-
describe('Number', function () {
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
@@ -49,55 +47,55 @@ describe('Number', function () {
describe('Number constants', function () {
it('should have max safe integer', function () {
expect(Number).to.have.property('MAX_SAFE_INTEGER');
- expect(Number.propertyIsEnumerable('MAX_SAFE_INTEGER')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'MAX_SAFE_INTEGER')).to.equal(false);
expect(Number.MAX_SAFE_INTEGER).to.equal(Math.pow(2, 53) - 1);
});
it('should have min safe integer', function () {
expect(Number).to.have.property('MIN_SAFE_INTEGER');
- expect(Number.propertyIsEnumerable('MIN_SAFE_INTEGER')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'MIN_SAFE_INTEGER')).to.equal(false);
expect(Number.MIN_SAFE_INTEGER).to.equal(-Math.pow(2, 53) + 1);
});
it('should have epsilon', function () {
expect(Number).to.have.property('EPSILON');
- expect(Number.propertyIsEnumerable('EPSILON')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'EPSILON')).to.equal(false);
expect(Number.EPSILON).to.equal(2.2204460492503130808472633361816e-16);
});
it('should have NaN', function () {
expect(Number).to.have.property('NaN');
- expect(Number.propertyIsEnumerable('NaN')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'NaN')).to.equal(false);
expect(isNaN(Number.NaN)).to.equal(true);
});
it('should have MAX_VALUE', function () {
expect(Number).to.have.property('MAX_VALUE');
- expect(Number.propertyIsEnumerable('MAX_VALUE')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'MAX_VALUE')).to.equal(false);
expect(Number.MAX_VALUE).to.equal(1.7976931348623157e+308);
});
it('should have MIN_VALUE', function () {
expect(Number).to.have.property('MIN_VALUE');
- expect(Number.propertyIsEnumerable('MIN_VALUE')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'MIN_VALUE')).to.equal(false);
expect(Number.MIN_VALUE).to.equal(5e-324);
});
it('should have NEGATIVE_INFINITY', function () {
expect(Number).to.have.property('NEGATIVE_INFINITY');
- expect(Number.propertyIsEnumerable('NEGATIVE_INFINITY')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'NEGATIVE_INFINITY')).to.equal(false);
expect(Number.NEGATIVE_INFINITY).to.equal(-Infinity);
});
it('should have POSITIVE_INFINITY', function () {
expect(Number).to.have.property('POSITIVE_INFINITY');
- expect(Number.propertyIsEnumerable('POSITIVE_INFINITY')).to.equal(false);
+ expect(Object.prototype.propertyIsEnumerable.call(Number, 'POSITIVE_INFINITY')).to.equal(false);
expect(Number.POSITIVE_INFINITY).to.equal(Infinity);
});
});
describe('.parseInt()', function () {
- if (!Number.hasOwnProperty('parseInt')) {
+ if (!Object.prototype.hasOwnProperty.call(Number, 'parseInt')) {
return it('exists', function () {
expect(Number).to.have.property('parseInt');
});
@@ -129,7 +127,7 @@ describe('Number', function () {
});
describe('.parseFloat()', function () {
- if (!Number.hasOwnProperty('parseFloat')) {
+ if (!Object.prototype.hasOwnProperty.call(Number, 'parseFloat')) {
return it('exists', function () {
expect(Number).to.have.property('parseFloat');
});
@@ -153,7 +151,7 @@ describe('Number', function () {
});
describe('.isFinite()', function () {
- if (!Number.hasOwnProperty('isFinite')) {
+ if (!Object.prototype.hasOwnProperty.call(Number, 'isFinite')) {
return it('exists', function () {
expect(Number).to.have.property('isFinite');
});
@@ -197,7 +195,7 @@ describe('Number', function () {
});
describe('.isInteger()', function () {
- if (!Number.hasOwnProperty('isInteger')) {
+ if (!Object.prototype.hasOwnProperty.call(Number, 'isInteger')) {
return it('exists', function () {
expect(Number).to.have.property('isInteger');
});
@@ -259,7 +257,7 @@ describe('Number', function () {
});
describe('.isSafeInteger()', function () {
- if (!Number.hasOwnProperty('isSafeInteger')) {
+ if (!Object.prototype.hasOwnProperty.call(Number, 'isSafeInteger')) {
return it('exists', function () {
expect(Number).to.have.property('isSafeInteger');
});
@@ -321,7 +319,7 @@ describe('Number', function () {
});
describe('.isNaN()', function () {
- if (!Number.hasOwnProperty('isNaN')) {
+ if (!Object.prototype.hasOwnProperty.call(Number, 'isNaN')) {
return it('exists', function () {
expect(Number).to.have.property('isNaN');
});
@@ -456,7 +454,10 @@ describe('Number', function () {
expect(String(Number({ valueOf: '1.1' }))).to.equal('NaN');
expect(Number({ valueOf: '1.1', toString: function () { return '2.2'; } })).to.equal(2.2);
expect(Number({ valueOf: function () { return '1.1'; }, toString: '2.2' })).to.equal(1.1);
- expect(Number({ valueOf: function () { return '1.1'; }, toString: function () { return '2.2'; } })).to.equal(1.1);
+ expect(Number({
+ valueOf: function () { return '1.1'; },
+ toString: function () { return '2.2'; }
+ })).to.equal(1.1);
expect(String(Number({ valueOf: function () { return '-0x1a2b3c'; } }))).to.equal('NaN');
expect(String(Number({ toString: function () { return '-0x1a2b3c'; } }))).to.equal('NaN');
expect(Number({ valueOf: function () { return '0o12345'; } })).to.equal(5349);
diff --git a/test/object.js b/test/object.js
index acde271..29ed3ae 100644
--- a/test/object.js
+++ b/test/object.js
@@ -1,5 +1,3 @@
-/* global describe, it, xit, expect, require, Symbol */
-
describe('Object', function () {
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
@@ -139,7 +137,7 @@ describe('Object', function () {
});
describe('.is()', function () {
- if (!Object.hasOwnProperty('is')) {
+ if (!Object.prototype.hasOwnProperty.call(Object, 'is')) {
return it('exists', function () {
expect(Object).to.have.property('is');
});
@@ -171,7 +169,7 @@ describe('Object', function () {
});
describe('.assign()', function () {
- if (!Object.hasOwnProperty('assign')) {
+ if (!Object.prototype.hasOwnProperty.call(Object, 'assign')) {
return it('exists', function () {
expect(Object).to.have.property('assign');
});
@@ -275,7 +273,11 @@ describe('Object', function () {
Object.preventExtensions(thrower);
expect(thrower).to.have.property(2, 3);
var error;
- try { Object.assign(thrower, 'wxyz'); } catch (e) { error = e; }
+ try {
+ Object.assign(thrower, 'wxyz');
+ } catch (e) {
+ error = e;
+ }
expect(thrower).not.to.have.property(0);
if (thrower[1] === 'x') {
// IE 9 doesn't throw in strict mode with preventExtensions
@@ -289,13 +291,20 @@ describe('Object', function () {
});
ifSymbolsIt('includes enumerable symbols, after keys', function () {
+ /* eslint max-statements-per-line: 1 */
var visited = [];
var obj = {};
Object.defineProperty(obj, 'a', { get: function () { visited.push('a'); return 42; }, enumerable: true });
var symbol = Symbol('enumerable');
- Object.defineProperty(obj, symbol, { get: function () { visited.push(symbol); return Infinity; }, enumerable: true });
+ Object.defineProperty(obj, symbol, {
+ get: function () { visited.push(symbol); return Infinity; },
+ enumerable: true
+ });
var nonEnumSymbol = Symbol('non-enumerable');
- Object.defineProperty(obj, nonEnumSymbol, { get: function () { visited.push(nonEnumSymbol); return -Infinity; }, enumerable: false });
+ Object.defineProperty(obj, nonEnumSymbol, {
+ get: function () { visited.push(nonEnumSymbol); return -Infinity; },
+ enumerable: false
+ });
var target = Object.assign({}, obj);
expect(visited).to.eql(['a', symbol]);
expect(target.a).to.equal(42);
diff --git a/test/promise.js b/test/promise.js
index 917a49d..213bbd8 100644
--- a/test/promise.js
+++ b/test/promise.js
@@ -1,5 +1,3 @@
-/* global describe, it, expect, require, Promise */
-
/* This file is for testing implementation regressions of Promises. */
describe('Promise', function () {
diff --git a/test/promise/evil-promises.js b/test/promise/evil-promises.js
index 2051d24..f2c3b07 100644
--- a/test/promise/evil-promises.js
+++ b/test/promise/evil-promises.js
@@ -1,5 +1,3 @@
-/* global describe, specify, assert, Promise */
-
describe('Evil promises should not be able to break invariants', function () {
'use strict';
diff --git a/test/promise/promises-aplus.js b/test/promise/promises-aplus.js
index 114c153..b7ab4f3 100644
--- a/test/promise/promises-aplus.js
+++ b/test/promise/promises-aplus.js
@@ -1,5 +1,3 @@
-/* global describe, require, Promise */
-
// tests from promises-aplus-tests
describe('Promises/A+ Tests', function () {
diff --git a/test/promise/promises-es6.js b/test/promise/promises-es6.js
index b3f7c8b..d5b307a 100644
--- a/test/promise/promises-es6.js
+++ b/test/promise/promises-es6.js
@@ -1,5 +1,3 @@
-/* global describe, require, Promise */
-
// tests from promises-es6-tests
(function () {
'use strict';
diff --git a/test/promise/race.js b/test/promise/race.js
index fc4e69c..d18309a 100644
--- a/test/promise/race.js
+++ b/test/promise/race.js
@@ -1,5 +1,3 @@
-/* global describe, it, expect, setTimeout, assert, Promise */
-
var failIfThrows = function (done) {
'use strict';
diff --git a/test/promise/reject.js b/test/promise/reject.js
index 5702b80..c1c94f9 100644
--- a/test/promise/reject.js
+++ b/test/promise/reject.js
@@ -1,5 +1,3 @@
-/* global describe, it, expect, setTimeout, Promise */
-
var failIfThrows = function (done) {
'use strict';
diff --git a/test/promise/resolve.js b/test/promise/resolve.js
index 786038d..23bad8d 100644
--- a/test/promise/resolve.js
+++ b/test/promise/resolve.js
@@ -1,5 +1,3 @@
-/* global describe, it, expect, setTimeout, Promise */
-
var failIfThrows = function (done) {
'use strict';
diff --git a/test/promise/simple.js b/test/promise/simple.js
index 9ef22e1..1feb665 100644
--- a/test/promise/simple.js
+++ b/test/promise/simple.js
@@ -1,5 +1,3 @@
-/* global describe, specify, assert, Promise */
-
var failIfThrows = function (done) {
'use strict';
diff --git a/test/reflect.js b/test/reflect.js
index a9a1d7a..7ea8419 100644
--- a/test/reflect.js
+++ b/test/reflect.js
@@ -1,5 +1,3 @@
-/* global describe, xdescribe, it, xit, expect, require, Reflect */
-
var arePropertyDescriptorsSupported = function () {
try {
Object.defineProperty({}, 'x', {});
diff --git a/test/regexp.js b/test/regexp.js
index 02c423f..ea31379 100644
--- a/test/regexp.js
+++ b/test/regexp.js
@@ -1,5 +1,3 @@
-/* global beforeEach, describe, it, expect, require */
-
var getRegexLiteral = function (stringRegex) {
try {
/* jshint evil: true */
@@ -13,7 +11,7 @@ var describeIfSupportsDescriptors = Object.getOwnPropertyDescriptor ? describe :
var callAllowsPrimitives = (function () { return this === 3; }.call(3));
var ifCallAllowsPrimitivesIt = callAllowsPrimitives ? it : it.skip;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
-var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && typeof Symbol() === 'symbol';
+var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && typeof Symbol('') === 'symbol';
var ifSymbolsDescribe = hasSymbols ? describe : describe.skip;
var defaultRegex = (function () {
// Chrome Canary 51 has an undefined RegExp#toSource, and
@@ -197,7 +195,7 @@ describe('RegExp', function () {
});
describeIfSupportsDescriptors('#flags', function () {
- if (!RegExp.prototype.hasOwnProperty('flags')) {
+ if (!Object.prototype.hasOwnProperty.call(RegExp.prototype, 'flags')) {
return it('exists', function () {
expect(RegExp.prototype).to.have.property('flags');
});
@@ -226,10 +224,10 @@ describe('RegExp', function () {
expect((/a/g).flags).to.equal('g');
expect((/a/i).flags).to.equal('i');
expect((/a/m).flags).to.equal('m');
- if (RegExp.prototype.hasOwnProperty('sticky')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(getRegexLiteral('/a/y').flags).to.equal('y');
}
- if (RegExp.prototype.hasOwnProperty('unicode')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(getRegexLiteral('/a/u').flags).to.equal('u');
}
});
@@ -238,10 +236,10 @@ describe('RegExp', function () {
expect(new RegExp('a', 'g').flags).to.equal('g');
expect(new RegExp('a', 'i').flags).to.equal('i');
expect(new RegExp('a', 'm').flags).to.equal('m');
- if (RegExp.prototype.hasOwnProperty('sticky')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(new RegExp('a', 'y').flags).to.equal('y');
}
- if (RegExp.prototype.hasOwnProperty('unicode')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(new RegExp('a', 'u').flags).to.equal('u');
}
});
@@ -250,10 +248,10 @@ describe('RegExp', function () {
expect((/a/gim).flags).to.equal('gim');
expect((/a/mig).flags).to.equal('gim');
expect((/a/mgi).flags).to.equal('gim');
- if (RegExp.prototype.hasOwnProperty('sticky')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(getRegexLiteral('/a/gyim').flags).to.equal('gimy');
}
- if (RegExp.prototype.hasOwnProperty('unicode')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(getRegexLiteral('/a/ugmi').flags).to.equal('gimu');
}
});
@@ -262,10 +260,10 @@ describe('RegExp', function () {
expect(new RegExp('a', 'gim').flags).to.equal('gim');
expect(new RegExp('a', 'mig').flags).to.equal('gim');
expect(new RegExp('a', 'mgi').flags).to.equal('gim');
- if (RegExp.prototype.hasOwnProperty('sticky')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(new RegExp('a', 'mygi').flags).to.equal('gimy');
}
- if (RegExp.prototype.hasOwnProperty('unicode')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(new RegExp('a', 'mugi').flags).to.equal('gimu');
}
});
@@ -367,10 +365,10 @@ describe('RegExp', function () {
});
it('has "multiline"', function () {
- if (RegExp.hasOwnProperty('multiline')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp, 'multiline')) {
expect(RegExp.multiline).to.equal(false);
}
- if (RegExp.hasOwnProperty('$*')) {
+ if (Object.prototype.hasOwnProperty.call(RegExp, '$*')) {
expect(RegExp['$*']).to.equal(false);
}
});
diff --git a/test/set.js b/test/set.js
index 1e5e40d..0e30c5c 100644
--- a/test/set.js
+++ b/test/set.js
@@ -1,5 +1,3 @@
-/* global describe, it, xit, expect, require, beforeEach, afterEach */
-
// Big thanks to V8 folks for test ideas.
// v8/test/mjsunit/harmony/collections.js
@@ -56,7 +54,7 @@ describe('Set', function () {
return result;
};
- var prototypePropIsEnumerable = (function () {}).propertyIsEnumerable('prototype');
+ var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype');
var expectNotEnumerable = function (object) {
if (prototypePropIsEnumerable && typeof object === 'function') {
expect(Object.keys(object)).to.eql(['prototype']);
@@ -289,7 +287,7 @@ describe('Set', function () {
});
describe('#keys()', function () {
- if (!Set.prototype.hasOwnProperty('keys')) {
+ if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'keys')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('keys');
});
@@ -313,7 +311,7 @@ describe('Set', function () {
});
describe('#values()', function () {
- if (!Set.prototype.hasOwnProperty('values')) {
+ if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'values')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('values');
});
@@ -332,7 +330,7 @@ describe('Set', function () {
});
it('throws when called on a non-Set', function () {
- var expectedMessage = /^(Method )?Set.prototype.values called on incompatible receiver |^values method called on incompatible |^Cannot create a Set value iterator for a non-Set object.$|^Set.prototype.values: 'this' is not a Set object$/;
+ var expectedMessage = /^(Method )?Set.prototype.values called on incompatible receiver |^values method called on incompatible |^Cannot create a Set value iterator for a non-Set object.$|^Set.prototype.values: 'this' is not a Set object$|^std_Set_iterator method called on incompatible \w+$/;
var nonSets = [true, false, 'abc', NaN, new Map([[1, 2]]), { a: true }, [1], Object('abc'), Object(NaN)];
nonSets.forEach(function (nonSet) {
expect(function () { return Set.prototype.values.call(nonSet); }).to['throw'](TypeError, expectedMessage);
@@ -341,7 +339,7 @@ describe('Set', function () {
});
describe('#entries()', function () {
- if (!Set.prototype.hasOwnProperty('entries')) {
+ if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'entries')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('entries');
});
@@ -361,7 +359,7 @@ describe('Set', function () {
});
describe('#has()', function () {
- if (!Set.prototype.hasOwnProperty('has')) {
+ if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'has')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('has');
});
@@ -414,7 +412,7 @@ describe('Set', function () {
});
describe('has an iterator that works with Array.from', function () {
- if (!Array.hasOwnProperty('from')) {
+ if (!Object.prototype.hasOwnProperty.call(Array, 'from')) {
return it('requires Array.from to exist', function () {
expect(Array).to.have.property('from');
});
diff --git a/test/string.js b/test/string.js
index 4fb46cc..966060e 100644
--- a/test/string.js
+++ b/test/string.js
@@ -1,5 +1,3 @@
-/* global describe, it, expect, require */
-
var runStringTests = function (it) {
'use strict';
@@ -26,7 +24,7 @@ var runStringTests = function (it) {
});
describe('#repeat()', function () {
- if (!String.prototype.hasOwnProperty('repeat')) {
+ if (!Object.prototype.hasOwnProperty.call(String.prototype, 'repeat')) {
return it('exists', function () {
expect(String.prototype).to.have.property('repeat');
});
@@ -80,7 +78,7 @@ var runStringTests = function (it) {
});
describe('#startsWith()', function () {
- if (!String.prototype.hasOwnProperty('startsWith')) {
+ if (!Object.prototype.hasOwnProperty.call(String.prototype, 'startsWith')) {
return it('exists', function () {
expect(String.prototype).to.have.property('startsWith');
});
@@ -203,7 +201,7 @@ var runStringTests = function (it) {
});
describe('#endsWith()', function () {
- if (!String.prototype.hasOwnProperty('endsWith')) {
+ if (!Object.prototype.hasOwnProperty.call(String.prototype, 'endsWith')) {
return it('exists', function () {
expect(String.prototype).to.have.property('endsWith');
});
@@ -329,7 +327,7 @@ var runStringTests = function (it) {
});
describe('#includes()', function () {
- if (!String.prototype.hasOwnProperty('includes')) {
+ if (!Object.prototype.hasOwnProperty.call(String.prototype, 'includes')) {
return it('exists', function () {
expect(String.prototype).to.have.property('includes');
});
@@ -444,7 +442,7 @@ var runStringTests = function (it) {
});
describe('.fromCodePoint()', function () {
- if (!String.hasOwnProperty('fromCodePoint')) {
+ if (!Object.prototype.hasOwnProperty.call(String, 'fromCodePoint')) {
return it('exists', function () {
expect(String).to.have.property('fromCodePoint');
});
@@ -496,7 +494,7 @@ var runStringTests = function (it) {
});
describe('#codePointAt()', function () {
- if (!String.prototype.hasOwnProperty('codePointAt')) {
+ if (!Object.prototype.hasOwnProperty.call(String.prototype, 'codePointAt')) {
return it('exists', function () {
expect(String.prototype).to.have.property('codePointAt');
});
@@ -543,7 +541,7 @@ var runStringTests = function (it) {
});
describe('#[Symbol.iterator]()', function () {
- if (!Array.hasOwnProperty('from')) {
+ if (!Object.prototype.hasOwnProperty.call(Array, 'from')) {
return it('requires Array.from to test', function () {
expect(Array).to.have.property('from');
});
@@ -563,7 +561,7 @@ var runStringTests = function (it) {
});
describe('.raw()', function () {
- if (!String.hasOwnProperty('raw')) {
+ if (!Object.prototype.hasOwnProperty.call(String, 'raw')) {
return it('exists', function () {
expect(String).to.have.property('raw');
});
@@ -588,6 +586,7 @@ var runStringTests = function (it) {
callSite.raw = ['The total is ', ' ($', ' with tax)'];
expect(String.raw(callSite, 10, 11)).to.eql(str);
+ // eslint-disable-next-line no-template-curly-in-string
str = 'The total is {total} (${total * 1.01} with tax)';
callSite.raw = ['The total is ', ' ($', ' with tax)'];
expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql(str);
@@ -600,6 +599,7 @@ var runStringTests = function (it) {
callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 };
expect(String.raw(callSite, 10, 11)).to.eql(str);
+ // eslint-disable-next-line no-template-curly-in-string
str = 'The total is {total} (${total * 1.01} with tax)';
callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 };
expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql(str);
@@ -621,7 +621,7 @@ var runStringTests = function (it) {
});
describe('#trim()', function () {
- if (!String.prototype.hasOwnProperty('trim')) {
+ if (!Object.prototype.hasOwnProperty.call(String.prototype, 'trim')) {
return it('exists', function () {
expect(String.prototype).to.have.property('trim');
});
@@ -766,7 +766,9 @@ var runStringTests = function (it) {
var str = Object('a');
var replaceVal = Object('replaceValue');
var obj = {};
- obj[Symbol.replace] = function (string, replaceValue) { return string === str && replaceValue === replaceVal && this === obj; };
+ obj[Symbol.replace] = function (string, replaceValue) {
+ return string === str && replaceValue === replaceVal && this === obj;
+ };
expect(str.replace(obj, replaceVal)).to.equal(true);
});
});
diff --git a/test/worker-test.js b/test/worker-test.js
index e7fd6c8..cf914ca 100644
--- a/test/worker-test.js
+++ b/test/worker-test.js
@@ -1,4 +1,4 @@
-/* global describe, it, expect, Worker, location */
+/* globals Worker, location */
describe('Worker', function () {
var workerErrorEventToError = function (errorEvent) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-es6-shim.git
More information about the Pkg-javascript-commits
mailing list