Template Upload
This commit is contained in:
2
node_modules/es6-shim/.eslintignore
generated
vendored
Normal file
2
node_modules/es6-shim/.eslintignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
Gruntfile.js
|
||||
*.min.js
|
51
node_modules/es6-shim/.eslintrc
generated
vendored
Normal file
51
node_modules/es6-shim/.eslintrc
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"callback-return": [0],
|
||||
"complexity": [1],
|
||||
"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],
|
||||
"no-extend-native": [2, { "exceptions": ["Set"] }],
|
||||
"no-extra-parens": [1],
|
||||
"no-func-assign": [1],
|
||||
"no-implicit-coercion": [2, {
|
||||
"boolean": false,
|
||||
"number": false,
|
||||
"string": true
|
||||
}],
|
||||
"no-invalid-this": [0],
|
||||
"no-invalid-regexp": [2, { "allowConstructorFlags": ["u", "y"] }],
|
||||
"no-magic-numbers": [0],
|
||||
"no-native-reassign": [2, { "exceptions": ["Number", "Promise", "RegExp"] }],
|
||||
"no-negated-condition": [1],
|
||||
"no-plusplus": [1],
|
||||
"no-restricted-syntax": [2, "DebuggerStatement", "LabeledStatement", "WithStatement"],
|
||||
"no-shadow": [1],
|
||||
"no-underscore-dangle": [0],
|
||||
"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]
|
||||
}
|
||||
}
|
175
node_modules/es6-shim/.jscs.json
generated
vendored
Normal file
175
node_modules/es6-shim/.jscs.json
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
{
|
||||
"es3": true,
|
||||
|
||||
"additionalRules": [],
|
||||
|
||||
"requireSemicolons": true,
|
||||
|
||||
"disallowMultipleSpaces": true,
|
||||
|
||||
"disallowIdentifierNames": [],
|
||||
|
||||
"requireCurlyBraces": {
|
||||
"allExcept": [],
|
||||
"keywords": ["if", "else", "for", "while", "do", "try", "catch"]
|
||||
},
|
||||
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],
|
||||
|
||||
"disallowSpaceAfterKeywords": [],
|
||||
|
||||
"disallowSpaceBeforeComma": true,
|
||||
"disallowSpaceAfterComma": false,
|
||||
"disallowSpaceBeforeSemicolon": true,
|
||||
|
||||
"disallowNodeTypes": [
|
||||
"DebuggerStatement",
|
||||
"LabeledStatement",
|
||||
"SwitchCase",
|
||||
"SwitchStatement",
|
||||
"WithStatement"
|
||||
],
|
||||
|
||||
"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
|
||||
|
||||
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
|
||||
"requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
|
||||
"disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true },
|
||||
"requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
|
||||
"disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
|
||||
|
||||
"requireSpaceBetweenArguments": true,
|
||||
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
|
||||
"disallowQuotedKeysInObjects": { "allExcept": ["reserved"] },
|
||||
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
|
||||
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
|
||||
"requireSpaceAfterPrefixUnaryOperators": [],
|
||||
|
||||
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
|
||||
"requireSpaceBeforePostfixUnaryOperators": [],
|
||||
|
||||
"disallowSpaceBeforeBinaryOperators": [],
|
||||
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
|
||||
|
||||
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
|
||||
"disallowSpaceAfterBinaryOperators": [],
|
||||
|
||||
"disallowImplicitTypeConversion": ["binary", "string"],
|
||||
|
||||
"disallowKeywords": ["with", "eval"],
|
||||
|
||||
"requireKeywordsOnNewLine": [],
|
||||
"disallowKeywordsOnNewLine": ["else"],
|
||||
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
|
||||
"disallowTrailingWhitespace": true,
|
||||
|
||||
"disallowTrailingComma": true,
|
||||
|
||||
"excludeFiles": ["node_modules/**", "vendor/**"],
|
||||
|
||||
"disallowMultipleLineStrings": true,
|
||||
|
||||
"requireDotNotation": { "allExcept": ["keywords"] },
|
||||
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
|
||||
"validateLineBreaks": "LF",
|
||||
|
||||
"validateQuoteMarks": {
|
||||
"escape": true,
|
||||
"mark": "'"
|
||||
},
|
||||
|
||||
"disallowOperatorBeforeLineBreak": [],
|
||||
|
||||
"requireSpaceBeforeKeywords": [
|
||||
"do",
|
||||
"for",
|
||||
"if",
|
||||
"else",
|
||||
"switch",
|
||||
"case",
|
||||
"try",
|
||||
"catch",
|
||||
"finally",
|
||||
"while",
|
||||
"with",
|
||||
"return"
|
||||
],
|
||||
|
||||
"validateAlignedFunctionParameters": {
|
||||
"lineBreakAfterOpeningBraces": true,
|
||||
"lineBreakBeforeClosingBraces": true
|
||||
},
|
||||
|
||||
"requirePaddingNewLinesBeforeExport": true,
|
||||
|
||||
"validateNewlineAfterArrayElements": {
|
||||
"maximum": 10
|
||||
},
|
||||
|
||||
"requirePaddingNewLinesAfterUseStrict": true,
|
||||
|
||||
"disallowArrowFunctions": true,
|
||||
|
||||
"disallowMultiLineTernary": true,
|
||||
|
||||
"validateOrderInObjectKeys": false,
|
||||
|
||||
"disallowIdenticalDestructuringNames": true,
|
||||
|
||||
"disallowNestedTernaries": { "maxLevel": 1 },
|
||||
|
||||
"requireSpaceAfterComma": { "allExcept": ["trailing"] },
|
||||
"requireAlignedMultilineParams": false,
|
||||
|
||||
"requireSpacesInGenerator": {
|
||||
"afterStar": true
|
||||
},
|
||||
|
||||
"disallowSpacesInGenerator": {
|
||||
"beforeStar": true
|
||||
},
|
||||
|
||||
"disallowVar": false,
|
||||
|
||||
"requireArrayDestructuring": false,
|
||||
|
||||
"requireEnhancedObjectLiterals": false,
|
||||
|
||||
"requireObjectDestructuring": false,
|
||||
|
||||
"requireEarlyReturn": false,
|
||||
|
||||
"requireCapitalizedConstructorsNew": {
|
||||
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array", "OrigNumber"]
|
||||
},
|
||||
|
||||
"requireImportAlphabetized": false,
|
||||
|
||||
"requireSpaceBeforeObjectValues": true,
|
||||
"requireSpaceBeforeDestructuredValues": true,
|
||||
|
||||
"disallowSpacesInsideTemplateStringPlaceholders": true,
|
||||
|
||||
"disallowArrayDestructuringReturn": false,
|
||||
|
||||
"requireNewlineBeforeSingleStatementsInIf": false,
|
||||
|
||||
"disallowUnusedVariables": true,
|
||||
|
||||
"requireSpacesInsideImportedObjectBraces": true,
|
||||
|
||||
"requireUseStrict": false
|
||||
}
|
||||
|
7
node_modules/es6-shim/.jshintrc
generated
vendored
Normal file
7
node_modules/es6-shim/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"es3": true,
|
||||
"esnext": true,
|
||||
"sub": true,
|
||||
"newcap": false,
|
||||
"notypeof": true
|
||||
}
|
4
node_modules/es6-shim/.npmignore
generated
vendored
Normal file
4
node_modules/es6-shim/.npmignore
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
.travis.yml
|
||||
testling.html
|
598
node_modules/es6-shim/CHANGELOG.md
generated
vendored
Normal file
598
node_modules/es6-shim/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,598 @@
|
||||
# es6-shim 0.35.3 (23 January 2017)
|
||||
* [Fix] avoid needlessly shimming `Array#{find, findIndex}` (#433)
|
||||
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `grunt-saucelabs`
|
||||
* [Tests] up to `node` `v7.4`, `v4.7`; improve test matrix
|
||||
|
||||
# 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)
|
||||
* [Refactor] Use `iteratorResult` internally for iterator result objects
|
||||
* [Refactor] Simplify logic for Math.tanh (#412)
|
||||
* [Robustness] cache `Math` constants
|
||||
* [Robustness] cache `Math.exp`
|
||||
* [Robustness] don’t rely on a `Math` lookup inside `Math.asinh`
|
||||
* [Robustness] use cached `Number.isNaN`
|
||||
* [Robustness] cache `Math.sign`
|
||||
* [Dev Deps] update `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `grunt-contrib-connect`, `grunt-contrib-watch`, `evalmd`, `jshint`
|
||||
* [Tests] up to `node` `v6.1`, `v5.10`, `v4.4`
|
||||
* [Tests] `npm run --silent`, use “pretest” for linting
|
||||
* [Tests] `RegExp#toString`: Chrome Canary 51 produces `/undefined/`
|
||||
* [Docs] update ES6 draft comment URLs to point to the published spec
|
||||
|
||||
# es6-shim 0.35.0 (29 Feb 2016)
|
||||
* [Breaking] remove `Reflect.enumerate` (#405)
|
||||
* [New] Add `Array#indexOf` from post-ES6 errata
|
||||
* [New] Ensure `RegExp#toString` is compliant
|
||||
* [New] [sham] Add `Function#toString` to `es6-sham`
|
||||
* [Fix] ensure that a non-object `globals.Reflect` doesn’t break the shim (#392)
|
||||
* [Fix] In ES3 browsers (like Safari 4) `Reflect.getPrototypeOf` is undefined
|
||||
* [Fix] `Object.keys`: handle regexes in ES3 browsers (#287)
|
||||
* [Performance] Early exit from tanh for values outside of +-20 at limits of JS precision (#411)
|
||||
* [Tests] `Function#name` on `new Function`s is empty string in v8
|
||||
* [Tests] `Function#name` is non-configurable pre-ES6
|
||||
* [Tests] up to `node` `v5.7`, `v4.3`
|
||||
* [Docs] correct readme; we sham Function#name, not toString
|
||||
|
||||
# es6-shim 0.34.4 (9 Feb 2016)
|
||||
* [Fix] 'Uncaught (in promise) TypeError' in Chrome 48 (#408, #407)
|
||||
* [Fix] handle the obscure case where `startsWith` throws on the second parameter (#399)
|
||||
* [Tests] silence a promise rejection error in Chrome
|
||||
|
||||
# es6-shim 0.34.3 (8 Feb 2016)
|
||||
* [Fix] Suppress “uncaught rejection” warnings in Chrome 50 console (#403)
|
||||
* [Fix] ensure ES3 `Number` constants don’t get lost in ES3 browsers (#402)
|
||||
* [Dev Deps] update `chai`, `es5-shim`, `jscs`, `mocha`
|
||||
* [Tests] up to `node` `v5.5`
|
||||
|
||||
# es6-shim 0.34.2 (22 Jan 2016)
|
||||
* [Fix] `JSON.stringify` should ignore a replacer arg unless it’s an array or function.
|
||||
* [Fix] `Array#copyWithin`: check for inherited properties as well
|
||||
* [Fix] `Array#copyWithin`: should delete the target key if the source key is not present
|
||||
* [Performance] Optimize Map/Set fast key path (#397)
|
||||
* [Tests] fix `Reflect.enumerate` tests to not call `next` too many times
|
||||
* [Dev Deps] update `jscs`, `jshint`
|
||||
* [Docs] update license year to 2016 (#400)
|
||||
|
||||
# es6-shim 0.34.1 (5 Jan 2016)
|
||||
* [Fix] `RegExp#[Symbol.search]` was broken with a regex argument (#394)
|
||||
* [Fix] ensure that Set#clear works with both primitive and object values
|
||||
* [Fix] static Promise methods have the wrong length in Firefox
|
||||
* [Robustness] Cache `Object.keys`
|
||||
* [Performance] Avoid accessing arguments array without length check
|
||||
* [Performance] Optimize ES.TypeIsObject (#388)
|
||||
* [Performance] Promises: lots of improvements (#383)
|
||||
* [Performance] Only use slow implementation of IsCallable where necessary (old browsers)
|
||||
* [Performance] Promises: remove unnecessary `.bind` on `setImmediate`
|
||||
* [Refactor] extract “decode fast Map key” logic
|
||||
* [Dev Deps] update `s5-shim`, `@ljharb/eslint-config`
|
||||
* Don’t npmignore tests
|
||||
* [Tests] Fix a bug with “deep equal” wrt NaN
|
||||
* [Tests] split up Map and Set test files
|
||||
* [Tests] up to `node` `v5.3`
|
||||
|
||||
# es6-shim 0.34.0 (14 Dec 2015)
|
||||
* [Breaking] Remove `Symbol.species` from `Promise.all` and `Promise.race` (#34)
|
||||
* [Fix] Firefox has enumerable Promise static methods
|
||||
* [Fix] prevent crashes in older Firefox when checking if Array methods ToLength correctly
|
||||
* [Fix] `Reflect.enumerate`: ensure correct property ordering in Firefox 19 (and likely others)
|
||||
* [Fix] Ensure that `toLengthsCorrectly` returns `true` when it passes, instead of `undefined`
|
||||
* [Fix] Don't call `Reflect.construct` unless it's actually present
|
||||
* [Fix] Ensure `Map` and `Set` do not have an own `constructor` property (#368)
|
||||
* [Fix] Add missing checks to Promise.resolve and Promise.reject (#379)
|
||||
* [Fix] `Map`: older v8s have a SameValueZero bug when a Map has a size > 4 (#378)
|
||||
* [Fix] `Map`: when provided with an iterable that yields non-Object values, should throw
|
||||
* [Fix] `Promise`: Make sure to shim broken implementations in Chrome 49 Canary
|
||||
* [Fix] `Promise`: Chrome does not retrieve a thenable's .then synchronously (#372)
|
||||
* [New] Add `RegExp.prototype[Symbol.{match,search,split,replace}]`
|
||||
* [New] support `Symbol.match` in `RegExp` constructor
|
||||
* [New] add `Symbol.match` and ensure `String#{match, startsWith, endsWith, includes}` support it
|
||||
* [New] add `Symbol.split` and ensure `String#split` supports it
|
||||
* [New] add `Symbol.replace` and ensure `String#replace` supports it
|
||||
* [New] add `Symbol.search` and ensure `String#search` supports it
|
||||
* [Robustness] Add and use `ES.ToString` so as not to rely on the global `String`
|
||||
* [Dev Deps] update `eslint`, `jscs`, `mocha`, `uglify-js`, `es5-shim`, `grunt-saucelabs`
|
||||
* [Tests] bailing out of some tests when the feature isn't present, to clean up native test failure output
|
||||
* [Tests] up to `node` `v5.2`
|
||||
* [Tests] fix `npm run test:native`
|
||||
* [Tests] Ensure `Promise.{reject,resolve}` throws when the receiver is a primitive (#379)
|
||||
* [Tests] Further ensure that Promise.resolve/reject work with a non-promise receiver (#379)
|
||||
* [Docs] update README URLs (#375)
|
||||
* [Docs] fix some typos (#380)
|
||||
|
||||
# es6-shim 0.33.13 (12 Nov 2015)
|
||||
* [Fix] `Number`: when no arguments are passed, return `+0`.
|
||||
* [Fix] `Number`: Make sure string values are trimmed before attempting to parse.
|
||||
* [Tests] cleaning up `Number` tests)
|
||||
* [Dev Deps] update `uglify-js`
|
||||
|
||||
# es6-shim 0.33.12 (11 Nov 2015)
|
||||
* [Fix] IE 8: more NFE madness.
|
||||
* [Dev Deps] update `es5-shim`
|
||||
* [Docs] removing now-fixed `Number` caveat
|
||||
* [Docs] use assertions so `evalmd` will test the readme better.
|
||||
* [Docs] fix incorrect isFinite note (#373)
|
||||
|
||||
# es6-shim 0.33.11 (9 Nov 2015)
|
||||
* [Fix] handle future change of RegExp.prototype not being a regex (#370, #371)
|
||||
* [Fix] disallow invalid hex strings in `Number` (#369)
|
||||
* [Tests] Tweak "polluted prototype" approach
|
||||
* [Dev Deps] update `chai`, `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`
|
||||
|
||||
# es6-shim 0.33.10 (2 Nov 2015)
|
||||
* [Fix] the `Number` constructor properly trims (or not) whitespace characters (#368)
|
||||
* [Fix] `Number('0b12')` and `Number('0o18')` should both be `NaN` (#366)
|
||||
* [Tests] Fix npm upgrades in older nodes
|
||||
* [Tests] add `npm run tests-only`
|
||||
* [Tests] on `node` `v5.0`
|
||||
* [Tests] ensure `JSON.stringify` has the right name
|
||||
* [Tests] add `npm run eslint`
|
||||
* [Dev Deps] update `es5-shim`, `jscs`
|
||||
* [Cleanup] Rearrange things so that they’re defined before they’re used
|
||||
* [Cleanup] Don't reassign to function or catch parameters
|
||||
* [Cleanup] Remove unused variables
|
||||
* [Refactor] String#trim shim should use `defineProperty`, and check more non-whitespace chars
|
||||
|
||||
# es6-shim 0.33.9 (29 Oct 2015)
|
||||
* [Fix] IE 8: `Number(new Number(1))` was throwing. More NFE madness. (#365)
|
||||
|
||||
# es6-shim 0.33.8 (23 Oct 2015)
|
||||
* [Fix] IE 8: `Promise.resolve(2)` was throwing. More named function expression madness.
|
||||
* [Tests] Reflect: Don't attempt to define properties on this test object unless we're in true ES5.
|
||||
|
||||
# es6-shim 0.33.7 (23 Oct 2015)
|
||||
* [Fix] Ensure `preserveToString` does not throw when the original does not exist (#359)
|
||||
* [Fix] `Promise`: properly handle named function expressions in IE 8.
|
||||
* [Fix] `Number`: `wrapConstructor` now works in ES3 (#365)
|
||||
* [Docs] Document `Number` supporting string binary and octal literals.
|
||||
* [Tests] add commented-out test for `typeof Number.call(Object(3), 3) === 'number'`, which fails atm.
|
||||
* [Tests] Fix browser tests sans-`npm install`
|
||||
* [Dev Deps] update `es5-shim`, `jscs`, `uglify-js`, `chai`
|
||||
|
||||
# es6-shim 0.33.6 (29 Sep 2015)
|
||||
* [Fix] In IE 6-8, of course, `typeof setTimeout` is "object"
|
||||
* [Tests] Upgrade jQuery on the test HTML pages
|
||||
|
||||
# es6-shim 0.33.5 (28 Sep 2015)
|
||||
* [Fix] IE 6-8 have wacky scoping issues with named function expressions.
|
||||
* [Fix] Apparently in IE 8, RegExp#test is an own property of regexes, not a prototype method
|
||||
* [Fix] Make sure to treat `es5-sham`'s `Object.defineProperty` as unsupported, in IE 8
|
||||
|
||||
# es6-shim 0.33.4 (27 Sep 2015)
|
||||
* [Fix] Add test, and fix, for `JSON.stringify(Object(Symbol()))` throwing on Chrome 45
|
||||
* [Fix] Wrap `JSON.stringify` when `Symbol` exists and it fails to serialize them correctly
|
||||
* [Fix] fix `Reflect.defineProperty` on edge v0.12
|
||||
* [Robustness] Cache `Array.isArray` internally
|
||||
* [Refactor] Use internal `overrideNative` helper for String.prototype HTML methods
|
||||
* [Refactor] Update `is-arguments` implementation; don't call down legacy code path in modern engines
|
||||
* [Tests] Add `evalmd` to verify that example code blocks are valid
|
||||
* [Tests] Adding a test for Safari 7.1 and later (runtime check added in 8a8ddd36186cdc1fcb3fcc259ec9ecef1e141901)
|
||||
* [Tests] Add additional `JSON.stringify` test for `Symbol` and object `Symbol` values
|
||||
* [Tests] up to `io.js` `v3.3`, `node` `v4.1`
|
||||
* [Dev Deps] update `es5-shim`, `mocha`, `chai`
|
||||
|
||||
# es6-shim 0.33.3 (31 Aug 2015)
|
||||
* [Fix] Handle Firefox Nightly's broken `construct` method
|
||||
* [Tests] Add `JSON.stringify` tests for handling `Symbol`s
|
||||
|
||||
# es6-shim 0.33.2 (26 Aug 2015)
|
||||
* [Fix] Make sure that minified code preserves function names.
|
||||
* [Fix] Skip the `Promise` shim when `setTimeout` is not available ([#301](https://github.com/paulmillr/es6-shim/issues/301#issuecomment-126566703))
|
||||
* [Docs] Add note about `setPrototypeOf` on null objects
|
||||
|
||||
# es6-shim 0.33.1 (20 Aug 2015)
|
||||
* [New] Add support for binary and octal literals in strings to the `Number` constructor (#358)
|
||||
* [Docs] Update spec link to final spec
|
||||
* [Fix] `Reflect.enumerate`: does not necessarily wait until the first `next()` to determine keys.
|
||||
* [Refactors] split up some tests; name some functions; remove unnecessary code
|
||||
* {Refactors] make ObjectIterator properties non-enumerable
|
||||
* [Refactors] Refactor `RegExp` wrapping code so most of it can be reused.
|
||||
* [Tests] up to `io.js` `v3.1`
|
||||
* [Dev Deps] update `grunt-contrib-connect`, `jscs`
|
||||
|
||||
# es6-shim 0.33.0 (30 Jul 2015)
|
||||
* [Breaking] Avoid CSP errors in Chrome apps by using global var detection (#301)
|
||||
* [Performance] Rearranging some of the Map/Set runtime shim clobberings to be more efficient.
|
||||
* [Refactor] Implement `Array.of` directly, rather than in terms of `Array.from`
|
||||
* [Dev Deps] Update `chai`, `es5-shim`, `promises-aplus-tests`, `uglify-js`
|
||||
* [Tests] Add test for `Object.getPrototypeOf` accepting primitives.
|
||||
* [Tests] Bail out of individual `Reflect` tests when the methods don’t exist
|
||||
* [Tests] Test on latest `io.js`
|
||||
|
||||
# es6-shim 0.32.3 (21 Jun 2015)
|
||||
* [Fix] Override or wrap native `Reflect` methods in Microsoft Edge v0.11 as required.
|
||||
* [Fix] Edge v0.11: `Array.from([], undefined)` should not throw
|
||||
* [Fix] Fix a bug in `Array.from handles iterables` runtime clobbering, which would always replace the native function
|
||||
* [Fix] Ensure that `Set#has` has the correct name in Edge v0.11
|
||||
* [Tests] Add `Map`/`Set` error messages for Edge v0.11
|
||||
* [Tests] Fix `Math.fround` test value for Edge v0.11
|
||||
* [Tests] Bail out of `Map`/`Set` test blocks if they don't exist
|
||||
* [Docs] Update ES5 subclassing instructions in the README.
|
||||
* [Dev Deps] Update `es5-shim`
|
||||
|
||||
# es6-shim 0.32.2 (17 Jun 2015)
|
||||
* [Fix] `Object.assign` with no sources should coerce to an object (#348)
|
||||
* [Fix] `String#includes` should throw when given a `RegExp` (#349)
|
||||
* [Fix] `RegExp()` should not throw (#350)
|
||||
* [Fix] Create `Value.defineByDescriptor`, fix `create` when `Object.create` is unavailable.
|
||||
* [Compliance] Update `Promise.reject` to match official ECMA-262 spec.
|
||||
* [Dev Deps] Update `es5-shim`
|
||||
|
||||
# es6-shim 0.32.1 (13 Jun 2015)
|
||||
* [Fix] Make sure that all `Map`/`Set` shim forms properly add an iterable to the collection instance.
|
||||
* [Tests] Make sure none of the `Array` ToLength tests throw *any* error (#347)
|
||||
|
||||
# es6-shim 0.32.0 (7 Jun 2015)
|
||||
* [Spec compliance] Update Promises to match finalized ES6 spec (#345, #344, #239)
|
||||
* [Fix] Ensure `Map`, `Set`, and `Promise` shims all throw when used without "new".
|
||||
* [Tests] Fix the pending exceptions test for Safari 5.1
|
||||
* [Refactor] Since the String HTML shims will be iterated anyways, no need to defineProperties them twice.
|
||||
* [Deps] Update `chai`, `es5-shim`
|
||||
|
||||
# es6-shim 0.31.3 (2 Jun 2015)
|
||||
* [Fix] Properly name more shim functions
|
||||
* [Fix] Fix an IE bug where the layout engine internally calls the userland `Object.getOwnPropertyNames`
|
||||
* [Fix] Ensure `Map.prototype[Symbol.iterator] === Map.prototype.entries`
|
||||
* [Fix] Ensure `Set.prototype[Symbol.iterator] === Set.prototype.values`
|
||||
* [Tests] `Object.assign` pending exceptions: IE 9 `preventExtensions` doesn't throw, even in strict mode
|
||||
* [Security] Cache more native methods in case they're overwritten later
|
||||
* [Tests] IE 11 has native `Map`/`Set`, but it takes an optional *function*, not an optional iterable, in the constructor
|
||||
* [Tests] Add more "exists" early bailouts, to declutter native test results
|
||||
* [Docs] Alphabetize shim lists in the README
|
||||
* [Perf] Add more `Map`/`Set` fast paths for more primitives: boolean, null, undefined
|
||||
* [Tests] Test up to `io.js` `v2.2`
|
||||
* [Deps] Update `mocha`, `es5-shim`, `uglify-js`, `jshint`
|
||||
* [Refactor] Style cleanups
|
||||
|
||||
# es6-shim 0.31.2 (9 May 2015)
|
||||
* Fix ES5 `Array.prototype` method wrappers to return the correct value. (#341)
|
||||
|
||||
# es6-shim 0.31.1 (7 May 2015)
|
||||
* `RegExp` should work properly as a wrapper (#340)
|
||||
|
||||
# es6-shim 0.31.0 (1 May 2015)
|
||||
* All Array.prototype methods should use `ToLength`, not `ToUint32`, on `this.length`.
|
||||
* Preserve and use original Array.prototype functions (for later shimming)
|
||||
* Make String#{startsWith, endsWith, includes} tests a bit more granular.
|
||||
* Fix Map/Set invalid receiver error messages for WebKit
|
||||
* Update `grunt-saucelabs`, `jscs`
|
||||
|
||||
# es6-shim 0.30.0 (26 Apr 2015)
|
||||
* `Map` and `Set` methods are not generic, and must only be called on valid `Map` and `Set` objects.
|
||||
* Use the native `Number#clz` (in Safari 8, eg) inside `Math.clz32`
|
||||
|
||||
# es6-shim 0.29.0 (26 Apr 2015)
|
||||
* Test on `io.js` `v1.7` and `v1.8`
|
||||
* Ensure that shallowly wrapped Maps’ and Sets’ prototypes aren't one level too far away.
|
||||
* Update `chai` and use new matchers
|
||||
* Avoid reassigning argument variables to avoid deoptimizations
|
||||
* Ensure that ES3 browsers get both `Object.is` and `Object.assign`
|
||||
* Improve `Object.assign` to avoid leaking arguments in v8
|
||||
* Ensuring `Number.parseInt === parseInt` (failed in FF 37)
|
||||
* a little more accurate Math.cbrt (#335)
|
||||
* Test cleanups
|
||||
* Adding `Symbol.unscopables` tests
|
||||
* Adding tests to ensure that default iterators on builtins === the appropriate prototype function.
|
||||
|
||||
# es6-shim 0.28.2 (13 Apr 2015)
|
||||
* `Map` and `Set` should have an arity of 0.
|
||||
|
||||
# es6-shim 0.28.1 (12 Apr 2015)
|
||||
* Ensure `Object.assign` only includes enumerable Symbols.
|
||||
|
||||
# es6-shim 0.28.0 (12 Apr 2015)
|
||||
* Ensure `Object.assign` also includes Symbols.
|
||||
* Make sure to clobber Firefox 37's very slow native Object.assign, that has "pending exception" logic.
|
||||
* Adding much more granular Set/Map acceptance tests and replacements, to preserve as much of the original implementation as possible. (#326, #328)
|
||||
* Lots of test additions and cleanup
|
||||
* Fill in (and fix) missing name, arity, and enumerability tests.
|
||||
* Using `property` matcher for a more helpful failure message.
|
||||
* Make sure this test doesn't fail if `Array#values` doesn't exist yet.
|
||||
* Make this `@@iterator` test not depend on `Array#values`, and properly skip tests if the symbol isn't available.
|
||||
* Update `Math.fround` with a much smaller implementation (#332)
|
||||
* Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change.
|
||||
* Update `es5-shim`, `mocha`, `grunt-contrib-connect`, `chai`, `jshint`
|
||||
* IE 11 TP has a broken `String.raw` implementation
|
||||
* Overwriting some imprecise Math functions on IE 11 TP.
|
||||
* Overwrite `Math.imul` in Safari 8 to report the correct length.
|
||||
* Fix Math.round for very large numbers
|
||||
* Don't rely on shims in tests, for better native failure checking.
|
||||
* Shim `Object.is` in ES3 environments, and add tests.
|
||||
* Test the native `Object.assign` prior to shimming it.
|
||||
* Tweak the `travis-ci` config to make a separate "lint only" test run.
|
||||
* Fix Firefox 4 test failures: ensure RegExp global aliases starting with "$" exist.
|
||||
* more efficient Math.clz32 (#327)
|
||||
* Fix Webkit nightly bugs with `Array.from` and `Array.of`.
|
||||
* Make sure shims that depend on `Number.isNaN` and `Number.isFinite` will always work.
|
||||
* The latest Webkit nightly has a bug with `String#includes` and a position arg of `Infinity`.
|
||||
* Webkit r181855 has a noncompliant `String#startsWith` and `String#endsWith`
|
||||
* Clean up README; add more accurate note about `es5-shim`.
|
||||
* Updating the `String.raw` code to be more in line with the changes in RC2/Rev 35 of the spec.
|
||||
|
||||
# es6-shim 0.27.1 (5 Mar 2015)
|
||||
* Revert `Array#slice` changes. (#322)
|
||||
* Test on `io.js` `v1.4`
|
||||
|
||||
# es6-shim 0.27.0 (26 Feb 2015)
|
||||
* Overwrite `Array#slice` so that it supports Array subclasses.
|
||||
* Improve `Map`/`Set` `TypeError` messages when called as a function. (#321)
|
||||
|
||||
# es6-shim 0.26.1 (25 Feb 2015)
|
||||
* Ensure `Array`/`Array.prototype` functions have the correct name.
|
||||
* Chrome 40 defines the incorrect name for `Array#values`
|
||||
* Make sure that `Array.of` works when subclassed.
|
||||
|
||||
# es6-shim 0.26.0 (24 Feb 2015)
|
||||
* Ensure that remaining Object static methods accept primitives.
|
||||
* Update `chai`
|
||||
* Document `String.prototype` HTML methods and `Reflect` methods in README
|
||||
|
||||
# es6-shim 0.25.3 (22 Feb 2015)
|
||||
* Removing nonexistent arguments from some String.prototype HTML methods
|
||||
* All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`.
|
||||
* Test on `iojs-v1.3`
|
||||
* Update `chai`
|
||||
* Add a LICENSE file
|
||||
|
||||
# es6-shim 0.25.2 (18 Feb 2015)
|
||||
* If someone (looking at you, chalk) has previously modified String.prototype with a non-function “bold”, don‘t break. (#315)
|
||||
|
||||
# es6-shim 0.25.1 (18 Feb 2015)
|
||||
* Add Annex B String.prototype HTML methods.
|
||||
* Overwriting Annex B String.prototype HTML methods in IE 9, which both uppercases the tag names, and fails to escape double quotes.
|
||||
* Overwriting Annex B String.prototype HTML methods in Safari 4-5, which fails to escape double quotes.
|
||||
* Ensuring that Date#toString returns “Invalid Date” when the date‘s value is NaN.
|
||||
* Test on `iojs-v1.2`
|
||||
|
||||
# es6-shim 0.25.0 (16 Feb 2015)
|
||||
* Ensure Object.getOwnPropertyNames accepts primitives.
|
||||
* Make sure the replaced `Object.keys` is non-enumerable.
|
||||
* Clean up lots of tests to make failures easier to read, and false negatives less common
|
||||
|
||||
# es6-shim 0.24.0 (5 Feb 2015)
|
||||
* Improving accuracy of Math.expm1 values, and ensuring a shim on Linux FF 35, which reports an inaccurate value for Math.expm1(10).
|
||||
* Fix bug from 7454db144e5aa251d599415cfb296b67aa3cf992 which prevented String#startsWith and String#endsWith from being overwritten in old Firefox.
|
||||
* Improve tests across a wider list of browsers
|
||||
* Ensure that individual Reflect methods are added when possible
|
||||
* Add Reflect (#313)
|
||||
* Fix node 0.11: it has an imprecise Math.sinh with very small numbers.
|
||||
* Alter String#repeat RangeError message to align with Firefox’s native implementation.
|
||||
|
||||
# es6-shim 0.23.0 (26 Jan 2015)
|
||||
* Use Symbol.species when available, else fall back to "@@species" (renamed from "@@create")
|
||||
* Fix `npm run test-native`
|
||||
* Correct broken Math implementations: `log1p`, `exmp1`, `tanh`, `acosh`, `cosh`, `sinh`, `round` (#314)
|
||||
* Update `jscs`, `grunt-saucelabs`, `jshint`
|
||||
|
||||
# es6-shim 0.22.2 (4 Jan 2015)
|
||||
* Faster travis-ci builds
|
||||
* Better ES3 support: quoting/avoiding reserved words
|
||||
* Update `mocha`, `jscs`, `jshint`, `grunt-saucelabs`, `uglify-js`
|
||||
|
||||
# es6-shim 0.22.1 (13 Dec 2014)
|
||||
* Make RegExp#flags generic, per spec (#310)
|
||||
|
||||
# es6-shim 0.22.0 (12 Dec 2014)
|
||||
* Add RegExp#flags
|
||||
* Make `new RegExp` work with both a regex and a flags string
|
||||
* Remove non-spec `Object.{getPropertyNames,getPropertyDescriptor}`
|
||||
|
||||
# es6-shim 0.21.1 (4 Dec 2014)
|
||||
* Promise/Promise.prototype methods, and String#{startsWith,endsWith} are now not enumerable
|
||||
* Array#{keys, values, entries} should all be @@unscopeable in browsers that support that
|
||||
* Ensure that tampering with Function#{call,apply} won’t break internal methods
|
||||
* Add Math.clz32, RegExp tests
|
||||
* Update es6-sham UMD
|
||||
* Update `chai`, `es5-shim`, `grunt-saucelabs`, `jscs`
|
||||
|
||||
# es6-shim 0.21.0 (21 Nov 2014)
|
||||
* String#contains → String#includes per 2014-11-19 TC39 meeting
|
||||
* Use an invalid identifier as the es6-shim iterator key, so it doesn’t show up in the console as easily.
|
||||
|
||||
# es6-shim 0.20.4 (20 Nov 2014)
|
||||
* Performance improvements: avoid slicing arguments, avoid `Function#call` when possible
|
||||
* Name `String.{fromCodePoint,raw}` for debugging
|
||||
* Fix `String.raw` to match spec
|
||||
* Ensure Chrome’s excess Promise methods are purged
|
||||
* Ensure `Set#keys === Set#values`, per spec
|
||||
|
||||
# es6-shim 0.20.3 (19 Nov 2014)
|
||||
* Fix Set#add and Map#set to always return "this" (#302)
|
||||
* Clarify TypeError messages thrown by Map/Set
|
||||
* Fix Chrome 38 bug with Array#values
|
||||
|
||||
# es6-shim 0.20.2 (28 Oct 2014)
|
||||
* Fix AMD (#299)
|
||||
|
||||
# es6-shim 0.20.1 (27 Oct 2014)
|
||||
* Set#delete and Map#delete should return false unless a deletion occurred. (#298)
|
||||
|
||||
# es6-shim 0.20.0 (26 Oct 2014)
|
||||
* Use a more reliable UMD
|
||||
* export the global object rather than undefined
|
||||
|
||||
# es6-shim 0.19.2 (25 Oct 2014)
|
||||
* Set#delete and Map#delete should return a boolean indicating success. (#298)
|
||||
* Make style consistent; add jscs
|
||||
|
||||
# es6-shim 0.19.1 (14 Oct 2014)
|
||||
* Fix Map#set and Set#add to be chainable (#295)
|
||||
* Update mocha
|
||||
|
||||
# es6-shim 0.19.0 (9 Oct 2014)
|
||||
* Detect and override noncompliant Map in Firefox 32 (#294)
|
||||
* Fix Map and Set for engines that don’t preserve numeric key order (#292, #290)
|
||||
* Detect and override noncompliant Safari 7.1 Promises (#289)
|
||||
* Fix Array#keys and Array#entries in Safari 7.1
|
||||
* General style and whitespace cleanup
|
||||
* Update dependencies
|
||||
* Clean up tests for ES3 by removing reserved words
|
||||
|
||||
# es6-shim 0.18.0 (6 Sep 2014)
|
||||
* Speed up String#trim replacement (#284)
|
||||
* named Array#find and Array#findIndex for easier debugging
|
||||
* Replace broken native implementation in Firefox 25-31 for Array#find and Array#findIndex
|
||||
* Ensure String.fromCodePoint has the correct length in Firefox
|
||||
* List the license in `package.json` for `npm`
|
||||
* Array.from: fix spec bug with Array.from([], undefined) throwing
|
||||
* Array.from: fix Firefox Array.from bug wrt swallowing negative lengths vs throwing
|
||||
|
||||
# es6-shim 0.17.0 (31 Aug 2014)
|
||||
* Added es6-sham (#281)
|
||||
* Fixing some flaky tests (#268)
|
||||
* Tweaking how ArrayIterator is checked in its "next" function
|
||||
* Cleaning up some of the logic in Array.from
|
||||
|
||||
# es6-shim 0.16.0 (6 Aug 2014)
|
||||
* Array#find and Array#findIndex: no longer skips holes in sparse arrays, per https://bugs.ecmascript.org/show_bug.cgi?id=3107
|
||||
|
||||
# es6-shim 0.15.1 (5 Aug 2014)
|
||||
* Array.from: now correctly throws if provided `undefined` as a mapper function
|
||||
* Array.from: now correctly works if provided a falsy `thisArg`
|
||||
* Fix tests so they work properly when Array#(values|keys|entries) are not present
|
||||
* Add `npm run lint` to run style checks independently
|
||||
* Add `test/native.html` so browsers can be easily checked for shim-less compliance.
|
||||
|
||||
# es6-shim 0.15.0 (31 Jul 2014)
|
||||
* Object.assign no longer throws on null or undefined sources, per https://bugs.ecmascript.org/show_bug.cgi?id=3096
|
||||
|
||||
# es6-shim 0.14.0 (20 Jul 2014)
|
||||
* Properly recognize Symbol.iterator when it is present (#277)
|
||||
* Fix Math.clz’s improper handling of values that coerce to NaN (#269)
|
||||
* Fix incorrect handling of negative end index on Array#fill (#270)
|
||||
* Removed Object.getOwnPropertyKeys, which shouldn’t be anywhere (#267)
|
||||
* Fixed arity of Map and Set constructors, per 2014.04.27 draft spec (rev 24)
|
||||
* Added a full additional suite of ES6 promise tests (thanks to @smikes!) (#265)
|
||||
* Make Number.isInteger a bit more efficient (#266)
|
||||
* Added `npm run test-native` to expose how broken implementations are without the shim ;-)
|
||||
* Added additional tests
|
||||
|
||||
# es6-shim 0.13.0 (11 Jun 2014)
|
||||
* Adapt to new Array.from changes: mapper function is now called with both value and index (#261, #262)
|
||||
* More reliably getting the global object in strict mode to fix node-webkit (#258, #259)
|
||||
* Properly test the global Promise for ignoring non-function callbacks (#258)
|
||||
|
||||
# es6-shim 0.12.0 (4 Jun 2014)
|
||||
* Fix String#trim implementations that incorrectly trim \u0085
|
||||
* Stop relying on ArrayIterator being a public var, fixing Safari 8
|
||||
|
||||
# es6-shim 0.11.1 (2 Jun 2014)
|
||||
* Make sure to shim Object.assign in all environments, not just true ES5
|
||||
* Now including minified file and source map
|
||||
|
||||
# es6-shim 0.11.0 (11 May 2014)
|
||||
* Remove `Object.getOwnPropertyDescriptors`, per spec. (#234, #235)
|
||||
* IE8 fixes. (#163, #236)
|
||||
* Improve `Promise` scheduling. (#231)
|
||||
* Add some more standalone shims
|
||||
* Use an Object.create fallback, for better ES3 compatibility
|
||||
* Fix Math.expm1 in more browsers (#84)
|
||||
* Fix es6-shim in Web Workers (#247, #248)
|
||||
* Correct Object.assign to take multiple sources (#241)
|
||||
|
||||
# es6-shim 0.10.1 (13 Mar 2014)
|
||||
* Update bower.json, component.json, and .npmignore (#229, #230, #233)
|
||||
* Minor updates to `Promise` implementation and test suite.
|
||||
* Workaround lack of "strict mode" in IE9. (#232)
|
||||
|
||||
# es6-shim 0.10.0 (1 March 2014)
|
||||
* Implement `Promise`, per spec. (#209, #215, #224, #225)
|
||||
* Make `Map`/`Set` subclassable; support `iterable` argument to
|
||||
constructor (#218)
|
||||
* Rename `Number#clz` to `Math.clz32` (#217)
|
||||
* Bug fixes to `Array#find` and `Array#findIndex` on sparse arrays (#213)
|
||||
* Re-add `Number.isInteger` (mistakenly removed in 0.9.0)
|
||||
* Allow use of `arguments` as an iterable
|
||||
* Minor spec-compliance fixes for `String.raw`
|
||||
* In ES6, `Object.keys` accepts non-Object types (#220)
|
||||
* Improved browser compatibility with IE 9/10, Opera 12 (#225)
|
||||
|
||||
# es6-shim 0.9.3 (5 February 2014)
|
||||
* Per spec, removed `Object.mixin` (#192)
|
||||
* Per spec, treat -0 and +0 keys as identical in Map/Set (#129, #204)
|
||||
* Per spec, `ArrayIterator`/`Array#values()` skips sparse indexes now. (#189)
|
||||
* Added `Array.from`, supporting Map/Set/Array/String iterators (the String iterator iterates over codepoints, not indexes) (#182)
|
||||
* Bug fixes to Map/Set iteration after concurrent delete. (#183)
|
||||
* Bug fixes to `Number.clz`: 0 and 0x100000000 are handled correctly now. (#196)
|
||||
* Added `Math.fround` to truncate to a 32-bit floating point number. (#140)
|
||||
* Bug fix for `Math.cosh` (#178)
|
||||
* Work around Firefox bugs in `String#startsWith` and `String#endsWith` (#172)
|
||||
* Work around Safari bug in `Math.imul`
|
||||
|
||||
# es6-shim 0.9.2 (18 December 2013)
|
||||
* Negative `String#endsWith` position is now handled properly.
|
||||
* `TypeError` is now thrown when string methods are called
|
||||
on `null` / `undefined`.
|
||||
|
||||
# es6-shim 0.9.1 (28 October 2013)
|
||||
* Added `Array#copyWithin` and `Number.MIN_SAFE_INTEGER`
|
||||
* Big speed-up of Maps / Sets for string / number keys:
|
||||
they are O(1) now.
|
||||
* Changed `Math.hypot` according to spec.
|
||||
* Other small fixes.
|
||||
|
||||
# es6-shim 0.9.0 (30 August 2013)
|
||||
* Added Array iteration methods: `Array#keys`, `Array#values`, `Array#entries`, which return an `ArrayIterator`
|
||||
* Changed `Map` and `Set` constructors to conform to spec when called without `new`
|
||||
* Added `Math.imul`
|
||||
* Per spec, removed `Number.toInteger`, `Number.isInteger`, and `Number.MAX_INTEGER`; added `Number.isSafeInteger`, `Number.MAX_SAFE_INTEGER`
|
||||
* Added extensive additional tests for many methods
|
||||
|
||||
# es6-shim 0.8.0 (8 June 2013)
|
||||
* Added `Object.setPrototypeOf`, `Set#keys`, `Set#values`, `Map#keys`, `Map#values`, `Map#entries`, `Set#entries`.
|
||||
* Fixed `String#repeat` according to spec.
|
||||
|
||||
# es6-shim 0.7.0 (2 April 2013)
|
||||
* Added `Array#find`, `Array#findIndex`, `Object.assign`, `Object.mixin`,
|
||||
`Math.cbrt`, `String.fromCodePoint`, `String#codePointAt`.
|
||||
* Removed `Object.isnt`.
|
||||
* Made Math functions fully conform spec.
|
||||
|
||||
# es6-shim 0.6.0 (15 January 2013)
|
||||
* Added `Map#keys`, `Map#values`, `Map#size`, `Set#size`, `Set#clear`.
|
||||
|
||||
# es6-shim 0.5.3 (2 September 2012)
|
||||
* Made `String#startsWith`, `String#endsWith` fully conform spec.
|
||||
|
||||
# es6-shim 0.5.2 (17 June 2012)
|
||||
* Removed `String#toArray` and `Object.isObject` as per spec updates.
|
||||
|
||||
# es6-shim 0.5.1 (14 June 2012)
|
||||
* Made Map and Set follow Spidermonkey implementation instead of V8.
|
||||
`var m = Map(); m.set('key', void 0); m.has('key');` now gives true.
|
||||
|
||||
# es6-shim 0.5.0 (13 June 2012)
|
||||
* Added Number.MAX_INTEGER, Number.EPSILON, Number.parseInt,
|
||||
Number.parseFloat, Number.prototype.clz, Object.isObject.
|
||||
|
||||
# es6-shim 0.4.1 (11 May 2012)
|
||||
* Fixed boundary checking in Number.isInteger.
|
||||
|
||||
# es6-shim 0.4.0 (8 February 2012)
|
||||
* Added Math.log10, Math.log2, Math.log1p, Math.expm1, Math.cosh,
|
||||
Math.sinh, Math.tanh, Math.acosh, Math.asinh, Math.atanh, Math.hypot,
|
||||
Math.trunc.
|
||||
|
||||
# es6-shim 0.3.1 (30 January 2012)
|
||||
* Added IE8 support.
|
||||
|
||||
# es6-shim 0.3.0 (27 January 2012)
|
||||
* Added Number.isFinite() and Object.isnt().
|
||||
|
||||
# es6-shim 0.2.1 (7 January 2012)
|
||||
* Fixed a bug in String#endsWith().
|
||||
|
||||
# es6-shim 0.2.0 (25 December 2011)
|
||||
* Added browser support.
|
||||
* Added tests.
|
||||
* Added Math.sign().
|
||||
|
||||
# es6-shim 0.1.0 (25 December 2011)
|
||||
* Initial release
|
98
node_modules/es6-shim/Gruntfile.js
generated
vendored
Normal file
98
node_modules/es6-shim/Gruntfile.js
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
var browsers = [
|
||||
{ browserName: 'firefox', version: '19', platform: 'XP' },
|
||||
{ browserName: 'firefox', platform: 'linux' },
|
||||
{ browserName: 'firefox', platform: 'OS X 10.10' },
|
||||
{ browserName: 'chrome', platform: 'linux' },
|
||||
{ browserName: 'chrome', platform: 'OS X 10.9' },
|
||||
{ browserName: 'chrome', platform: 'XP' },
|
||||
{ browserName: 'internet explorer', platform: 'Windows 8.1', version: '11' },
|
||||
{ browserName: 'internet explorer', platform: 'WIN8', version: '10' },
|
||||
{ browserName: 'internet explorer', platform: 'VISTA', version: '9' },
|
||||
{ browserName: 'safari', platform: 'OS X 10.6' },
|
||||
{ browserName: 'safari', platform: 'OS X 10.8' },
|
||||
{ browserName: 'safari', platform: 'OS X 10.9' },
|
||||
{ browserName: 'safari', platform: 'OS X 10.10' },
|
||||
{ browserName: 'iphone', platform: 'OS X 10.9', version: '7.1' },
|
||||
{ browserName: 'android', platform: 'Linux', version: '4.4' },
|
||||
];
|
||||
var extraBrowsers = [
|
||||
{ browserName: 'firefox', platform: 'linux', version: '30' },
|
||||
{ browserName: 'firefox', platform: 'linux', version: '25' },
|
||||
{ browserName: 'iphone', platform: 'OS X 10.8', version: '6.1' },
|
||||
{ browserName: 'iphone', platform: 'OS X 10.8', version: '5.1' },
|
||||
{ browserName: 'android', platform: 'Linux', version: '4.2' },
|
||||
// XXX haven't investigated these:
|
||||
// { browserName: 'opera', platform: 'Windows 7', version: '12' },
|
||||
// { browserName: 'opera', platform: 'Windows 2008', version: '12' }
|
||||
// { browserName: 'iphone', platform: 'OS X 10.6', version: '4.3' },
|
||||
// { browserName: 'android', platform: 'Linux', version: '4.0' },
|
||||
];
|
||||
if (grunt.option('extra')) {
|
||||
browsers = browsers.concat(extraBrowsers);
|
||||
}
|
||||
grunt.initConfig({
|
||||
connect: {
|
||||
server: {
|
||||
options: {
|
||||
base: '',
|
||||
port: 9999,
|
||||
useAvailablePort: true
|
||||
}
|
||||
}
|
||||
},
|
||||
'saucelabs-mocha': {
|
||||
all: {
|
||||
options: {
|
||||
urls: (function () {
|
||||
var urls = ['http://localhost:9999/test/'];
|
||||
if (grunt.option('extra')) {
|
||||
urls.push('http://localhost:9999/test-sham/');
|
||||
}
|
||||
return urls;
|
||||
}()),
|
||||
// tunnelTimeout: 5,
|
||||
build: process.env.TRAVIS_BUILD_NUMBER,
|
||||
tunneled: !process.env.SAUCE_HAS_TUNNEL,
|
||||
identifier: process.env.TRAVIS_JOB_NUMBER,
|
||||
sauceConfig: {
|
||||
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
|
||||
},
|
||||
// concurrency: 3,
|
||||
browsers: browsers,
|
||||
testname: (function () {
|
||||
var testname = 'mocha';
|
||||
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
||||
testname += ' (PR ' + process.env.TRAVIS_PULL_REQUEST + ')';
|
||||
}
|
||||
if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') {
|
||||
testname += ' (branch ' + process.env.TRAVIS_BRANCH + ')';
|
||||
}
|
||||
return testname;
|
||||
}()),
|
||||
tags: (function () {
|
||||
var tags = [];
|
||||
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
||||
tags.push('PR-' + process.env.TRAVIS_PULL_REQUEST);
|
||||
}
|
||||
if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') {
|
||||
tags.push(process.env.TRAVIS_BRANCH);
|
||||
}
|
||||
return tags;
|
||||
}())
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {}
|
||||
});
|
||||
// Loading dependencies
|
||||
for (var key in grunt.file.readJSON('package.json').devDependencies) {
|
||||
if (key !== 'grunt' && key.indexOf('grunt') === 0) {
|
||||
grunt.loadNpmTasks(key);
|
||||
}
|
||||
}
|
||||
grunt.registerTask('dev', ['connect', 'watch']);
|
||||
grunt.registerTask('sauce', ['connect', 'saucelabs-mocha']);
|
||||
};
|
26
node_modules/es6-shim/LICENSE
generated
vendored
Normal file
26
node_modules/es6-shim/LICENSE
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
The project was initially based on [es6-shim by Axel Rauschmayer](https://github.com/rauschma/es6-shim).
|
||||
|
||||
Current maintainers are: [Paul Miller](http://paulmillr.com), [Jordan Harband](https://github.com/ljharb), and [C. Scott Ananian](http://cscott.net).
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2016 Paul Miller (http://paulmillr.com) and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
269
node_modules/es6-shim/README.md
generated
vendored
Normal file
269
node_modules/es6-shim/README.md
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
# ES6 Shim
|
||||
Provides compatibility shims so that legacy JavaScript engines behave as
|
||||
closely as possible to ECMAScript 6 (Harmony).
|
||||
|
||||
[![Build Status][1]][2] [![dependency status][3]][4] [![dev dependency status][5]][6]
|
||||
|
||||
[](https://ci.testling.com/paulmillr/es6-shim)
|
||||
|
||||
[](https://saucelabs.com/u/es6-shim)
|
||||
|
||||
[HTML version of the final ECMAScript 6 spec][spec-html-url]
|
||||
|
||||
## Installation
|
||||
If you want to use it in browser:
|
||||
|
||||
* Just include es6-shim before your scripts.
|
||||
* Include [es5-shim][es5-shim-url] especially if your browser doesn't support ECMAScript 5 - but every JS engine requires the `es5-shim` to correct broken implementations, so it's strongly recommended to always include it.
|
||||
|
||||
For `node.js`, `io.js`, or any `npm`-managed workflow (this is the recommended method):
|
||||
|
||||
npm install es6-shim
|
||||
|
||||
Alternative methods:
|
||||
* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/componentjs/component).
|
||||
* `bower install es6-shim` if you’re using [Bower](http://bower.io/).
|
||||
|
||||
In both browser and node you may also want to include `unorm`; see the [`String.prototype.normalize`](#stringprototypenormalize) section for details.
|
||||
|
||||
## Safe shims
|
||||
|
||||
* `Map`, `Set` (requires ES5 property descriptor support)
|
||||
* `Promise`
|
||||
* `String`:
|
||||
* `fromCodePoint()` ([a standalone shim is also available](http://mths.be/fromcodepoint))
|
||||
* `raw()`
|
||||
* `String.prototype`:
|
||||
* `codePointAt()` ([a standalone shim is also available](http://mths.be/codepointat))
|
||||
* `endsWith()` ([a standalone shim is also available](http://mths.be/endswith))
|
||||
* `includes()` ([a standalone shim is also available](http://mths.be/includes))
|
||||
* `repeat()` ([a standalone shim is also available](http://mths.be/repeat))
|
||||
* `startsWith()` ([a standalone shim is also available](http://mths.be/startswith))
|
||||
* `RegExp`:
|
||||
* `new RegExp`, when given a RegExp as the pattern, will no longer throw when given a "flags" string argument. (requires ES5)
|
||||
* `RegExp.prototype`:
|
||||
* `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags))
|
||||
* `[Symbol.match]` (requires native `Symbol`s)
|
||||
* `[Symbol.replace]` (requires native `Symbol`s)
|
||||
* `[Symbol.search]` (requires native `Symbol`s)
|
||||
* `[Symbol.split]` (requires native `Symbol`s)
|
||||
* `toString`
|
||||
* `Number`:
|
||||
* binary and octal literals: `Number('0b1')` and `Number('0o7')`
|
||||
* `EPSILON`
|
||||
* `MAX_SAFE_INTEGER`
|
||||
* `MIN_SAFE_INTEGER`
|
||||
* `isNaN()`([a standalone shim is also available](https://www.npmjs.com/package/is-nan))
|
||||
* `isInteger()`
|
||||
* `isSafeInteger()`
|
||||
* `isFinite()`
|
||||
* `parseInt()`
|
||||
* `parseFloat()`
|
||||
* `Array`:
|
||||
* `from()` ([a standalone shim is also available](https://www.npmjs.com/package/array.from))
|
||||
* `of()` ([a standalone shim is also available](https://www.npmjs.com/package/array.of))
|
||||
* `Array.prototype`:
|
||||
* `copyWithin()`
|
||||
* `entries()`
|
||||
* `fill()`
|
||||
* `find()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.find))
|
||||
* `findIndex()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.findIndex))
|
||||
* `keys()` (note: keys/values/entries return an `ArrayIterator` object)
|
||||
* `values()`
|
||||
* `indexOf()` (ES6 errata)
|
||||
* `Object`:
|
||||
* `assign()` ([a standalone shim is also available](https://github.com/ljharb/object.assign))
|
||||
* `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is))
|
||||
* `keys()` (in ES5, but no longer throws on non-object non-null/undefined values in ES6)
|
||||
* `setPrototypeOf()` (IE >= 11)
|
||||
* `Function.prototype`:
|
||||
* `name` (es6-sham, covers IE 9-11)
|
||||
* `Math`:
|
||||
* `acosh()`
|
||||
* `asinh()`
|
||||
* `atanh()`
|
||||
* `cbrt()`
|
||||
* `clz32()`
|
||||
* `cosh()`
|
||||
* `expm1()`
|
||||
* `fround()`
|
||||
* `hypot()`
|
||||
* `imul()`
|
||||
* `log10()`
|
||||
* `log1p()`
|
||||
* `log2()`
|
||||
* `sign()`
|
||||
* `sinh()`
|
||||
* `tanh()`
|
||||
* `trunc()`
|
||||
|
||||
Math functions’ accuracy is 1e-11.
|
||||
|
||||
* `Reflect`
|
||||
* `apply()`
|
||||
* `construct()`
|
||||
* `defineProperty()`
|
||||
* `deleteProperty()`
|
||||
* `get()`
|
||||
* `getOwnPropertyDescriptor()`
|
||||
* `getPrototypeOf()`
|
||||
* `has()`
|
||||
* `isExtensible()`
|
||||
* `ownKeys()`
|
||||
* `preventExtensions()`
|
||||
* `set()`
|
||||
* `setPrototypeOf()`
|
||||
|
||||
* `Symbol` (only if it already exists)
|
||||
* `match` (and corresponding `String#match`, `String#startsWith`, `String#endsWith`, `String#includes`, `RegExp` support)
|
||||
* `replace` (and corresponding `String#replace` support)
|
||||
* `search` (and corresponding `String#search` support)
|
||||
* `split` (and corresponding `String#split` support)
|
||||
|
||||
Well-known symbols will only be provided if the engine already has `Symbol` support.
|
||||
|
||||
* `String.prototype` Annex B HTML methods
|
||||
* `anchor()`
|
||||
* `big()`
|
||||
* `blink()`
|
||||
* `bold()`
|
||||
* `fixed()`
|
||||
* `fontcolor()`
|
||||
* `fontsize()`
|
||||
* `italics()`
|
||||
* `link()`
|
||||
* `small()`
|
||||
* `strike()`
|
||||
* `sub()`
|
||||
* `sup()`
|
||||
|
||||
These methods are part of "Annex B", which means that although they are a defacto standard, you shouldn't use them. None the less, the `es6-shim` provides them and normalizes their behavior across browsers.
|
||||
|
||||
## Subclassing
|
||||
The `Map`, `Set`, and `Promise` implementations are subclassable.
|
||||
You should use the following pattern to create a subclass in ES5 which will continue to work in ES6:
|
||||
```javascript
|
||||
require('es6-shim');
|
||||
|
||||
function MyPromise(exec) {
|
||||
var promise = new Promise(exec);
|
||||
Object.setPrototypeOf(promise, MyPromise.prototype);
|
||||
// ...
|
||||
return promise;
|
||||
}
|
||||
Object.setPrototypeOf(MyPromise, Promise);
|
||||
MyPromise.prototype = Object.create(Promise.prototype, {
|
||||
constructor: { value: MyPromise }
|
||||
});
|
||||
```
|
||||
|
||||
## String.prototype.normalize
|
||||
Including a proper shim for `String.prototype.normalize` would increase the size of this library by a factor of more than 4.
|
||||
So instead we recommend that you install the [`unorm`](https://github.com/walling/unorm) package alongside `es6-shim` if you need `String.prototype.normalize`.
|
||||
See https://github.com/paulmillr/es6-shim/issues/134 for more discussion.
|
||||
|
||||
|
||||
## WeakMap shim
|
||||
It is not possible to implement WeakMap in pure javascript.
|
||||
The [es6-collections](https://github.com/WebReflection/es6-collections) implementation doesn't hold values strongly, which is critical for the collection. `es6-shim` decided to not include an incorrect shim.
|
||||
|
||||
`WeakMap` has very unusual use-cases, so you probably won't need it at all (use simple `Map` instead).
|
||||
|
||||
## Getting started
|
||||
|
||||
```javascript
|
||||
require('es6-shim');
|
||||
var assert = require('assert');
|
||||
|
||||
assert.equal(true, 'abc'.startsWith('a'));
|
||||
assert.equal(false, 'abc'.endsWith('a'));
|
||||
assert.equal(true, 'john alice'.includes('john'));
|
||||
assert.equal('123'.repeat(2), '123123');
|
||||
|
||||
assert.equal(false, NaN === NaN);
|
||||
assert.equal(true, Object.is(NaN, NaN));
|
||||
assert.equal(true, -0 === 0);
|
||||
assert.equal(false, Object.is(-0, 0));
|
||||
|
||||
var result = Object.assign({ a: 1 }, { b: 2 });
|
||||
assert.deepEqual(result, { a: 1, b: 2 });
|
||||
|
||||
assert.equal(true, isNaN('a'));
|
||||
assert.equal(false, Number.isNaN('a'));
|
||||
assert.equal(true, Number.isNaN(NaN));
|
||||
|
||||
assert.equal(true, isFinite('123'));
|
||||
assert.equal(false, Number.isFinite('123'));
|
||||
assert.equal(false, Number.isFinite(Infinity));
|
||||
|
||||
// Tests if value is a number, finite,
|
||||
// >= -9007199254740992 && <= 9007199254740992 and floor(value) === value
|
||||
assert.equal(false, Number.isInteger(2.4));
|
||||
|
||||
assert.equal(1, Math.sign(400));
|
||||
assert.equal(0, Math.sign(0));
|
||||
assert.equal(-1, Math.sign(-400));
|
||||
|
||||
var found = [5, 10, 15, 10].find(function (item) { return item / 2 === 5; });
|
||||
assert.equal(10, found);
|
||||
|
||||
var foundIndex = [5, 10, 15, 10].findIndex(function (item) { return item / 2 === 5; });
|
||||
assert.equal(1, foundIndex);
|
||||
|
||||
// Replacement for `{}` key-value storage.
|
||||
// Keys can be anything.
|
||||
var map = new Map([['Bob', 42], ['Foo', 'bar']]);
|
||||
map.set('John', 25);
|
||||
map.set('Alice', 400);
|
||||
map.set(['meh'], 555);
|
||||
assert.equal(undefined, map.get(['meh'])); // undefined because you need to use exactly the same object.
|
||||
map.delete('Alice');
|
||||
map.keys();
|
||||
map.values();
|
||||
assert.equal(4, map.size);
|
||||
|
||||
// Useful for storing unique items.
|
||||
var set = new Set([0, 1]);
|
||||
set.add(2);
|
||||
set.add(5);
|
||||
assert.equal(true, set.has(0));
|
||||
assert.equal(true, set.has(1));
|
||||
assert.equal(true, set.has(2));
|
||||
assert.equal(false, set.has(4));
|
||||
assert.equal(true, set.has(5));
|
||||
set.delete(5);
|
||||
assert.equal(false, set.has(5));
|
||||
|
||||
// Promises, see
|
||||
// http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript
|
||||
// https://github.com/petkaantonov/bluebird/#what-are-promises-and-why-should-i-use-them
|
||||
Promise.resolve(5).then(function (value) {
|
||||
assert.equal(value, 5);
|
||||
if (value) throw new Error('whoops!');
|
||||
// do some stuff
|
||||
return anotherPromise();
|
||||
}).catch(function (e) {
|
||||
assert.equal(e.message, 'whoops!');
|
||||
assert.equal(true, e instanceof Error);
|
||||
// any errors thrown asynchronously end up here
|
||||
});
|
||||
```
|
||||
|
||||
## Caveats
|
||||
|
||||
- `Object.setPrototypeOf` / `Reflect.setPrototypeOf`
|
||||
- Note that null objects (`Object.create(null)`, eg, an object with `null` as its `[[Prototype]]`) can not have their `[[Prototype]]` changed except via a native `Object.setPrototypeOf`.
|
||||
- Well-known `Symbol`s
|
||||
- In order to make them work cross-realm, these are created with the global `Symbol` registry via `Symbol.for`. This does not violate the spec, but it does mean that `Symbol.for('Symbol.search') === Symbol.search` will be `true`, which it would not by default in a fresh compliant realm.
|
||||
|
||||
## [License][license-url]
|
||||
|
||||
[1]: https://travis-ci.org/paulmillr/es6-shim.svg
|
||||
[2]: https://travis-ci.org/paulmillr/es6-shim
|
||||
[3]: https://david-dm.org/paulmillr/es6-shim.svg
|
||||
[4]: https://david-dm.org/paulmillr/es6-shim
|
||||
[5]: https://david-dm.org/paulmillr/es6-shim/dev-status.svg
|
||||
[6]: https://david-dm.org/paulmillr/es6-shim#info=devDependencies
|
||||
[license-url]: https://github.com/paulmillr/es6-shim/blob/master/LICENSE
|
||||
[spec-html-url]: http://www.ecma-international.org/ecma-262/6.0/
|
||||
[es5-shim-url]: https://github.com/es-shims/es5-shim
|
28
node_modules/es6-shim/bower.json
generated
vendored
Normal file
28
node_modules/es6-shim/bower.json
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "es6-shim",
|
||||
"repo": "paulmillr/es6-shim",
|
||||
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
|
||||
"keywords": [
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"es6",
|
||||
"shim",
|
||||
"promise",
|
||||
"promises",
|
||||
"setPrototypeOf",
|
||||
"map",
|
||||
"set",
|
||||
"__proto__"
|
||||
],
|
||||
"main": "es6-shim.js",
|
||||
"scripts": ["es6-shim.js"],
|
||||
"dependencies": {},
|
||||
"development": {},
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"components",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
|
23
node_modules/es6-shim/component.json
generated
vendored
Normal file
23
node_modules/es6-shim/component.json
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "es6-shim",
|
||||
"version": "0.35.3",
|
||||
"repo": "paulmillr/es6-shim",
|
||||
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
|
||||
"keywords": [
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"es6",
|
||||
"shim",
|
||||
"promise",
|
||||
"promises",
|
||||
"setPrototypeOf",
|
||||
"map",
|
||||
"set",
|
||||
"__proto__"
|
||||
],
|
||||
"main": "es6-shim.js",
|
||||
"scripts": ["es6-shim.js"],
|
||||
"dependencies": {},
|
||||
"development": {}
|
||||
}
|
||||
|
170
node_modules/es6-shim/es6-sham.js
generated
vendored
Normal file
170
node_modules/es6-shim/es6-sham.js
generated
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
/*!
|
||||
* https://github.com/paulmillr/es6-shim
|
||||
* @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com)
|
||||
* and contributors, MIT License
|
||||
* es6-sham: v0.35.1
|
||||
* see https://github.com/paulmillr/es6-shim/blob/0.35.1/LICENSE
|
||||
* Details and documentation:
|
||||
* https://github.com/paulmillr/es6-shim/
|
||||
*/
|
||||
|
||||
// UMD (Universal Module Definition)
|
||||
// see https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
(function (root, factory) {
|
||||
/*global define, exports, module */
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.returnExports = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
'use strict';
|
||||
|
||||
/*jshint evil: true */
|
||||
/* eslint-disable no-new-func */
|
||||
var getGlobal = new Function('return this;');
|
||||
/* eslint-enable no-new-func */
|
||||
/*jshint evil: false */
|
||||
|
||||
var globals = getGlobal();
|
||||
var Object = globals.Object;
|
||||
var _call = Function.call.bind(Function.call);
|
||||
var functionToString = Function.toString;
|
||||
var _strMatch = String.prototype.match;
|
||||
|
||||
var throwsError = function (func) {
|
||||
try {
|
||||
func();
|
||||
return false;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var arePropertyDescriptorsSupported = function () {
|
||||
// if Object.defineProperty exists but throws, it's IE 8
|
||||
return !throwsError(function () {
|
||||
Object.defineProperty({}, 'x', { get: function () {} });
|
||||
});
|
||||
};
|
||||
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
|
||||
|
||||
// NOTE: This versions needs object ownership
|
||||
// because every promoted object needs to be reassigned
|
||||
// otherwise uncompatible browsers cannot work as expected
|
||||
//
|
||||
// NOTE: This might need es5-shim or polyfills upfront
|
||||
// because it's based on ES5 API.
|
||||
// (probably just an IE <= 8 problem)
|
||||
//
|
||||
// NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
|
||||
(function () {
|
||||
if (Object.setPrototypeOf) { return; }
|
||||
|
||||
/*jshint proto: true */
|
||||
// @author Andrea Giammarchi - @WebReflection
|
||||
|
||||
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
||||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||
var create = Object.create;
|
||||
var defineProperty = Object.defineProperty;
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
var objProto = Object.prototype;
|
||||
|
||||
var copyDescriptors = function (target, source) {
|
||||
// define into target descriptors from source
|
||||
getOwnPropertyNames(source).forEach(function (key) {
|
||||
defineProperty(
|
||||
target,
|
||||
key,
|
||||
getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
return target;
|
||||
};
|
||||
// used as fallback when no promotion is possible
|
||||
var createAndCopy = function (origin, proto) {
|
||||
return copyDescriptors(create(proto), origin);
|
||||
};
|
||||
var set, setPrototypeOf;
|
||||
try {
|
||||
// this might fail for various reasons
|
||||
// ignore if Chrome cought it at runtime
|
||||
set = getOwnPropertyDescriptor(objProto, '__proto__').set;
|
||||
set.call({}, null);
|
||||
// setter not poisoned, it can promote
|
||||
// Firefox, Chrome
|
||||
setPrototypeOf = function (origin, proto) {
|
||||
set.call(origin, proto);
|
||||
return origin;
|
||||
};
|
||||
} catch (e) {
|
||||
// do one or more feature detections
|
||||
set = { __proto__: null };
|
||||
// if proto does not work, needs to fallback
|
||||
// some Opera, Rhino, ducktape
|
||||
if (set instanceof Object) {
|
||||
setPrototypeOf = createAndCopy;
|
||||
} else {
|
||||
// verify if null objects are buggy
|
||||
/* eslint-disable no-proto */
|
||||
set.__proto__ = objProto;
|
||||
/* eslint-enable no-proto */
|
||||
// if null objects are buggy
|
||||
// nodejs 0.8 to 0.10
|
||||
if (set instanceof Object) {
|
||||
setPrototypeOf = function (origin, proto) {
|
||||
// use such bug to promote
|
||||
/* eslint-disable no-proto */
|
||||
origin.__proto__ = proto;
|
||||
/* eslint-enable no-proto */
|
||||
return origin;
|
||||
};
|
||||
} else {
|
||||
// try to use proto or fallback
|
||||
// Safari, old Firefox, many others
|
||||
setPrototypeOf = function (origin, proto) {
|
||||
// if proto is not null
|
||||
if (getPrototypeOf(origin)) {
|
||||
// use __proto__ to promote
|
||||
/* eslint-disable no-proto */
|
||||
origin.__proto__ = proto;
|
||||
/* eslint-enable no-proto */
|
||||
return origin;
|
||||
} else {
|
||||
// otherwise unable to promote: fallback
|
||||
return createAndCopy(origin, proto);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.setPrototypeOf = setPrototypeOf;
|
||||
}());
|
||||
|
||||
if (supportsDescriptors && function foo() {}.name !== 'foo') {
|
||||
/* eslint no-extend-native: 1 */
|
||||
Object.defineProperty(Function.prototype, 'name', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
var str = _call(functionToString, this);
|
||||
var match = _call(_strMatch, str, /\s*function\s+([^(\s]*)\s*/);
|
||||
var name = match && match[1];
|
||||
Object.defineProperty(this, 'name', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: name
|
||||
});
|
||||
return name;
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
1
node_modules/es6-shim/es6-sham.map
generated
vendored
Normal file
1
node_modules/es6-shim/es6-sham.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","_call","call","bind","functionToString","toString","_strMatch","String","prototype","match","throwsError","func","e","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","getPrototypeOf","objProto","copyDescriptors","target","source","forEach","key","createAndCopy","origin","proto","set","__proto__","foo","name","configurable","enumerable","str","writable","value"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAIA,IAAIC,GAAY,GAAIC,UAAS,eAI7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,MACrB,IAAIC,GAAQH,SAASI,KAAKC,KAAKL,SAASI,KACxC,IAAIE,GAAmBN,SAASO,QAChC,IAAIC,GAAYC,OAAOC,UAAUC,KAEjC,IAAIC,GAAc,SAAUC,GAC1B,IACEA,GACA,OAAO,OACP,MAAOC,GACP,MAAO,OAGX,IAAIC,GAAkC,WAEpC,OAAQH,EAAY,WAClBV,EAAOc,kBAAmB,KAAOC,IAAK,iBAG1C,IAAIC,KAAwBhB,EAAOc,gBAAkBD,KAWpD,WACC,GAAIb,EAAOiB,eAAgB,CAAE,OAK7B,GAAIC,GAAsBlB,EAAOkB,mBACjC,IAAIC,GAA2BnB,EAAOmB,wBACtC,IAAIC,GAASpB,EAAOoB,MACpB,IAAIN,GAAiBd,EAAOc,cAC5B,IAAIO,GAAiBrB,EAAOqB,cAC5B,IAAIC,GAAWtB,EAAOQ,SAEtB,IAAIe,GAAkB,SAAUC,EAAQC,GAEtCP,EAAoBO,GAAQC,QAAQ,SAAUC,GAC5Cb,EACEU,EACAG,EACAR,EAAyBM,EAAQE,KAGrC,OAAOH,GAGT,IAAII,GAAgB,SAAUC,EAAQC,GACpC,MAAOP,GAAgBH,EAAOU,GAAQD,GAExC,IAAIE,GAAKd,CACT,KAGEc,EAAMZ,EAAyBG,EAAU,aAAaS,GACtDA,GAAI7B,QAAS,KAGbe,GAAiB,SAAUY,EAAQC,GACjCC,EAAI7B,KAAK2B,EAAQC,EACjB,OAAOD,IAET,MAAOjB,GAEPmB,GAAQC,UAAW,KAGnB,IAAID,YAAe/B,GAAQ,CACzBiB,EAAiBW,MACZ,CAGLG,EAAIC,UAAYV,CAIhB,IAAIS,YAAe/B,GAAQ,CACzBiB,EAAiB,SAAUY,EAAQC,GAGjCD,EAAOG,UAAYF,CAEnB,OAAOD,QAEJ,CAGLZ,EAAiB,SAAUY,EAAQC,GAEjC,GAAIT,EAAeQ,GAAS,CAG1BA,EAAOG,UAAYF,CAEnB,OAAOD,OACF,CAEL,MAAOD,GAAcC,EAAQC,OAMvC9B,EAAOiB,eAAiBA,KAG1B,IAAID,GAAuB,QAASiB,SAASC,OAAS,MAAO,CAE3DlC,EAAOc,eAAehB,SAASU,UAAW,QACxC2B,aAAc,KACdC,WAAY,MACZrB,IAAK,WACH,GAAIsB,GAAMpC,EAAMG,EAAkBR,KAClC,IAAIa,GAAQR,EAAMK,EAAW+B,EAAK,6BAClC,IAAIH,GAAOzB,GAASA,EAAM,EAC1BT,GAAOc,eAAelB,KAAM,QAC1BuC,aAAc,KACdC,WAAY,MACZE,SAAU,MACVC,MAAOL,GAET,OAAOA"}
|
11
node_modules/es6-shim/es6-sham.min.js
generated
vendored
Normal file
11
node_modules/es6-shim/es6-sham.min.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* https://github.com/paulmillr/es6-shim
|
||||
* @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com)
|
||||
* and contributors, MIT License
|
||||
* es6-sham: v0.35.1
|
||||
* see https://github.com/paulmillr/es6-shim/blob/0.35.1/LICENSE
|
||||
* Details and documentation:
|
||||
* https://github.com/paulmillr/es6-shim/
|
||||
*/
|
||||
(function(t,e){if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){"use strict";var t=new Function("return this;");var e=t();var r=e.Object;var n=Function.call.bind(Function.call);var o=Function.toString;var i=String.prototype.match;var f=function(t){try{t();return false}catch(t){return true}};var a=function(){return!f(function(){r.defineProperty({},"x",{get:function(){}})})};var u=!!r.defineProperty&&a();(function(){if(r.setPrototypeOf){return}var t=r.getOwnPropertyNames;var e=r.getOwnPropertyDescriptor;var n=r.create;var o=r.defineProperty;var i=r.getPrototypeOf;var f=r.prototype;var a=function(r,n){t(n).forEach(function(t){o(r,t,e(n,t))});return r};var u=function(t,e){return a(n(e),t)};var c,s;try{c=e(f,"__proto__").set;c.call({},null);s=function(t,e){c.call(t,e);return t}}catch(t){c={__proto__:null};if(c instanceof r){s=u}else{c.__proto__=f;if(c instanceof r){s=function(t,e){t.__proto__=e;return t}}else{s=function(t,e){if(i(t)){t.__proto__=e;return t}else{return u(t,e)}}}}}r.setPrototypeOf=s})();if(u&&function foo(){}.name!=="foo"){r.defineProperty(Function.prototype,"name",{configurable:true,enumerable:false,get:function(){var t=n(o,this);var e=n(i,t,/\s*function\s+([^(\s]*)\s*/);var f=e&&e[1];r.defineProperty(this,"name",{configurable:true,enumerable:false,writable:false,value:f});return f}})}});
|
||||
//# sourceMappingURL=es6-sham.map
|
3842
node_modules/es6-shim/es6-shim.js
generated
vendored
Normal file
3842
node_modules/es6-shim/es6-shim.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/es6-shim/es6-shim.map
generated
vendored
Normal file
1
node_modules/es6-shim/es6-shim.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/es6-shim/es6-shim.min.js
generated
vendored
Normal file
12
node_modules/es6-shim/es6-shim.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
11
node_modules/es6-shim/full.html
generated
vendored
Normal file
11
node_modules/es6-shim/full.html
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="./node_modules/es5-shim/es5-shim.js"></script>
|
||||
<script src="./es6-shim.js"></script>
|
||||
<script>
|
||||
Promise.resolve(2);
|
||||
try { Promise(); } catch (e) { alert(e); }
|
||||
try { new Promise(); } catch (e) { alert(e); }
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
11
node_modules/es6-shim/min.html
generated
vendored
Normal file
11
node_modules/es6-shim/min.html
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="./node_modules/es5-shim/es5-shim.js"></script>
|
||||
<script src="./es6-shim.min.js"></script>
|
||||
<script>
|
||||
Promise.resolve(2);
|
||||
Promise();
|
||||
new Promise();
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
148
node_modules/es6-shim/package.json
generated
vendored
Normal file
148
node_modules/es6-shim/package.json
generated
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"es6-shim@^0.35.0",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton"
|
||||
]
|
||||
],
|
||||
"_from": "es6-shim@>=0.35.0-0 <0.36.0-0",
|
||||
"_id": "es6-shim@0.35.3",
|
||||
"_inCache": true,
|
||||
"_location": "/es6-shim",
|
||||
"_nodeVersion": "7.4.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/es6-shim-0.35.3.tgz_1485240587767_0.6348716060165316"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "ljharb@gmail.com",
|
||||
"name": "ljharb"
|
||||
},
|
||||
"_npmVersion": "4.0.5",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "es6-shim",
|
||||
"raw": "es6-shim@^0.35.0",
|
||||
"rawSpec": "^0.35.0",
|
||||
"scope": null,
|
||||
"spec": ">=0.35.0-0 <0.36.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.3.tgz",
|
||||
"_shasum": "9bfb7363feffff87a6cdb6cd93e405ec3c4b6f26",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "es6-shim@^0.35.0",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton",
|
||||
"author": {
|
||||
"name": "Paul Miller",
|
||||
"url": "http://paulmillr.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/paulmillr/es6-shim/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^10.0.0",
|
||||
"chai": "^3.5.0",
|
||||
"es5-shim": "^4.5.9",
|
||||
"eslint": "^3.14.0",
|
||||
"evalmd": "^0.0.17",
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-contrib-connect": "^1.0.2",
|
||||
"grunt-contrib-watch": "^1.0.0",
|
||||
"grunt-saucelabs": "^8.6.3",
|
||||
"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.7.3"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "9bfb7363feffff87a6cdb6cd93e405ec3c4b6f26",
|
||||
"tarball": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.3.tgz"
|
||||
},
|
||||
"gitHead": "129819173958a0da2b487e219425baf0ca6d1a99",
|
||||
"homepage": "https://github.com/paulmillr/es6-shim/",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"__proto__",
|
||||
"ecmascript",
|
||||
"es6",
|
||||
"harmony",
|
||||
"map",
|
||||
"promise",
|
||||
"promises",
|
||||
"set",
|
||||
"setPrototypeOf",
|
||||
"shim"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "es6-shim",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "paulmillr",
|
||||
"email": "paul@paulmillr.com"
|
||||
},
|
||||
{
|
||||
"name": "ljharb",
|
||||
"email": "ljharb@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "es6-shim",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/paulmillr/es6-shim.git"
|
||||
},
|
||||
"scripts": {
|
||||
"eslint": "npm run --silent eslint:shim && npm run --silent eslint:sham",
|
||||
"eslint:sham": "eslint es6-sham.js test-sham/*.js",
|
||||
"eslint:shim": "eslint es6-shim.js test/*.js test/*/*.js",
|
||||
"jscs": "npm run --silent jscs:shim && npm run --silent jscs:sham",
|
||||
"jscs:sham": "jscs es6-sham.js test-sham/*.js",
|
||||
"jscs:shim": "jscs es6-shim.js test/*.js test/*/*.js",
|
||||
"jshint": "npm run --silent jshint:shim && npm run --silent jshint:sham",
|
||||
"jshint:sham": "jshint es6-sham.js test-sham/*.js",
|
||||
"jshint:shim": "jshint es6-shim.js test/*.js test/*/*.js",
|
||||
"lint": "npm run --silent lint:shim && npm run --silent lint:sham",
|
||||
"lint:sham": "npm run --silent jshint:sham && npm run --silent jscs:sham && npm run --silent eslint:sham",
|
||||
"lint:shim": "npm run --silent jshint:shim && npm run --silent jscs:shim && npm run --silent eslint:shim",
|
||||
"minify": "npm run --silent minify:shim && npm run --silent minify:sham",
|
||||
"minify:sham": "uglifyjs es6-sham.js --keep-fnames --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js",
|
||||
"minify:shim": "uglifyjs es6-shim.js --keep-fnames --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js",
|
||||
"pretest": "npm run --silent lint && evalmd *.md",
|
||||
"sauce": "npm run --silent sauce-connect && grunt sauce",
|
||||
"sauce-connect": "curl -L https://gist.githubusercontent.com/henrikhodne/9322897/raw/sauce-connect.sh | bash && export TRAVIS_SAUCE_CONNECT=true",
|
||||
"test": "npm run --silent tests-only",
|
||||
"test:native": "NO_ES6_SHIM=1 npm run --silent tests-only",
|
||||
"test:sham": "mocha test-sham/*.js",
|
||||
"test:shim": "mocha test/*.js test/*/*.js",
|
||||
"tests-only": "npm run --silent test:shim && npm run --silent test:sham"
|
||||
},
|
||||
"testling": {
|
||||
"browsers": [
|
||||
"android-browser/4.2..latest",
|
||||
"chrome/20.0..latest",
|
||||
"chrome/4.0..10.0",
|
||||
"chrome/canary",
|
||||
"firefox/10.0",
|
||||
"firefox/15.0..latest",
|
||||
"firefox/3.0..6.0",
|
||||
"firefox/nightly",
|
||||
"iexplore/6.0..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"opera/10.0..latest",
|
||||
"opera/next",
|
||||
"safari/4.0..latest"
|
||||
],
|
||||
"html": "testling.html"
|
||||
},
|
||||
"version": "0.35.3"
|
||||
}
|
8
node_modules/es6-shim/test-sham/.eslintrc
generated
vendored
Normal file
8
node_modules/es6-shim/test-sham/.eslintrc
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"globals": {
|
||||
"expect": false
|
||||
}
|
||||
}
|
54
node_modules/es6-shim/test-sham/function.js
generated
vendored
Normal file
54
node_modules/es6-shim/test-sham/function.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
var identity = function (x) { return x; };
|
||||
|
||||
describe('Function', function () {
|
||||
describe('#name', function () {
|
||||
it('returns the name for named functions', function () {
|
||||
var foo = function bar() {};
|
||||
expect(foo.name).to.equal('bar');
|
||||
|
||||
// pre-ES6, this property is nonconfigurable.
|
||||
var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(foo, 'name').configurable : false;
|
||||
|
||||
expect(foo).to.have.ownPropertyDescriptor('name', {
|
||||
configurable: !!configurable,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: 'bar'
|
||||
});
|
||||
});
|
||||
|
||||
it('returns empty string for anonymous functions', function () {
|
||||
var anon = identity(function () {});
|
||||
expect(anon.name).to.equal('');
|
||||
|
||||
// pre-ES6, this property is nonconfigurable.
|
||||
var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(anon, 'name').configurable : false;
|
||||
|
||||
expect(anon).to.have.ownPropertyDescriptor('name', {
|
||||
configurable: !!configurable,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: ''
|
||||
});
|
||||
});
|
||||
|
||||
it('returns "anomymous" for Function functions', function () {
|
||||
/* eslint no-new-func: 1 */
|
||||
/* jshint evil: true */
|
||||
var func = identity(Function(''));
|
||||
/* jshint evil: false */
|
||||
expect(typeof func.name).to.equal('string');
|
||||
expect(func.name === 'anonymous' || func.name === '').to.equal(true);
|
||||
|
||||
// pre-ES6, this property is nonconfigurable.
|
||||
var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(func, 'name').configurable : false;
|
||||
|
||||
expect(func).to.have.ownPropertyDescriptor('name', {
|
||||
configurable: !!configurable,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: func.name
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
23
node_modules/es6-shim/test-sham/index.html
generated
vendored
Normal file
23
node_modules/es6-shim/test-sham/index.html
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>es6-shim tests</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
<script src="../node_modules/es5-shim/es5-shim.js"></script>
|
||||
<script src="../node_modules/es5-shim/es5-sham.js"></script>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<!-- note that chai uses Object.create() so needs es5-sham to be loaded -->
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="../es6-sham.js"></script>
|
||||
<script src="../test/browser-setup.js"></script>
|
||||
<script src="set-prototype-of.js"></script>
|
||||
<script src="function.js"></script>
|
||||
<script src="../test/browser-onload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
26
node_modules/es6-shim/test-sham/set-prototype-of.js
generated
vendored
Normal file
26
node_modules/es6-shim/test-sham/set-prototype-of.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/* global expect, describe, it */
|
||||
|
||||
describe('Object.setPrototypeOf(o, p)', function () {
|
||||
'use strict';
|
||||
|
||||
it('changes prototype to regular objects', function () {
|
||||
var obj = { a: 123 };
|
||||
expect(obj).to.be.an.instanceOf(Object);
|
||||
// sham requires assignment to work cross browser
|
||||
obj = Object.setPrototypeOf(obj, null);
|
||||
expect(obj).not.to.be.an.instanceOf(Object);
|
||||
expect(obj.a).to.equal(123);
|
||||
});
|
||||
|
||||
it('changes prototype to null objects', function () {
|
||||
var obj = Object.create(null);
|
||||
obj.a = 456;
|
||||
expect(obj).not.to.be.an.instanceOf(Object);
|
||||
expect(obj.a).to.equal(456);
|
||||
// sham requires assignment to work cross browser
|
||||
obj = Object.setPrototypeOf(obj, {});
|
||||
expect(obj).to.be.an.instanceOf(Object);
|
||||
expect(obj.a).to.equal(456);
|
||||
});
|
||||
|
||||
});
|
19
node_modules/es6-shim/test/.eslintrc
generated
vendored
Normal file
19
node_modules/es6-shim/test/.eslintrc
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"rules": {
|
||||
"array-callback-return": 0,
|
||||
"func-name-matching": 0,
|
||||
"max-statements-per-line": [2, { "max": 2 }],
|
||||
"no-restricted-properties": 1,
|
||||
"symbol-description": 0,
|
||||
"prefer-promise-reject-errors": 0,
|
||||
},
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"globals": {
|
||||
"Symbol": false,
|
||||
"Promise": false,
|
||||
"expect": false,
|
||||
"assert": false
|
||||
}
|
||||
}
|
1037
node_modules/es6-shim/test/array.js
generated
vendored
Normal file
1037
node_modules/es6-shim/test/array.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
45
node_modules/es6-shim/test/browser-onload.js
generated
vendored
Normal file
45
node_modules/es6-shim/test/browser-onload.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/* global window, mocha */
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.completedTests = 0;
|
||||
window.sawFail = false;
|
||||
window.onload = function () {
|
||||
window.testsPassed = null;
|
||||
var handleResults = function (runner) {
|
||||
var failedTests = [];
|
||||
if (runner.stats.end) {
|
||||
window.testsPassed = runner.stats.failures === 0;
|
||||
}
|
||||
runner.on('pass', function () {
|
||||
window.completedTests += 1;
|
||||
});
|
||||
runner.on('fail', function (test, err) {
|
||||
window.sawFail = true;
|
||||
var flattenTitles = function (testToFlatten) {
|
||||
var titles = [];
|
||||
var currentTest = testToFlatten;
|
||||
while (currentTest.parent.title) {
|
||||
titles.push(currentTest.parent.title);
|
||||
currentTest = currentTest.parent;
|
||||
}
|
||||
return titles.reverse();
|
||||
};
|
||||
failedTests.push({
|
||||
name: test.title,
|
||||
result: false,
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
titles: flattenTitles(test)
|
||||
});
|
||||
});
|
||||
runner.on('end', function () {
|
||||
window.testsPassed = !window.sawFail;
|
||||
// for sauce
|
||||
window.mochaResults = runner.stats;
|
||||
window.mochaResults.reports = failedTests;
|
||||
});
|
||||
return runner;
|
||||
};
|
||||
handleResults(mocha.run());
|
||||
};
|
||||
}
|
11
node_modules/es6-shim/test/browser-setup.js
generated
vendored
Normal file
11
node_modules/es6-shim/test/browser-setup.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/* global window, chai, mocha */
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
chai.config.includeStack = true;
|
||||
window.expect = chai.expect;
|
||||
window.assert = chai.assert;
|
||||
mocha.setup('bdd');
|
||||
window.require = function () {
|
||||
return window;
|
||||
};
|
||||
}
|
5
node_modules/es6-shim/test/date.js
generated
vendored
Normal file
5
node_modules/es6-shim/test/date.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
describe('Date', function () {
|
||||
it('when invalid, dates should toString to "Invalid Date"', function () {
|
||||
expect(String(new Date(NaN))).to.equal('Invalid Date');
|
||||
});
|
||||
});
|
42
node_modules/es6-shim/test/index.html
generated
vendored
Normal file
42
node_modules/es6-shim/test/index.html
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>es6-shim tests</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
<script src="../node_modules/es5-shim/es5-shim.js"></script>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="../es6-shim.js"></script>
|
||||
<script src="browser-setup.js"></script>
|
||||
<script src="array.js"></script>
|
||||
<script src="map.js"></script>
|
||||
<script src="set.js"></script>
|
||||
<script src="json.js"></script>
|
||||
<script src="math.js"></script>
|
||||
<script src="number.js"></script>
|
||||
<script src="object.js"></script>
|
||||
<script src="promise.js"></script>
|
||||
<script src="regexp.js"></script>
|
||||
<script src="string.js"></script>
|
||||
<script src="reflect.js"></script>
|
||||
<script src="worker-test.js"></script>
|
||||
<script src="promise/all.js"></script>
|
||||
<script src="promise/evil-promises.js"></script>
|
||||
<!--
|
||||
<script src="promise/promises-aplus.js"></script>
|
||||
-->
|
||||
<script src="../node_modules/promises-es6-tests/bundle/promises-es6-tests.js"></script>
|
||||
<script src="promise/race.js"></script>
|
||||
<script src="promise/reject.js"></script>
|
||||
<script src="promise/resolve.js"></script>
|
||||
<script src="promise/simple.js"></script>
|
||||
<script src="promise/subclass.js"></script>
|
||||
<script src="browser-onload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
77
node_modules/es6-shim/test/json.js
generated
vendored
Normal file
77
node_modules/es6-shim/test/json.js
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
describe('JSON', function () {
|
||||
var functionsHaveNames = (function foo() {}).name === 'foo';
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
|
||||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
|
||||
var ifSymbolsIt = hasSymbols ? it : xit;
|
||||
var ifSymbolsDescribe = hasSymbols ? describe : xit;
|
||||
|
||||
describe('.stringify()', function () {
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(JSON.stringify.name).to.equal('stringify');
|
||||
});
|
||||
|
||||
ifSymbolsIt('serializes a Symbol to undefined', function () {
|
||||
expect(JSON.stringify(Symbol())).to.equal(undefined);
|
||||
});
|
||||
|
||||
ifSymbolsIt('serializes a Symbol object to {}', function () {
|
||||
expect(function stringifyObjectSymbol() { JSON.stringify(Object(Symbol())); }).not.to['throw']();
|
||||
expect(JSON.stringify(Object(Symbol()))).to.equal('{}');
|
||||
});
|
||||
|
||||
ifSymbolsIt('serializes Symbols in an Array to null', function () {
|
||||
expect(JSON.stringify([Symbol('foo')])).to.equal('[null]');
|
||||
});
|
||||
|
||||
ifSymbolsIt('serializes Symbol objects in an Array to {}', function () {
|
||||
expect(function stringifyObjectSymbolInArray() { JSON.stringify([Object(Symbol('foo'))]); }).not.to['throw']();
|
||||
expect(JSON.stringify([Object(Symbol('foo'))])).to.equal('[{}]');
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('skips symbol properties and values in an object', function () {
|
||||
var enumSym = Symbol('enumerable');
|
||||
var nonenum = Symbol('non-enumerable');
|
||||
var createObject = function () {
|
||||
var obj = { a: 1 };
|
||||
obj[enumSym] = true;
|
||||
obj.sym = enumSym;
|
||||
Object.defineProperty(obj, nonenum, { enumerable: false, value: true });
|
||||
expect(Object.getOwnPropertySymbols(obj)).to.eql([enumSym, nonenum]);
|
||||
return obj;
|
||||
};
|
||||
|
||||
it('works with no replacer', function () {
|
||||
var obj = createObject();
|
||||
expect(JSON.stringify(obj)).to.equal('{"a":1}');
|
||||
expect(JSON.stringify(obj, null, '|')).to.equal('{\n|"a": 1\n}');
|
||||
});
|
||||
|
||||
it('works with a replacer function', function () {
|
||||
var tuples = [];
|
||||
var replacer = function (key, value) {
|
||||
tuples.push([this, key, value]);
|
||||
return value;
|
||||
};
|
||||
var obj = createObject();
|
||||
expect(JSON.stringify(obj, replacer, '|')).to.equal('{\n|"a": 1\n}'); // populate `tuples` array
|
||||
expect(tuples).to.eql([
|
||||
[{ '': obj }, '', obj],
|
||||
[obj, 'a', 1],
|
||||
[obj, 'sym', enumSym]
|
||||
]);
|
||||
});
|
||||
|
||||
it('works with a replacer array', function () {
|
||||
var obj = createObject();
|
||||
obj.foo = 'bar';
|
||||
obj[Symbol.prototype.toString.call(enumSym)] = 'tricksy';
|
||||
expect(JSON.stringify(obj, ['a', enumSym])).to.equal('{"a":1}');
|
||||
expect(JSON.stringify(obj, ['a', enumSym], '|')).to.equal('{\n|"a": 1\n}');
|
||||
});
|
||||
|
||||
it('ignores a non-array non-callable replacer object', function () {
|
||||
expect(JSON.stringify('z', { test: null })).to.equal('"z"');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
603
node_modules/es6-shim/test/map.js
generated
vendored
Normal file
603
node_modules/es6-shim/test/map.js
generated
vendored
Normal file
@ -0,0 +1,603 @@
|
||||
// Big thanks to V8 folks for test ideas.
|
||||
// v8/test/mjsunit/harmony/collections.js
|
||||
|
||||
var Assertion = expect().constructor;
|
||||
Assertion.addMethod('theSameSet', function (otherArray) {
|
||||
var array = this._obj;
|
||||
|
||||
expect(Array.isArray(array)).to.equal(true);
|
||||
expect(Array.isArray(otherArray)).to.equal(true);
|
||||
|
||||
var diff = array.filter(function (value) {
|
||||
return otherArray.every(function (otherValue) {
|
||||
var areBothNaN = typeof value === 'number' && typeof otherValue === 'number' && value !== value && otherValue !== otherValue;
|
||||
return !areBothNaN && value !== otherValue;
|
||||
});
|
||||
});
|
||||
|
||||
this.assert(
|
||||
diff.length === 0,
|
||||
'expected #{this} to be equal to #{exp} (as sets, i.e. no order)',
|
||||
array,
|
||||
otherArray
|
||||
);
|
||||
});
|
||||
|
||||
Assertion.addMethod('entries', function (expected) {
|
||||
var collection = this._obj;
|
||||
|
||||
expect(Array.isArray(expected)).to.equal(true);
|
||||
var expectedEntries = expected.slice();
|
||||
|
||||
var iterator = collection.entries();
|
||||
var result;
|
||||
do {
|
||||
result = iterator.next();
|
||||
expect(result.value).to.be.eql(expectedEntries.shift());
|
||||
} while (!result.done);
|
||||
});
|
||||
|
||||
describe('Map', function () {
|
||||
var functionsHaveNames = (function foo() {}).name === 'foo';
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
|
||||
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
|
||||
|
||||
var range = function range(from, to) {
|
||||
var result = [];
|
||||
for (var value = from; value < to; value++) {
|
||||
result.push(value);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype');
|
||||
var expectNotEnumerable = function (object) {
|
||||
if (prototypePropIsEnumerable && typeof object === 'function') {
|
||||
expect(Object.keys(object)).to.eql(['prototype']);
|
||||
} else {
|
||||
expect(Object.keys(object)).to.eql([]);
|
||||
}
|
||||
};
|
||||
|
||||
var Sym = typeof Symbol === 'undefined' ? {} : Symbol;
|
||||
var isSymbol = function (sym) {
|
||||
return typeof Sym === 'function' && typeof sym === 'symbol';
|
||||
};
|
||||
var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit;
|
||||
|
||||
var testMapping = function (map, key, value) {
|
||||
expect(map.has(key)).to.equal(false);
|
||||
expect(map.get(key)).to.equal(undefined);
|
||||
expect(map.set(key, value)).to.equal(map);
|
||||
expect(map.get(key)).to.equal(value);
|
||||
expect(map.has(key)).to.equal(true);
|
||||
};
|
||||
|
||||
if (typeof Map === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(typeof Map).to.equal('function');
|
||||
});
|
||||
}
|
||||
|
||||
var map;
|
||||
beforeEach(function () {
|
||||
map = new Map();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
map = null;
|
||||
});
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.Map).to.equal(Map);
|
||||
});
|
||||
|
||||
it('should exist in global namespace', function () {
|
||||
expect(typeof Map).to.equal('function');
|
||||
});
|
||||
|
||||
it('should have the right arity', function () {
|
||||
expect(Map).to.have.property('length', 0);
|
||||
});
|
||||
|
||||
it('should has valid getter and setter calls', function () {
|
||||
['get', 'set', 'has', 'delete'].forEach(function (method) {
|
||||
expect(function () {
|
||||
map[method]({});
|
||||
}).to.not['throw']();
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept an iterable as argument', function () {
|
||||
testMapping(map, 'a', 'b');
|
||||
testMapping(map, 'c', 'd');
|
||||
var map2;
|
||||
expect(function () { map2 = new Map(map); }).not.to['throw'](Error);
|
||||
expect(map2).to.be.an.instanceOf(Map);
|
||||
expect(map2.has('a')).to.equal(true);
|
||||
expect(map2.has('c')).to.equal(true);
|
||||
expect(map2).to.have.entries([['a', 'b'], ['c', 'd']]);
|
||||
});
|
||||
|
||||
it('should throw with iterables that return primitives', function () {
|
||||
expect(function () { return new Map('123'); }).to['throw'](TypeError);
|
||||
expect(function () { return new Map([1, 2, 3]); }).to['throw'](TypeError);
|
||||
expect(function () { return new Map(['1', '2', '3']); }).to['throw'](TypeError);
|
||||
expect(function () { return new Map([true]); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('should not be callable without "new"', function () {
|
||||
expect(Map).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('should be subclassable', function () {
|
||||
if (!Object.setPrototypeOf) { return; } // skip test if on IE < 11
|
||||
var MyMap = function MyMap() {
|
||||
var testMap = new Map([['a', 'b']]);
|
||||
Object.setPrototypeOf(testMap, MyMap.prototype);
|
||||
return testMap;
|
||||
};
|
||||
Object.setPrototypeOf(MyMap, Map);
|
||||
MyMap.prototype = Object.create(Map.prototype, {
|
||||
constructor: { value: MyMap }
|
||||
});
|
||||
|
||||
var myMap = new MyMap();
|
||||
testMapping(myMap, 'c', 'd');
|
||||
expect(myMap).to.have.entries([['a', 'b'], ['c', 'd']]);
|
||||
});
|
||||
|
||||
it('uses SameValueZero even on a Map of size > 4', function () {
|
||||
// Chrome 38-42, node 0.11/0.12, iojs 1/2 have a bug when the Map has a size > 4
|
||||
var firstFour = [[1, 0], [2, 0], [3, 0], [4, 0]];
|
||||
var fourMap = new Map(firstFour);
|
||||
expect(fourMap.size).to.equal(4);
|
||||
expect(fourMap.has(-0)).to.equal(false);
|
||||
expect(fourMap.has(0)).to.equal(false);
|
||||
|
||||
fourMap.set(-0, fourMap);
|
||||
|
||||
expect(fourMap.has(0)).to.equal(true);
|
||||
expect(fourMap.has(-0)).to.equal(true);
|
||||
});
|
||||
|
||||
it('treats positive and negative zero the same', function () {
|
||||
var value1 = {};
|
||||
var value2 = {};
|
||||
testMapping(map, +0, value1);
|
||||
expect(map.has(-0)).to.equal(true);
|
||||
expect(map.get(-0)).to.equal(value1);
|
||||
expect(map.set(-0, value2)).to.equal(map);
|
||||
expect(map.get(-0)).to.equal(value2);
|
||||
expect(map.get(+0)).to.equal(value2);
|
||||
});
|
||||
|
||||
it('should map values correctly', function () {
|
||||
// Run this test twice, one with the "fast" implementation (which only
|
||||
// allows string and numeric keys) and once with the "slow" impl.
|
||||
[true, false].forEach(function (slowkeys) {
|
||||
map = new Map();
|
||||
|
||||
range(1, 20).forEach(function (number) {
|
||||
if (slowkeys) { testMapping(map, number, {}); }
|
||||
testMapping(map, number / 100, {});
|
||||
testMapping(map, 'key-' + number, {});
|
||||
testMapping(map, String(number), {});
|
||||
if (slowkeys) { testMapping(map, Object(String(number)), {}); }
|
||||
});
|
||||
|
||||
var testkeys = [Infinity, -Infinity, NaN];
|
||||
if (slowkeys) {
|
||||
testkeys.push(true, false, null, undefined);
|
||||
}
|
||||
testkeys.forEach(function (key) {
|
||||
testMapping(map, key, {});
|
||||
testMapping(map, String(key), {});
|
||||
});
|
||||
testMapping(map, '', {});
|
||||
|
||||
// verify that properties of Object don't peek through.
|
||||
[
|
||||
'hasOwnProperty',
|
||||
'constructor',
|
||||
'toString',
|
||||
'isPrototypeOf',
|
||||
'__proto__',
|
||||
'__parent__',
|
||||
'__count__'
|
||||
].forEach(function (key) {
|
||||
testMapping(map, key, {});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should map empty values correctly', function () {
|
||||
testMapping(map, {}, true);
|
||||
testMapping(map, null, true);
|
||||
testMapping(map, undefined, true);
|
||||
testMapping(map, '', true);
|
||||
testMapping(map, NaN, true);
|
||||
testMapping(map, 0, true);
|
||||
});
|
||||
|
||||
it('should has correct querying behavior', function () {
|
||||
var key = {};
|
||||
testMapping(map, key, 'to-be-present');
|
||||
expect(map.has(key)).to.equal(true);
|
||||
expect(map.has({})).to.equal(false);
|
||||
expect(map.set(key, void 0)).to.equal(map);
|
||||
expect(map.get(key)).to.equal(undefined);
|
||||
expect(map.has(key)).to.equal(true);
|
||||
expect(map.has({})).to.equal(false);
|
||||
});
|
||||
|
||||
it('should allow NaN values as keys', function () {
|
||||
expect(map.has(NaN)).to.equal(false);
|
||||
expect(map.has(NaN + 1)).to.equal(false);
|
||||
expect(map.has(23)).to.equal(false);
|
||||
expect(map.set(NaN, 'value')).to.equal(map);
|
||||
expect(map.has(NaN)).to.equal(true);
|
||||
expect(map.has(NaN + 1)).to.equal(true);
|
||||
expect(map.has(23)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should not have [[Enumerable]] props', function () {
|
||||
expectNotEnumerable(Map);
|
||||
expectNotEnumerable(Map.prototype);
|
||||
expectNotEnumerable(new Map());
|
||||
});
|
||||
|
||||
it('should not have an own constructor', function () {
|
||||
var m = new Map();
|
||||
expect(m).not.to.haveOwnPropertyDescriptor('constructor');
|
||||
expect(m.constructor).to.equal(Map);
|
||||
});
|
||||
|
||||
it('should allow common ecmascript idioms', function () {
|
||||
expect(map).to.be.an.instanceOf(Map);
|
||||
expect(typeof Map.prototype.get).to.equal('function');
|
||||
expect(typeof Map.prototype.set).to.equal('function');
|
||||
expect(typeof Map.prototype.has).to.equal('function');
|
||||
expect(typeof Map.prototype['delete']).to.equal('function');
|
||||
});
|
||||
|
||||
it('should have a unique constructor', function () {
|
||||
expect(Map.prototype).to.not.equal(Object.prototype);
|
||||
});
|
||||
|
||||
describe('#clear()', function () {
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Map.prototype.clear).to.have.property('name', 'clear');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Map.prototype).ownPropertyDescriptor('clear').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Map.prototype.clear).to.have.property('length', 0);
|
||||
});
|
||||
|
||||
it('should have #clear method', function () {
|
||||
expect(map.set(1, 2)).to.equal(map);
|
||||
expect(map.set(5, 2)).to.equal(map);
|
||||
expect(map.size).to.equal(2);
|
||||
expect(map.has(5)).to.equal(true);
|
||||
map.clear();
|
||||
expect(map.size).to.equal(0);
|
||||
expect(map.has(5)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#keys()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'keys')) {
|
||||
return it('exists', function () {
|
||||
expect(Map.prototype).to.have.property('keys');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Map.prototype.keys).to.have.property('name', 'keys');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Map.prototype).ownPropertyDescriptor('keys').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Map.prototype.keys).to.have.property('length', 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#values()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'values')) {
|
||||
return it('exists', function () {
|
||||
expect(Map.prototype).to.have.property('values');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Map.prototype.values).to.have.property('name', 'values');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Map.prototype).ownPropertyDescriptor('values').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Map.prototype.values).to.have.property('length', 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#entries()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'entries')) {
|
||||
return it('exists', function () {
|
||||
expect(Map.prototype).to.have.property('entries');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Map.prototype.entries).to.have.property('name', 'entries');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Map.prototype).ownPropertyDescriptor('entries').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Map.prototype.entries).to.have.property('length', 0);
|
||||
});
|
||||
|
||||
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$|^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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#size', function () {
|
||||
it('throws TypeError when accessed directly', function () {
|
||||
// see https://github.com/paulmillr/es6-shim/issues/176
|
||||
expect(function () { return Map.prototype.size; }).to['throw'](TypeError);
|
||||
expect(function () { return Map.prototype.size; }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('is an accessor function on the prototype', function () {
|
||||
expect(Map.prototype).ownPropertyDescriptor('size').to.have.property('get');
|
||||
expect(typeof Object.getOwnPropertyDescriptor(Map.prototype, 'size').get).to.equal('function');
|
||||
expect(new Map()).not.to.haveOwnPropertyDescriptor('size');
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false when deleting a nonexistent key', function () {
|
||||
expect(map.has('a')).to.equal(false);
|
||||
expect(map['delete']('a')).to.equal(false);
|
||||
});
|
||||
|
||||
it('should have keys, values and size props', function () {
|
||||
expect(map.set('a', 1)).to.equal(map);
|
||||
expect(map.set('b', 2)).to.equal(map);
|
||||
expect(map.set('c', 3)).to.equal(map);
|
||||
expect(typeof map.keys).to.equal('function');
|
||||
expect(typeof map.values).to.equal('function');
|
||||
expect(map.size).to.equal(3);
|
||||
expect(map['delete']('a')).to.equal(true);
|
||||
expect(map.size).to.equal(2);
|
||||
});
|
||||
|
||||
it('should have an iterator that works with Array.from', function () {
|
||||
expect(Array).to.have.property('from');
|
||||
|
||||
expect(map.set('a', 1)).to.equal(map);
|
||||
expect(map.set('b', NaN)).to.equal(map);
|
||||
expect(map.set('c', false)).to.equal(map);
|
||||
expect(Array.from(map)).to.eql([['a', 1], ['b', NaN], ['c', false]]);
|
||||
expect(Array.from(map.keys())).to.eql(['a', 'b', 'c']);
|
||||
expect(Array.from(map.values())).to.eql([1, NaN, false]);
|
||||
expect(map).to.have.entries(Array.from(map.entries()));
|
||||
});
|
||||
|
||||
ifSymbolIteratorIt('has the right default iteration function', function () {
|
||||
// fixed in Webkit https://bugs.webkit.org/show_bug.cgi?id=143838
|
||||
expect(Map.prototype).to.have.property(Sym.iterator, Map.prototype.entries);
|
||||
});
|
||||
|
||||
describe('#forEach', function () {
|
||||
var mapToIterate;
|
||||
|
||||
beforeEach(function () {
|
||||
mapToIterate = new Map();
|
||||
expect(mapToIterate.set('a', 1)).to.equal(mapToIterate);
|
||||
expect(mapToIterate.set('b', 2)).to.equal(mapToIterate);
|
||||
expect(mapToIterate.set('c', 3)).to.equal(mapToIterate);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
mapToIterate = null;
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Map.prototype.forEach).to.have.property('name', 'forEach');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Map.prototype).ownPropertyDescriptor('forEach').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Map.prototype.forEach).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be iterable via forEach', function () {
|
||||
var expectedMap = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
};
|
||||
var foundMap = {};
|
||||
mapToIterate.forEach(function (value, key, entireMap) {
|
||||
expect(entireMap).to.equal(mapToIterate);
|
||||
foundMap[key] = value;
|
||||
});
|
||||
expect(foundMap).to.eql(expectedMap);
|
||||
});
|
||||
|
||||
it('should iterate over empty keys', function () {
|
||||
var mapWithEmptyKeys = new Map();
|
||||
var expectedKeys = [{}, null, undefined, '', NaN, 0];
|
||||
expectedKeys.forEach(function (key) {
|
||||
expect(mapWithEmptyKeys.set(key, true)).to.equal(mapWithEmptyKeys);
|
||||
});
|
||||
var foundKeys = [];
|
||||
mapWithEmptyKeys.forEach(function (value, key, entireMap) {
|
||||
expect(entireMap.get(key)).to.equal(value);
|
||||
foundKeys.push(key);
|
||||
});
|
||||
expect(foundKeys).to.be.theSameSet(expectedKeys);
|
||||
});
|
||||
|
||||
it('should support the thisArg', function () {
|
||||
var context = function () {};
|
||||
mapToIterate.forEach(function () {
|
||||
expect(this).to.equal(context);
|
||||
}, context);
|
||||
});
|
||||
|
||||
it('should have a length of 1', function () {
|
||||
expect(Map.prototype.forEach.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('should not revisit modified keys', function () {
|
||||
var hasModifiedA = false;
|
||||
mapToIterate.forEach(function (value, key) {
|
||||
if (!hasModifiedA && key === 'a') {
|
||||
expect(mapToIterate.set('a', 4)).to.equal(mapToIterate);
|
||||
hasModifiedA = true;
|
||||
} else {
|
||||
expect(key).not.to.equal('a');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the map from #set() for chaining', function () {
|
||||
expect(mapToIterate.set({}, {})).to.equal(mapToIterate);
|
||||
expect(mapToIterate.set(42, {})).to.equal(mapToIterate);
|
||||
expect(mapToIterate.set(0, {})).to.equal(mapToIterate);
|
||||
expect(mapToIterate.set(NaN, {})).to.equal(mapToIterate);
|
||||
expect(mapToIterate.set(-0, {})).to.equal(mapToIterate);
|
||||
});
|
||||
|
||||
it('visits keys added in the iterator', function () {
|
||||
var hasAdded = false;
|
||||
var hasFoundD = false;
|
||||
mapToIterate.forEach(function (value, key) {
|
||||
if (!hasAdded) {
|
||||
mapToIterate.set('d', 5);
|
||||
hasAdded = true;
|
||||
} else if (key === 'd') {
|
||||
hasFoundD = true;
|
||||
}
|
||||
});
|
||||
expect(hasFoundD).to.equal(true);
|
||||
});
|
||||
|
||||
it('visits keys added in the iterator when there is a deletion', function () {
|
||||
var hasSeenFour = false;
|
||||
var mapToMutate = new Map();
|
||||
mapToMutate.set('0', 42);
|
||||
mapToMutate.forEach(function (value, key) {
|
||||
if (key === '0') {
|
||||
expect(mapToMutate['delete']('0')).to.equal(true);
|
||||
mapToMutate.set('4', 'a value');
|
||||
} else if (key === '4') {
|
||||
hasSeenFour = true;
|
||||
}
|
||||
});
|
||||
expect(hasSeenFour).to.equal(true);
|
||||
});
|
||||
|
||||
it('does not visit keys deleted before a visit', function () {
|
||||
var hasVisitedC = false;
|
||||
var hasDeletedC = false;
|
||||
mapToIterate.forEach(function (value, key) {
|
||||
if (key === 'c') {
|
||||
hasVisitedC = true;
|
||||
}
|
||||
if (!hasVisitedC && !hasDeletedC) {
|
||||
hasDeletedC = mapToIterate['delete']('c');
|
||||
expect(hasDeletedC).to.equal(true);
|
||||
}
|
||||
});
|
||||
expect(hasVisitedC).to.equal(false);
|
||||
});
|
||||
|
||||
it('should work after deletion of the current key', function () {
|
||||
var expectedMap = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
};
|
||||
var foundMap = {};
|
||||
mapToIterate.forEach(function (value, key) {
|
||||
foundMap[key] = value;
|
||||
expect(mapToIterate['delete'](key)).to.equal(true);
|
||||
});
|
||||
expect(foundMap).to.eql(expectedMap);
|
||||
});
|
||||
|
||||
it('should convert key -0 to +0', function () {
|
||||
var zeroMap = new Map();
|
||||
var result = [];
|
||||
zeroMap.set(-0, 'a');
|
||||
zeroMap.forEach(function (value, key) {
|
||||
result.push(String(1 / key) + ' ' + value);
|
||||
});
|
||||
zeroMap.set(1, 'b');
|
||||
zeroMap.set(0, 'c'); // shouldn't cause reordering
|
||||
zeroMap.forEach(function (value, key) {
|
||||
result.push(String(1 / key) + ' ' + value);
|
||||
});
|
||||
expect(result.join(', ')).to.equal(
|
||||
'Infinity a, Infinity c, 1 b'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should preserve insertion order', function () {
|
||||
var convertToPairs = function (item) { return [item, true]; };
|
||||
var arr1 = ['d', 'a', 'b'];
|
||||
var arr2 = [3, 2, 'z', 'a', 1];
|
||||
var arr3 = [3, 2, 'z', {}, 'a', 1];
|
||||
|
||||
[arr1, arr2, arr3].forEach(function (array) {
|
||||
var entries = array.map(convertToPairs);
|
||||
expect(new Map(entries)).to.have.entries(entries);
|
||||
});
|
||||
});
|
||||
|
||||
it('map iteration', function () {
|
||||
var map = new Map();
|
||||
map.set('a', 1);
|
||||
map.set('b', 2);
|
||||
map.set('c', 3);
|
||||
map.set('d', 4);
|
||||
|
||||
var keys = [];
|
||||
var iterator = map.keys();
|
||||
keys.push(iterator.next().value);
|
||||
expect(map['delete']('a')).to.equal(true);
|
||||
expect(map['delete']('b')).to.equal(true);
|
||||
expect(map['delete']('c')).to.equal(true);
|
||||
map.set('e');
|
||||
keys.push(iterator.next().value);
|
||||
keys.push(iterator.next().value);
|
||||
|
||||
expect(iterator.next().done).to.equal(true);
|
||||
map.set('f');
|
||||
expect(iterator.next().done).to.equal(true);
|
||||
expect(keys).to.eql(['a', 'd', 'e']);
|
||||
});
|
||||
});
|
848
node_modules/es6-shim/test/math.js
generated
vendored
Normal file
848
node_modules/es6-shim/test/math.js
generated
vendored
Normal file
@ -0,0 +1,848 @@
|
||||
var Assertion = expect().constructor;
|
||||
Assertion.prototype.almostEqual = function (obj, precision) {
|
||||
'use strict';
|
||||
|
||||
var allowedDiff = precision || 1e-11;
|
||||
return this.within(obj - allowedDiff, obj + allowedDiff);
|
||||
};
|
||||
|
||||
describe('Math', function () {
|
||||
var functionsHaveNames = (function foo() {}).name === 'foo';
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
|
||||
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
|
||||
|
||||
var isPositiveZero = function (zero) {
|
||||
'use strict';
|
||||
|
||||
return zero === 0 && 1 / zero === Infinity;
|
||||
};
|
||||
var isNegativeZero = function (zero) {
|
||||
'use strict';
|
||||
|
||||
return zero === 0 && 1 / zero === -Infinity;
|
||||
};
|
||||
var numberIsNaN = Number.isNaN || function (value) {
|
||||
return value !== value;
|
||||
};
|
||||
var valueOfIsNaN = { valueOf: function () { return NaN; } };
|
||||
var valueOfIsInfinity = { valueOf: function () { return Infinity; } };
|
||||
var EPSILON = Number.EPSILON || 2.2204460492503130808472633361816e-16;
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.Math).to.equal(Math);
|
||||
});
|
||||
|
||||
describe('.acosh()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'acosh')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('acosh');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.acosh).to.have.property('name', 'acosh');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('acosh').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.acosh).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(numberIsNaN(Math.acosh(NaN))).to.equal(true);
|
||||
expect(numberIsNaN(Math.acosh(0))).to.equal(true);
|
||||
expect(numberIsNaN(Math.acosh(0.9999999))).to.equal(true);
|
||||
expect(numberIsNaN(Math.acosh(-1e300))).to.equal(true);
|
||||
expect(Math.acosh(1e+99)).to.almostEqual(228.64907138697046);
|
||||
expect(isPositiveZero(Math.acosh(1))).to.equal(true);
|
||||
expect(Math.acosh(Infinity)).to.equal(Infinity);
|
||||
expect(Math.acosh(1234)).to.almostEqual(7.811163220849231);
|
||||
expect(Math.acosh(8.88)).to.almostEqual(2.8737631531629235);
|
||||
expect(Math.acosh(1e160)).to.almostEqual(369.10676205960726);
|
||||
expect(Math.acosh(Number.MAX_VALUE)).to.almostEqual(710.4758600739439);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.asinh()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'asinh')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('asinh');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.asinh).to.have.property('name', 'asinh');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('asinh').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.asinh).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct for NaN', function () {
|
||||
expect(numberIsNaN(Math.asinh(NaN))).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be correct for zeroes', function () {
|
||||
expect(isPositiveZero(Math.asinh(+0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.asinh(-0))).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be correct for Infinities', function () {
|
||||
expect(Math.asinh(Infinity)).to.equal(Infinity);
|
||||
expect(Math.asinh(-Infinity)).to.equal(-Infinity);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(Math.asinh(1234)).to.almostEqual(7.811163549201245);
|
||||
expect(Math.asinh(9.99)).to.almostEqual(2.997227420191335);
|
||||
expect(Math.asinh(1e150)).to.almostEqual(346.0809111296668);
|
||||
expect(Math.asinh(1e7)).to.almostEqual(16.811242831518268);
|
||||
expect(Math.asinh(-1e7)).to.almostEqual(-16.811242831518268);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.atanh()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'atanh')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('atanh');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.atanh).to.have.property('name', 'atanh');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('atanh').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.atanh).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(numberIsNaN(Math.atanh(NaN))).to.equal(true);
|
||||
expect(numberIsNaN(Math.atanh(-1.00000001))).to.equal(true);
|
||||
expect(numberIsNaN(Math.atanh(1.00000001))).to.equal(true);
|
||||
expect(numberIsNaN(Math.atanh(-1e300))).to.equal(true);
|
||||
expect(numberIsNaN(Math.atanh(1e300))).to.equal(true);
|
||||
expect(Math.atanh(-1)).to.equal(-Infinity);
|
||||
expect(Math.atanh(1)).to.equal(Infinity);
|
||||
expect(isPositiveZero(Math.atanh(+0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.atanh(-0))).to.equal(true);
|
||||
expect(Math.atanh(0.5)).to.almostEqual(0.5493061443340549);
|
||||
expect(Math.atanh(-0.5)).to.almostEqual(-0.5493061443340549);
|
||||
expect(Math.atanh(-0.5)).to.almostEqual(-0.5493061443340549);
|
||||
expect(Math.atanh(0.444)).to.almostEqual(0.47720201260109457);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.cbrt()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'cbrt')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('cbrt');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.cbrt).to.have.property('name', 'cbrt');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('cbrt').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.cbrt).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(isNaN(Math.cbrt(NaN))).to.equal(true);
|
||||
expect(isPositiveZero(Math.cbrt(+0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.cbrt(-0))).to.equal(true);
|
||||
expect(Math.cbrt(Infinity)).to.equal(Infinity);
|
||||
expect(Math.cbrt(-Infinity)).to.equal(-Infinity);
|
||||
expect(Math.cbrt(-8)).to.almostEqual(-2);
|
||||
expect(Math.cbrt(8)).to.almostEqual(2);
|
||||
expect(Math.cbrt(-1000)).to.almostEqual(-10);
|
||||
expect(Math.cbrt(1000)).to.almostEqual(10);
|
||||
expect(Math.cbrt(-1e-300)).to.almostEqual(-1e-100);
|
||||
expect(Math.cbrt(1e-300)).to.almostEqual(1e-100);
|
||||
expect(Math.cbrt(-1e+300)).to.almostEqual(-1e+100);
|
||||
expect(Math.cbrt(1e+300)).to.almostEqual(1e+100);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.clz32()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'clz32')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('clz32');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.clz32).to.have.property('name', 'clz32');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('clz32').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.clz32).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should have proper uint32 conversion', function () {
|
||||
var integers = [5295, -5295, -9007199254740991, 9007199254740991, 0, -0];
|
||||
var nonNumbers = [undefined, true, null, {}, [], 'str'];
|
||||
var nonIntegers = [-9007199254741992, 9007199254741992, 5.9];
|
||||
|
||||
integers.forEach(function (item) {
|
||||
expect(Math.clz32(item)).to.be.within(0, 32);
|
||||
});
|
||||
nonIntegers.forEach(function (item) {
|
||||
expect(Math.clz32(item)).to.be.within(0, 32);
|
||||
});
|
||||
nonNumbers.forEach(function (item) {
|
||||
expect(Math.clz32(item)).to.equal(item === true ? 31 : 32);
|
||||
});
|
||||
expect(Math.clz32(true)).to.equal(Math.clz32(1));
|
||||
expect(Math.clz32('')).to.equal(Math.clz32(0));
|
||||
expect(Math.clz32('10')).to.equal(Math.clz32(10));
|
||||
expect(Math.clz32(0.1)).to.equal(32);
|
||||
expect(Math.clz32(-1)).to.equal(0);
|
||||
expect(Math.clz32(1)).to.equal(31);
|
||||
expect(Math.clz32(0xFFFFFFFF)).to.equal(0);
|
||||
expect(Math.clz32(0x1FFFFFFFF)).to.equal(0);
|
||||
expect(Math.clz32(0x111111111)).to.equal(3);
|
||||
expect(Math.clz32(0x11111111)).to.equal(3);
|
||||
});
|
||||
|
||||
it('returns 32 for numbers that coerce to 0', function () {
|
||||
var zeroishes = [
|
||||
0,
|
||||
-0,
|
||||
NaN,
|
||||
Infinity,
|
||||
-Infinity,
|
||||
0x100000000,
|
||||
undefined,
|
||||
null,
|
||||
false,
|
||||
'',
|
||||
'str',
|
||||
{},
|
||||
[],
|
||||
[1, 2]
|
||||
];
|
||||
zeroishes.forEach(function (zeroish) {
|
||||
expect(Math.clz32(zeroish)).to.equal(32);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.cosh()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'cosh')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('cosh');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.cosh).to.have.property('name', 'cosh');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('cosh').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.cosh).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct for NaN', function () {
|
||||
expect(numberIsNaN(Math.cosh(NaN))).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be correct for Infinities', function () {
|
||||
expect(Math.cosh(Infinity)).to.equal(Infinity);
|
||||
expect(Math.cosh(-Infinity)).to.equal(Infinity);
|
||||
});
|
||||
|
||||
it('should be correct for zeroes', function () {
|
||||
expect(Math.cosh(-0)).to.equal(1);
|
||||
expect(Math.cosh(+0)).to.equal(1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
// Overridden precision values here are for Chrome, as of v25.0.1364.172
|
||||
// Broadened slightly for Firefox 31
|
||||
expect(Math.cosh(12)).to.almostEqual(81377.39571257407, 9e-11);
|
||||
expect(Math.cosh(22)).to.almostEqual(1792456423.065795780980053377, 1e-5);
|
||||
expect(Math.cosh(-10)).to.almostEqual(11013.23292010332313972137);
|
||||
expect(Math.cosh(-23)).to.almostEqual(4872401723.1244513000, 1e-5);
|
||||
expect(Math.cosh(-2e-17)).to.equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.expm1()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'expm1')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('expm1');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.expm1).to.have.property('name', 'expm1');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('expm1').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.expm1).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct for NaN', function () {
|
||||
expect(numberIsNaN(Math.expm1(NaN))).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be correct for zeroes', function () {
|
||||
expect(isPositiveZero(Math.expm1(+0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.expm1(-0))).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be correct for Infinity', function () {
|
||||
expect(Math.expm1(Infinity)).to.equal(Infinity);
|
||||
expect(Math.expm1(-Infinity)).to.equal(-1);
|
||||
});
|
||||
|
||||
it('should be correct for arbitrary numbers', function () {
|
||||
expect(Math.expm1(10)).to.almostEqual(22025.465794806716516957900645284244366353512618556781);
|
||||
expect(Math.expm1(-10)).to.almostEqual(-0.99995460007023751514846440848443944938976208191113);
|
||||
expect(Math.expm1(-2e-17)).to.almostEqual(-2e-17);
|
||||
});
|
||||
|
||||
it('works with very negative numbers', function () {
|
||||
expect(Math.expm1(-38)).to.almostEqual(-1);
|
||||
expect(Math.expm1(-8675309)).to.almostEqual(-1);
|
||||
expect(Math.expm1(-4815162342)).to.almostEqual(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.hypot()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'hypot')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('hypot');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.hypot).to.have.property('name', 'hypot');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('hypot').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.hypot).to.have.property('length', 2);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(Math.hypot(Infinity)).to.equal(Infinity);
|
||||
expect(Math.hypot(-Infinity)).to.equal(Infinity);
|
||||
expect(Math.hypot(Infinity, NaN)).to.equal(Infinity);
|
||||
expect(Math.hypot(NaN, Infinity)).to.equal(Infinity);
|
||||
expect(Math.hypot(-Infinity, 'Hello')).to.equal(Infinity);
|
||||
expect(Math.hypot(1, 2, Infinity)).to.equal(Infinity);
|
||||
expect(numberIsNaN(Math.hypot(NaN, 1))).to.equal(true);
|
||||
expect(isPositiveZero(Math.hypot())).to.equal(true);
|
||||
expect(isPositiveZero(Math.hypot(0, 0, 0))).to.equal(true);
|
||||
expect(isPositiveZero(Math.hypot(0, -0, 0))).to.equal(true);
|
||||
expect(isPositiveZero(Math.hypot(-0, -0, -0))).to.equal(true);
|
||||
expect(Math.hypot(66, 66)).to.almostEqual(93.33809511662427);
|
||||
expect(Math.hypot(0.1, 100)).to.almostEqual(100.0000499999875);
|
||||
});
|
||||
|
||||
it('should coerce to a number', function () {
|
||||
expect(Math.hypot('Infinity', 0)).to.equal(Infinity);
|
||||
expect(Math.hypot('3', '3', '3', '3')).to.equal(6);
|
||||
});
|
||||
|
||||
it('should take more than 3 arguments', function () {
|
||||
expect(Math.hypot(66, 66, 66)).to.almostEqual(114.3153532995459);
|
||||
expect(Math.hypot(66, 66, 66, 66)).to.equal(132);
|
||||
});
|
||||
|
||||
it('should have the right length', function () {
|
||||
expect(Math.hypot.length).to.equal(2);
|
||||
});
|
||||
|
||||
it('works for very large or small numbers', function () {
|
||||
expect(Math.hypot(1e+300, 1e+300)).to.almostEqual(1.4142135623730952e+300);
|
||||
expect(Math.hypot(1e-300, 1e-300)).to.almostEqual(1.4142135623730952e-300);
|
||||
expect(Math.hypot(1e+300, 1e+300, 2, 3)).to.almostEqual(1.4142135623730952e+300);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.log2()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'log2')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('log2');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.log2).to.have.property('name', 'log2');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('log2').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.log2).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('is correct for small numbers', function () {
|
||||
expect(numberIsNaN(Math.log2(-1e-50))).to.equal(true);
|
||||
});
|
||||
|
||||
it('is correct for edge cases', function () {
|
||||
expect(numberIsNaN(Math.log2(NaN))).to.equal(true);
|
||||
expect(Math.log2(+0)).to.equal(-Infinity);
|
||||
expect(Math.log2(-0)).to.equal(-Infinity);
|
||||
expect(isPositiveZero(Math.log2(1))).to.equal(true);
|
||||
expect(Math.log2(Infinity)).to.equal(Infinity);
|
||||
});
|
||||
|
||||
it('should have the right precision', function () {
|
||||
expect(Math.log2(5)).to.almostEqual(2.321928094887362);
|
||||
expect(Math.log2(32)).to.almostEqual(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.log10', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'log10')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('log10');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.log10).to.have.property('name', 'log10');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('log10').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.log10).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct for edge cases', function () {
|
||||
expect(numberIsNaN(Math.log10(NaN))).to.equal(true);
|
||||
expect(numberIsNaN(Math.log10(-1e-50))).to.equal(true);
|
||||
expect(Math.log10(+0)).to.equal(-Infinity);
|
||||
expect(Math.log10(-0)).to.equal(-Infinity);
|
||||
expect(isPositiveZero(Math.log10(1))).to.equal(true);
|
||||
expect(Math.log10(Infinity)).to.equal(Infinity);
|
||||
});
|
||||
|
||||
it('should have the right precision', function () {
|
||||
expect(Math.log10(5)).to.almostEqual(0.698970004336018);
|
||||
expect(Math.log10(50)).to.almostEqual(1.6989700043360187);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.log1p', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'log1p')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('log1p');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.log1p).to.have.property('name', 'log1p');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('log1p').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.log1p).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(numberIsNaN(Math.log1p(NaN))).to.equal(true);
|
||||
expect(numberIsNaN(Math.log1p(-1.000000001))).to.equal(true);
|
||||
expect(Math.log1p(-1)).to.equal(-Infinity);
|
||||
expect(isPositiveZero(Math.log1p(+0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.log1p(-0))).to.equal(true);
|
||||
expect(Math.log1p(Infinity)).to.equal(Infinity);
|
||||
|
||||
expect(Math.log1p(5)).to.almostEqual(1.791759469228055);
|
||||
expect(Math.log1p(50)).to.almostEqual(3.9318256327243257);
|
||||
expect(Math.log1p(-1e-17)).to.equal(-1e-17);
|
||||
expect(Math.log1p(-2e-17)).to.equal(-2e-17);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.sign()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'sign')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('sign');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.sign).to.have.property('name', 'sign');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('sign').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.sign).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
// we also verify that [[ToNumber]] is being called
|
||||
[Infinity, 1].forEach(function (value) {
|
||||
expect(Math.sign(value)).to.equal(1);
|
||||
expect(Math.sign(String(value))).to.equal(1);
|
||||
});
|
||||
expect(Math.sign(true)).to.equal(1);
|
||||
|
||||
[-Infinity, -1].forEach(function (value) {
|
||||
expect(Math.sign(value)).to.equal(-1);
|
||||
expect(Math.sign(String(value))).to.equal(-1);
|
||||
});
|
||||
|
||||
expect(isPositiveZero(Math.sign(+0))).to.equal(true);
|
||||
expect(isPositiveZero(Math.sign('0'))).to.equal(true);
|
||||
expect(isPositiveZero(Math.sign('+0'))).to.equal(true);
|
||||
expect(isPositiveZero(Math.sign(''))).to.equal(true);
|
||||
expect(isPositiveZero(Math.sign(' '))).to.equal(true);
|
||||
expect(isPositiveZero(Math.sign(null))).to.equal(true);
|
||||
expect(isPositiveZero(Math.sign(false))).to.equal(true);
|
||||
expect(isNegativeZero(Math.sign(-0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.sign('-0'))).to.equal(true);
|
||||
expect(numberIsNaN(Math.sign(NaN))).to.equal(true);
|
||||
expect(numberIsNaN(Math.sign('NaN'))).to.equal(true);
|
||||
expect(numberIsNaN(Math.sign(undefined))).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.sinh()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'sinh')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('sinh');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.sinh).to.have.property('name', 'sinh');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('sinh').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.sinh).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(numberIsNaN(Math.sinh(NaN))).to.equal(true);
|
||||
expect(isPositiveZero(Math.sinh(+0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.sinh(-0))).to.equal(true);
|
||||
expect(Math.sinh(Infinity)).to.equal(Infinity);
|
||||
expect(Math.sinh(-Infinity)).to.equal(-Infinity);
|
||||
expect(Math.sinh(-5)).to.almostEqual(-74.20321057778875);
|
||||
expect(Math.sinh(2)).to.almostEqual(3.6268604078470186);
|
||||
expect(Math.sinh(-2e-17)).to.equal(-2e-17);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.tanh()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'tanh')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('tanh');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.tanh).to.have.property('name', 'tanh');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('tanh').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.tanh).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(numberIsNaN(Math.tanh(NaN))).to.equal(true);
|
||||
expect(isPositiveZero(Math.tanh(+0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.tanh(-0))).to.equal(true);
|
||||
expect(Math.tanh(Infinity)).to.equal(1);
|
||||
expect(Math.tanh(-Infinity)).to.equal(-1);
|
||||
expect(Math.tanh(19)).to.almostEqual(1);
|
||||
expect(Math.tanh(-19)).to.almostEqual(-1);
|
||||
expect(Math.tanh(20)).to.equal(1); // JS loses precision for true value at this integer
|
||||
expect(Math.tanh(-20)).to.equal(-1); // JS loses precision for true value at this integer
|
||||
expect(Math.tanh(10)).to.almostEqual(0.9999999958776927);
|
||||
expect(Math.tanh(-2e-17)).to.equal(-2e-17);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.trunc()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'trunc')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('trunc');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.trunc).to.have.property('name', 'trunc');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('trunc').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.trunc).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(numberIsNaN(Math.trunc(NaN))).to.equal(true);
|
||||
expect(isNegativeZero(Math.trunc(-0))).to.equal(true);
|
||||
expect(isPositiveZero(Math.trunc(+0))).to.equal(true);
|
||||
expect(Math.trunc(Infinity)).to.equal(Infinity);
|
||||
expect(Math.trunc(-Infinity)).to.equal(-Infinity);
|
||||
expect(Math.trunc(1.01)).to.equal(1);
|
||||
expect(Math.trunc(1.99)).to.equal(1);
|
||||
expect(Math.trunc(-555.555)).to.equal(-555);
|
||||
expect(Math.trunc(-1.99)).to.equal(-1);
|
||||
});
|
||||
|
||||
it('should coerce to a number immediately', function () {
|
||||
expect(Math.trunc(valueOfIsInfinity)).to.equal(Infinity);
|
||||
expect(numberIsNaN(Math.trunc(valueOfIsNaN))).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.imul()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'imul')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('imul');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.imul).to.have.property('name', 'imul');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('imul').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.imul).to.have.property('length', 2);
|
||||
});
|
||||
|
||||
var str = 'str';
|
||||
var obj = {};
|
||||
var arr = [];
|
||||
|
||||
it('should be correct for non-numbers', function () {
|
||||
expect(Math.imul(false, 7)).to.equal(0);
|
||||
expect(Math.imul(7, false)).to.equal(0);
|
||||
expect(Math.imul(false, false)).to.equal(0);
|
||||
expect(Math.imul(true, 7)).to.equal(7);
|
||||
expect(Math.imul(7, true)).to.equal(7);
|
||||
expect(Math.imul(true, true)).to.equal(1);
|
||||
expect(Math.imul(undefined, 7)).to.equal(0);
|
||||
expect(Math.imul(7, undefined)).to.equal(0);
|
||||
expect(Math.imul(undefined, undefined)).to.equal(0);
|
||||
expect(Math.imul(str, 7)).to.equal(0);
|
||||
expect(Math.imul(7, str)).to.equal(0);
|
||||
expect(Math.imul(obj, 7)).to.equal(0);
|
||||
expect(Math.imul(7, obj)).to.equal(0);
|
||||
expect(Math.imul(arr, 7)).to.equal(0);
|
||||
expect(Math.imul(7, arr)).to.equal(0);
|
||||
});
|
||||
|
||||
it('should be correct for hex values', function () {
|
||||
expect(Math.imul(0xffffffff, 5)).to.equal(-5);
|
||||
expect(Math.imul(0xfffffffe, 5)).to.equal(-10);
|
||||
});
|
||||
|
||||
it('should be correct', function () {
|
||||
expect(Math.imul(2, 4)).to.equal(8);
|
||||
expect(Math.imul(-1, 8)).to.equal(-8);
|
||||
expect(Math.imul(-2, -2)).to.equal(4);
|
||||
expect(Math.imul(-0, 7)).to.equal(0);
|
||||
expect(Math.imul(7, -0)).to.equal(0);
|
||||
expect(Math.imul(0.1, 7)).to.equal(0);
|
||||
expect(Math.imul(7, 0.1)).to.equal(0);
|
||||
expect(Math.imul(0.9, 7)).to.equal(0);
|
||||
expect(Math.imul(7, 0.9)).to.equal(0);
|
||||
expect(Math.imul(1.1, 7)).to.equal(7);
|
||||
expect(Math.imul(7, 1.1)).to.equal(7);
|
||||
expect(Math.imul(1.9, 7)).to.equal(7);
|
||||
expect(Math.imul(7, 1.9)).to.equal(7);
|
||||
});
|
||||
|
||||
it('should be correct for objects with valueOf', function () {
|
||||
var x = {
|
||||
x: 0,
|
||||
valueOf: function () { this.x += 1; return this.x; }
|
||||
};
|
||||
expect(Math.imul(x, 1)).to.equal(1);
|
||||
expect(Math.imul(1, x)).to.equal(2);
|
||||
expect(Math.imul(x, 1)).to.equal(3);
|
||||
expect(Math.imul(1, x)).to.equal(4);
|
||||
expect(Math.imul(x, 1)).to.equal(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.round()', function () {
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.round).to.have.property('name', 'round');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('round').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.round).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('works for edge cases', function () {
|
||||
expect(numberIsNaN(Math.round(NaN))).to.equal(true);
|
||||
expect(isPositiveZero(Math.round(0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.round(-0))).to.equal(true);
|
||||
expect(Math.round(Infinity)).to.equal(Infinity);
|
||||
expect(Math.round(-Infinity)).to.equal(-Infinity);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
it('returns 1 / Number.EPSILON + 1 for 1 / Number.EPSILON + 1', function () {
|
||||
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;
|
||||
expect(Math.round(twiceInverseEpsilonMinus1)).to.equal(twiceInverseEpsilonMinus1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.fround()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Math, 'fround')) {
|
||||
return it('exists', function () {
|
||||
expect(Math).to.have.property('fround');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Math.fround).to.have.property('name', 'fround');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Math).ownPropertyDescriptor('fround').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Math.fround).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
// Mozilla's reference tests: https://bug900125.bugzilla.mozilla.org/attachment.cgi?id=793163
|
||||
it('returns NaN for undefined', function () {
|
||||
expect(numberIsNaN(Math.fround())).to.equal(true);
|
||||
});
|
||||
|
||||
it('returns NaN for NaN', function () {
|
||||
expect(numberIsNaN(Math.fround(NaN))).to.equal(true);
|
||||
});
|
||||
|
||||
it('works for zeroes and infinities', function () {
|
||||
expect(isPositiveZero(Math.fround(0))).to.equal(true);
|
||||
expect(isPositiveZero(Math.fround({ valueOf: function () { return 0; } }))).to.equal(true);
|
||||
expect(isNegativeZero(Math.fround(-0))).to.equal(true);
|
||||
expect(isNegativeZero(Math.fround({ valueOf: function () { return -0; } }))).to.equal(true);
|
||||
expect(Math.fround(Infinity)).to.equal(Infinity);
|
||||
expect(Math.fround({ valueOf: function () { return Infinity; } })).to.equal(Infinity);
|
||||
expect(Math.fround(-Infinity)).to.equal(-Infinity);
|
||||
expect(Math.fround({ valueOf: function () { return -Infinity; } })).to.equal(-Infinity);
|
||||
});
|
||||
|
||||
it('returns infinity for large numbers', function () {
|
||||
expect(Math.fround(1.7976931348623157e+308)).to.equal(Infinity);
|
||||
expect(Math.fround(-1.7976931348623157e+308)).to.equal(-Infinity);
|
||||
expect(Math.fround(3.4028235677973366e+38)).to.equal(Infinity);
|
||||
});
|
||||
|
||||
it('returns zero for really small numbers', function () {
|
||||
expect(Number.MIN_VALUE).to.equal(5e-324);
|
||||
|
||||
expect(Math.fround(Number.MIN_VALUE)).to.equal(0);
|
||||
expect(Math.fround(-Number.MIN_VALUE)).to.equal(0);
|
||||
});
|
||||
|
||||
it('rounds properly', function () {
|
||||
expect(Math.fround(3)).to.equal(3);
|
||||
expect(Math.fround(-3)).to.equal(-3);
|
||||
});
|
||||
|
||||
it('rounds properly with the max float 32', function () {
|
||||
var maxFloat32 = 3.4028234663852886e+38;
|
||||
expect(Math.fround(maxFloat32)).to.equal(maxFloat32);
|
||||
expect(Math.fround(-maxFloat32)).to.equal(-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 () {
|
||||
var minFloat32 = 1.401298464324817e-45;
|
||||
expect(Math.fround(minFloat32)).to.equal(minFloat32);
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
2
node_modules/es6-shim/test/mocha.opts
generated
vendored
Normal file
2
node_modules/es6-shim/test/mocha.opts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
--require test/test_helpers.js
|
||||
|
39
node_modules/es6-shim/test/native.html
generated
vendored
Normal file
39
node_modules/es6-shim/test/native.html
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>es6-shim tests</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="browser-setup.js"></script>
|
||||
<script src="array.js"></script>
|
||||
<script src="map.js"></script>
|
||||
<script src="set.js"></script>
|
||||
<script src="json.js"></script>
|
||||
<script src="math.js"></script>
|
||||
<script src="number.js"></script>
|
||||
<script src="object.js"></script>
|
||||
<script src="promise.js"></script>
|
||||
<script src="regexp.js"></script>
|
||||
<script src="string.js"></script>
|
||||
<script src="reflect.js"></script>
|
||||
<script src="worker-test.js"></script>
|
||||
<script src="promise/all.js"></script>
|
||||
<script src="promise/evil-promises.js"></script>
|
||||
<!--
|
||||
<script src="promise/promises-aplus.js"></script>
|
||||
-->
|
||||
<script src="promise/race.js"></script>
|
||||
<script src="promise/reject.js"></script>
|
||||
<script src="promise/resolve.js"></script>
|
||||
<script src="promise/simple.js"></script>
|
||||
<script src="promise/subclass.js"></script>
|
||||
<script src="browser-onload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
481
node_modules/es6-shim/test/number.js
generated
vendored
Normal file
481
node_modules/es6-shim/test/number.js
generated
vendored
Normal file
@ -0,0 +1,481 @@
|
||||
describe('Number', function () {
|
||||
var functionsHaveNames = (function foo() {}).name === 'foo';
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
|
||||
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
|
||||
|
||||
var integers = [5295, -5295, -9007199254740991, 9007199254740991, 0, -0];
|
||||
var nonIntegers = [-9007199254741992, 9007199254741992, 5.9];
|
||||
var infinities = [Infinity, -Infinity];
|
||||
|
||||
var valueOfThree = { valueOf: function () { return 3; } };
|
||||
var valueOfNaN = { valueOf: function () { return NaN; } };
|
||||
var valueOfThrows = { valueOf: function () { throw Object(17); } };
|
||||
var toStringThrows = { toString: function () { throw Object(42); } };
|
||||
var toPrimitiveThrows = {
|
||||
valueOf: function () { throw Object(17); },
|
||||
toString: function () { throw Object(42); }
|
||||
};
|
||||
|
||||
var nonNumbers = [
|
||||
undefined,
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
{},
|
||||
[],
|
||||
'str',
|
||||
'',
|
||||
valueOfThree,
|
||||
valueOfNaN,
|
||||
valueOfThrows,
|
||||
toStringThrows,
|
||||
toPrimitiveThrows,
|
||||
/a/g
|
||||
];
|
||||
var expectTrue = function (item) {
|
||||
expect(item).to.equal(true);
|
||||
};
|
||||
var expectFalse = function (item) {
|
||||
expect(item).to.equal(false);
|
||||
};
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.Number).to.equal(Number);
|
||||
});
|
||||
|
||||
describe('Number constants', function () {
|
||||
it('should have max safe integer', function () {
|
||||
expect(Number).to.have.property('MAX_SAFE_INTEGER');
|
||||
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(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(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(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(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(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(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(Object.prototype.propertyIsEnumerable.call(Number, 'POSITIVE_INFINITY')).to.equal(false);
|
||||
expect(Number.POSITIVE_INFINITY).to.equal(Infinity);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.parseInt()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Number, 'parseInt')) {
|
||||
return it('exists', function () {
|
||||
expect(Number).to.have.property('parseInt');
|
||||
});
|
||||
}
|
||||
|
||||
it('should work', function () {
|
||||
/* eslint-disable radix */
|
||||
expect(Number.parseInt('601')).to.equal(601);
|
||||
/* eslint-enable radix */
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Number.parseInt).to.have.property('name', 'parseInt');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Number).ownPropertyDescriptor('parseInt').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
// WebKit nightly had the wrong length; fixed in https://bugs.webkit.org/show_bug.cgi?id=143657
|
||||
expect(Number.parseInt).to.have.property('length', 2);
|
||||
});
|
||||
|
||||
it('is the same object as the global parseInt', function () {
|
||||
// fixed in WebKit nightly in https://bugs.webkit.org/show_bug.cgi?id=143799#add_comment
|
||||
expect(Number.parseInt).to.equal(parseInt);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.parseFloat()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Number, 'parseFloat')) {
|
||||
return it('exists', function () {
|
||||
expect(Number).to.have.property('parseFloat');
|
||||
});
|
||||
}
|
||||
|
||||
it('should work', function () {
|
||||
expect(Number.parseFloat('5.5')).to.equal(5.5);
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Number.parseFloat).to.have.property('name', 'parseFloat');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Number).ownPropertyDescriptor('parseFloat').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Number.parseFloat).to.have.property('length', 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.isFinite()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Number, 'isFinite')) {
|
||||
return it('exists', function () {
|
||||
expect(Number).to.have.property('isFinite');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Number.isFinite).to.have.property('name', 'isFinite');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Number).ownPropertyDescriptor('isFinite').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Number.isFinite).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should work', function () {
|
||||
integers.map(Number.isFinite).forEach(expectTrue);
|
||||
infinities.map(Number.isFinite).forEach(expectFalse);
|
||||
expect(Number.isFinite(Infinity)).to.equal(false);
|
||||
expect(Number.isFinite(-Infinity)).to.equal(false);
|
||||
expect(Number.isFinite(NaN)).to.equal(false);
|
||||
expect(Number.isFinite(4)).to.equal(true);
|
||||
expect(Number.isFinite(4.5)).to.equal(true);
|
||||
expect(Number.isFinite('hi')).to.equal(false);
|
||||
expect(Number.isFinite('1.3')).to.equal(false);
|
||||
expect(Number.isFinite('51')).to.equal(false);
|
||||
expect(Number.isFinite(0)).to.equal(true);
|
||||
expect(Number.isFinite(-0)).to.equal(true);
|
||||
expect(Number.isFinite(valueOfThree)).to.equal(false);
|
||||
expect(Number.isFinite(valueOfNaN)).to.equal(false);
|
||||
expect(Number.isFinite(valueOfThrows)).to.equal(false);
|
||||
expect(Number.isFinite(toStringThrows)).to.equal(false);
|
||||
expect(Number.isFinite(toPrimitiveThrows)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should not be confused by type coercion', function () {
|
||||
nonNumbers.map(Number.isFinite).forEach(expectFalse);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.isInteger()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Number, 'isInteger')) {
|
||||
return it('exists', function () {
|
||||
expect(Number).to.have.property('isInteger');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Number.isInteger).to.have.property('name', 'isInteger');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Number).ownPropertyDescriptor('isInteger').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Number.isInteger).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be truthy on integers', function () {
|
||||
integers.map(Number.isInteger).forEach(expectTrue);
|
||||
expect(Number.isInteger(4)).to.equal(true);
|
||||
expect(Number.isInteger(4.0)).to.equal(true);
|
||||
expect(Number.isInteger(1801439850948)).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be false when the type is not number', function () {
|
||||
nonNumbers.forEach(function (thing) {
|
||||
expect(Number.isInteger(thing)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be false when NaN', function () {
|
||||
expect(Number.isInteger(NaN)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be false when ∞', function () {
|
||||
expect(Number.isInteger(Infinity)).to.equal(false);
|
||||
expect(Number.isInteger(-Infinity)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be false when number is not integer', function () {
|
||||
expect(Number.isInteger(3.4)).to.equal(false);
|
||||
expect(Number.isInteger(-3.4)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be true when abs(number) is 2^53 or larger', function () {
|
||||
expect(Number.isInteger(Math.pow(2, 53))).to.equal(true);
|
||||
expect(Number.isInteger(Math.pow(2, 54))).to.equal(true);
|
||||
expect(Number.isInteger(-Math.pow(2, 53))).to.equal(true);
|
||||
expect(Number.isInteger(-Math.pow(2, 54))).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be true when abs(number) is less than 2^53', function () {
|
||||
var safeIntegers = [0, 1, Math.pow(2, 53) - 1];
|
||||
safeIntegers.forEach(function (integer) {
|
||||
expect(Number.isInteger(integer)).to.equal(true);
|
||||
expect(Number.isInteger(-integer)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.isSafeInteger()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Number, 'isSafeInteger')) {
|
||||
return it('exists', function () {
|
||||
expect(Number).to.have.property('isSafeInteger');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Number.isSafeInteger).to.have.property('name', 'isSafeInteger');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Number).ownPropertyDescriptor('isSafeInteger').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Number.isSafeInteger).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be truthy on integers', function () {
|
||||
integers.map(Number.isSafeInteger).forEach(expectTrue);
|
||||
expect(Number.isSafeInteger(4)).to.equal(true);
|
||||
expect(Number.isSafeInteger(4.0)).to.equal(true);
|
||||
expect(Number.isSafeInteger(1801439850948)).to.equal(true);
|
||||
});
|
||||
|
||||
it('should be false when the type is not number', function () {
|
||||
nonNumbers.forEach(function (thing) {
|
||||
expect(Number.isSafeInteger(thing)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be false when NaN', function () {
|
||||
expect(Number.isSafeInteger(NaN)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be false when ∞', function () {
|
||||
expect(Number.isSafeInteger(Infinity)).to.equal(false);
|
||||
expect(Number.isSafeInteger(-Infinity)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be false when number is not integer', function () {
|
||||
expect(Number.isSafeInteger(3.4)).to.equal(false);
|
||||
expect(Number.isSafeInteger(-3.4)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be false when abs(number) is 2^53 or larger', function () {
|
||||
expect(Number.isSafeInteger(Math.pow(2, 53))).to.equal(false);
|
||||
expect(Number.isSafeInteger(Math.pow(2, 54))).to.equal(false);
|
||||
expect(Number.isSafeInteger(-Math.pow(2, 53))).to.equal(false);
|
||||
expect(Number.isSafeInteger(-Math.pow(2, 54))).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be true when abs(number) is less than 2^53', function () {
|
||||
var safeIntegers = [0, 1, Math.pow(2, 53) - 1];
|
||||
safeIntegers.forEach(function (integer) {
|
||||
expect(Number.isSafeInteger(integer)).to.equal(true);
|
||||
expect(Number.isSafeInteger(-integer)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.isNaN()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Number, 'isNaN')) {
|
||||
return it('exists', function () {
|
||||
expect(Number).to.have.property('isNaN');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Number.isNaN).to.have.property('name', 'isNaN');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Number).ownPropertyDescriptor('isNaN').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Number.isNaN).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be truthy only on NaN', function () {
|
||||
integers.concat(nonIntegers).map(Number.isNaN).forEach(expectFalse);
|
||||
nonNumbers.map(Number.isNaN).forEach(expectFalse);
|
||||
expect(Number.isNaN(NaN)).to.equal(true);
|
||||
expect(Number.isNaN(0 / 0)).to.equal(true);
|
||||
expect(Number.isNaN(Number('NaN'))).to.equal(true);
|
||||
expect(Number.isNaN(4)).to.equal(false);
|
||||
expect(Number.isNaN(4.5)).to.equal(false);
|
||||
expect(Number.isNaN('hi')).to.equal(false);
|
||||
expect(Number.isNaN('1.3')).to.equal(false);
|
||||
expect(Number.isNaN('51')).to.equal(false);
|
||||
expect(Number.isNaN(0)).to.equal(false);
|
||||
expect(Number.isNaN(-0)).to.equal(false);
|
||||
expect(Number.isNaN(valueOfThree)).to.equal(false);
|
||||
expect(Number.isNaN(valueOfNaN)).to.equal(false);
|
||||
expect(Number.isNaN(valueOfThrows)).to.equal(false);
|
||||
expect(Number.isNaN(toStringThrows)).to.equal(false);
|
||||
expect(Number.isNaN(toPrimitiveThrows)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
it('behaves like the builtin', function () {
|
||||
expect((1).constructor).to.equal(Number);
|
||||
expect(Number()).to.equal(0);
|
||||
});
|
||||
|
||||
describe('strings in the constructor', function () {
|
||||
it('works on normal literals', function () {
|
||||
expect(Number('1')).to.equal(+'1');
|
||||
expect(Number('1.1')).to.equal(+'1.1');
|
||||
expect(Number('0xA')).to.equal(0xA);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when called with a receiver', function () {
|
||||
it('returns a primitive when called with a primitive receiver', function () {
|
||||
expect((1).constructor(2)).to.equal(2);
|
||||
expect((1).constructor.call(null, 3)).to.equal(3);
|
||||
expect(Object(1).constructor.call(null, 5)).to.equal(5);
|
||||
});
|
||||
|
||||
it('returns a primitive when called with a different number as an object receiver', function () {
|
||||
expect(Object(1).constructor(6)).to.equal(6);
|
||||
expect(Object(1).constructor.call(Object(1), 7)).to.equal(7);
|
||||
});
|
||||
|
||||
it('returns a primitive when called with the same number as an object receiver', function () {
|
||||
expect(Object(1).constructor.call(Object(8), 8)).to.equal(8);
|
||||
});
|
||||
});
|
||||
|
||||
it('works with boxed primitives', function () {
|
||||
expect(1 instanceof Number).to.equal(false);
|
||||
expect(Object(1) instanceof Number).to.equal(true);
|
||||
});
|
||||
|
||||
it('works with `new`', function () {
|
||||
/* jshint -W053 */
|
||||
/* eslint-disable no-new-wrappers */
|
||||
var one = new Number('1');
|
||||
var a = new Number('0xA');
|
||||
/* eslint-enable no-new-wrappers */
|
||||
/* jshint +W053 */
|
||||
|
||||
expect(+one).to.equal(1);
|
||||
expect(one instanceof Number).to.equal(true);
|
||||
expect(+a).to.equal(0xA);
|
||||
expect(a instanceof Number).to.equal(true);
|
||||
});
|
||||
|
||||
it('works with binary literals in string form', function () {
|
||||
expect(Number('0b1')).to.equal(1);
|
||||
expect(Number(' 0b1')).to.equal(1);
|
||||
expect(Number('0b1 ')).to.equal(1);
|
||||
|
||||
expect(Number('0b10')).to.equal(2);
|
||||
expect(Number(' 0b10')).to.equal(2);
|
||||
expect(Number('0b10 ')).to.equal(2);
|
||||
|
||||
expect(Number('0b11')).to.equal(3);
|
||||
expect(Number(' 0b11')).to.equal(3);
|
||||
expect(Number('0b11 ')).to.equal(3);
|
||||
|
||||
expect(Number({
|
||||
toString: function () { return '0b100'; },
|
||||
valueOf: function () { return '0b101'; }
|
||||
})).to.equal(5);
|
||||
});
|
||||
|
||||
it('works with octal literals in string form', function () {
|
||||
expect(Number('0o7')).to.equal(7);
|
||||
expect(Number('0o10')).to.equal(8);
|
||||
expect(Number('0o11')).to.equal(9);
|
||||
expect(Number({
|
||||
toString: function () { return '0o12'; },
|
||||
valueOf: function () { return '0o13'; }
|
||||
})).to.equal(11);
|
||||
});
|
||||
|
||||
it('should produce NaN', function () {
|
||||
expect(String(Number('0b12'))).to.equal('NaN');
|
||||
expect(String(Number('0o18'))).to.equal('NaN');
|
||||
expect(String(Number('0x1g'))).to.equal('NaN');
|
||||
expect(String(Number('+0b1'))).to.equal('NaN');
|
||||
expect(String(Number('+0o1'))).to.equal('NaN');
|
||||
expect(String(Number('+0x1'))).to.equal('NaN');
|
||||
expect(String(Number('-0b1'))).to.equal('NaN');
|
||||
expect(String(Number('-0o1'))).to.equal('NaN');
|
||||
expect(String(Number('-0x1'))).to.equal('NaN');
|
||||
});
|
||||
|
||||
it('should work with well formed and poorly formed objects', function () {
|
||||
expect(String(Number({}))).to.equal('NaN');
|
||||
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(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);
|
||||
expect(Number({ toString: function () { return '0o12345'; } })).to.equal(5349);
|
||||
expect(Number({ valueOf: function () { return '0b101010'; } })).to.equal(42);
|
||||
expect(Number({ toString: function () { return '0b101010'; } })).to.equal(42);
|
||||
});
|
||||
|
||||
it('should work with correct whitespaces', function () {
|
||||
var whitespace = ' \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000';
|
||||
|
||||
// Zero-width space (zws), next line character (nel), and non-character (bom) are not whitespace.
|
||||
var nonWhitespaces = ['\u0085', '\u200b', '\ufffe'];
|
||||
|
||||
expect(String(Number(nonWhitespaces[0] + '0' + nonWhitespaces[0]))).to.equal('NaN');
|
||||
expect(String(Number(nonWhitespaces[1] + '1' + nonWhitespaces[1]))).to.equal('NaN');
|
||||
expect(String(Number(nonWhitespaces[2] + '2' + nonWhitespaces[2]))).to.equal('NaN');
|
||||
expect(String(Number(whitespace + '3' + whitespace))).to.equal('3');
|
||||
});
|
||||
});
|
||||
});
|
365
node_modules/es6-shim/test/object.js
generated
vendored
Normal file
365
node_modules/es6-shim/test/object.js
generated
vendored
Normal file
@ -0,0 +1,365 @@
|
||||
describe('Object', function () {
|
||||
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.Object).to.equal(Object);
|
||||
});
|
||||
|
||||
var functionsHaveNames = (function foo() {}).name === 'foo';
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
|
||||
var ifExtensionsPreventable = Object.preventExtensions ? it : xit;
|
||||
|
||||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
|
||||
var ifSymbolsIt = hasSymbols ? it : xit;
|
||||
var ifBrowserIt = typeof window === 'object' && typeof document === 'object' ? it : xit;
|
||||
var ifObjectGetPrototypeOfIt = typeof Object.getPrototypeOf === 'function' ? it : xit;
|
||||
|
||||
if (Object.getOwnPropertyNames) {
|
||||
describe('.getOwnPropertyNames()', function () {
|
||||
it('throws on null or undefined', function () {
|
||||
expect(function () { Object.getOwnPropertyNames(); }).to['throw'](TypeError);
|
||||
expect(function () { Object.getOwnPropertyNames(undefined); }).to['throw'](TypeError);
|
||||
expect(function () { Object.getOwnPropertyNames(null); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('works on primitives', function () {
|
||||
[true, false, NaN, 42, /a/g, 'foo'].forEach(function (item) {
|
||||
expect(Object.getOwnPropertyNames(item)).to.eql(Object.getOwnPropertyNames(Object(item)));
|
||||
});
|
||||
});
|
||||
|
||||
ifBrowserIt('does not break when an iframe is added', function () {
|
||||
/*global window, document */
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = '<iframe src="http://xkcd.com"></iframe>';
|
||||
document.body.appendChild(div);
|
||||
setTimeout(function () {
|
||||
document.body.removeChild(div);
|
||||
}, 0);
|
||||
expect(Array.isArray(Object.getOwnPropertyNames(window))).to.eql(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.getOwnPropertyDescriptor) {
|
||||
describe('.getOwnPropertyDescriptor()', function () {
|
||||
it('throws on null or undefined', function () {
|
||||
expect(function () { Object.getOwnPropertyDescriptor(); }).to['throw'](TypeError);
|
||||
expect(function () { Object.getOwnPropertyDescriptor(undefined); }).to['throw'](TypeError);
|
||||
expect(function () { Object.getOwnPropertyDescriptor(null); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('works on primitives', function () {
|
||||
[true, false, NaN, 42, /a/g, 'foo'].forEach(function (item) {
|
||||
expect(Object.getOwnPropertyDescriptor(item, 'foo')).to.eql(Object.getOwnPropertyDescriptor(Object(item), 'foo'));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.seal) {
|
||||
describe('.seal()', function () {
|
||||
it('works on primitives', function () {
|
||||
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
|
||||
expect(Object.seal(item)).to.eql(item);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.isSealed) {
|
||||
describe('.isSealed()', function () {
|
||||
it('works on primitives', function () {
|
||||
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
|
||||
expect(Object.isSealed(item)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
describe('.freeze()', function () {
|
||||
it('works on primitives', function () {
|
||||
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
|
||||
expect(Object.freeze(item)).to.eql(item);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.isFrozen) {
|
||||
describe('.isFrozen()', function () {
|
||||
it('works on primitives', function () {
|
||||
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
|
||||
expect(Object.isFrozen(item)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.preventExtensions) {
|
||||
describe('.preventExtensions()', function () {
|
||||
it('works on primitives', function () {
|
||||
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
|
||||
expect(Object.preventExtensions(item)).to.eql(item);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.isExtensible) {
|
||||
describe('.isExtensible()', function () {
|
||||
it('works on primitives', function () {
|
||||
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
|
||||
expect(Object.isExtensible(item)).to.equal(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('.keys()', function () {
|
||||
it('works on strings', function () {
|
||||
expect(Object.keys('foo')).to.eql(['0', '1', '2']);
|
||||
});
|
||||
|
||||
it('throws on null or undefined', function () {
|
||||
expect(function () { Object.keys(); }).to['throw'](TypeError);
|
||||
expect(function () { Object.keys(undefined); }).to['throw'](TypeError);
|
||||
expect(function () { Object.keys(null); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('works on other primitives', function () {
|
||||
[true, false, NaN, 42, /a/g].forEach(function (item) {
|
||||
expect(Object.keys(item)).to.eql([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.is()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Object, 'is')) {
|
||||
return it('exists', function () {
|
||||
expect(Object).to.have.property('is');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Object.is).to.have.property('name', 'is');
|
||||
});
|
||||
|
||||
it('should have the right arity', function () {
|
||||
expect(Object.is).to.have.property('length', 2);
|
||||
});
|
||||
|
||||
it('should compare regular objects correctly', function () {
|
||||
[null, undefined, [0], 5, 'str', { a: null }].map(function (item) {
|
||||
return Object.is(item, item);
|
||||
}).forEach(function (result) {
|
||||
expect(result).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should compare 0 and -0 correctly', function () {
|
||||
expect(Object.is(0, -0)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should compare NaNs correctly', function () {
|
||||
expect(Object.is(NaN, NaN)).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.assign()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Object, 'assign')) {
|
||||
return it('exists', function () {
|
||||
expect(Object).to.have.property('assign');
|
||||
});
|
||||
}
|
||||
|
||||
it('has the correct length', function () {
|
||||
expect(Object.assign.length).to.eql(2);
|
||||
});
|
||||
|
||||
it('returns the modified target object', function () {
|
||||
var target = {};
|
||||
var returned = Object.assign(target, { a: 1 });
|
||||
expect(returned).to.equal(target);
|
||||
});
|
||||
|
||||
it('should merge two objects', function () {
|
||||
var target = { a: 1 };
|
||||
var returned = Object.assign(target, { b: 2 });
|
||||
expect(returned).to.eql({ a: 1, b: 2 });
|
||||
});
|
||||
|
||||
it('should merge three objects', function () {
|
||||
var target = { a: 1 };
|
||||
var source1 = { b: 2 };
|
||||
var source2 = { c: 3 };
|
||||
var returned = Object.assign(target, source1, source2);
|
||||
expect(returned).to.eql({ a: 1, b: 2, c: 3 });
|
||||
});
|
||||
|
||||
it('only iterates over own keys', function () {
|
||||
var Foo = function () {};
|
||||
Foo.prototype.bar = true;
|
||||
var foo = new Foo();
|
||||
foo.baz = true;
|
||||
var target = { a: 1 };
|
||||
var returned = Object.assign(target, foo);
|
||||
expect(returned).to.equal(target);
|
||||
expect(target).to.eql({ baz: true, a: 1 });
|
||||
});
|
||||
|
||||
it('throws when target is null or undefined', function () {
|
||||
expect(function () { Object.assign(null); }).to['throw'](TypeError);
|
||||
expect(function () { Object.assign(undefined); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('coerces lone target to an object', function () {
|
||||
var result = {
|
||||
bool: Object.assign(true),
|
||||
number: Object.assign(1),
|
||||
string: Object.assign('1')
|
||||
};
|
||||
|
||||
expect(typeof result.bool).to.equal('object');
|
||||
expect(Boolean.prototype.valueOf.call(result.bool)).to.equal(true);
|
||||
|
||||
expect(typeof result.number).to.equal('object');
|
||||
expect(Number.prototype.valueOf.call(result.number)).to.equal(1);
|
||||
|
||||
expect(typeof result.string).to.equal('object');
|
||||
expect(String.prototype.valueOf.call(result.string)).to.equal('1');
|
||||
});
|
||||
|
||||
it('coerces target to an object, assigns from sources', function () {
|
||||
var sourceA = { a: 1 };
|
||||
var sourceB = { b: 1 };
|
||||
|
||||
var result = {
|
||||
bool: Object.assign(true, sourceA, sourceB),
|
||||
number: Object.assign(1, sourceA, sourceB),
|
||||
string: Object.assign('1', sourceA, sourceB)
|
||||
};
|
||||
|
||||
expect(typeof result.bool).to.equal('object');
|
||||
expect(Boolean.prototype.valueOf.call(result.bool)).to.equal(true);
|
||||
expect(result.bool).to.eql({ a: 1, b: 1 });
|
||||
|
||||
expect(typeof result.number).to.equal('object');
|
||||
expect(Number.prototype.valueOf.call(result.number)).to.equal(1);
|
||||
|
||||
expect(typeof result.string).to.equal('object');
|
||||
expect(String.prototype.valueOf.call(result.string)).to.equal('1');
|
||||
expect(result.string).to.eql({ 0: '1', a: 1, b: 1 });
|
||||
});
|
||||
|
||||
it('ignores non-object sources', function () {
|
||||
expect(Object.assign({ a: 1 }, null, { b: 2 })).to.eql({ a: 1, b: 2 });
|
||||
expect(Object.assign({ a: 1 }, undefined, { b: 2 })).to.eql({ a: 1, b: 2 });
|
||||
expect(Object.assign({ a: 1 }, { b: 2 }, null)).to.eql({ a: 1, b: 2 });
|
||||
});
|
||||
|
||||
ifExtensionsPreventable('does not have pending exceptions', function () {
|
||||
'use strict';
|
||||
|
||||
// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
|
||||
// which is 72% slower than our shim, and Firefox 40's native implementation.
|
||||
var thrower = { 1: 2, 2: 3, 3: 4 };
|
||||
Object.defineProperty(thrower, 2, {
|
||||
get: function () { return 3; },
|
||||
set: function (v) { throw new RangeError('IE 9 does not throw on preventExtensions: ' + v); }
|
||||
});
|
||||
Object.preventExtensions(thrower);
|
||||
expect(thrower).to.have.property(2, 3);
|
||||
var error;
|
||||
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
|
||||
expect(error).to.be.an.instanceOf(RangeError);
|
||||
} else {
|
||||
expect(error).to.be.an.instanceOf(TypeError);
|
||||
expect(thrower).to.have.property(1, 2);
|
||||
}
|
||||
expect(thrower).to.have.property(2, 3);
|
||||
expect(thrower).to.have.property(3, 4);
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
var nonEnumSymbol = Symbol('non-enumerable');
|
||||
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);
|
||||
expect(target[symbol]).to.equal(Infinity);
|
||||
expect(target[nonEnumSymbol]).not.to.equal(-Infinity);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Object.setPrototypeOf()', function () {
|
||||
if (!Object.setPrototypeOf) {
|
||||
return; // IE < 11
|
||||
}
|
||||
|
||||
describe('argument checking', function () {
|
||||
it('should throw TypeError if first arg is not object', function () {
|
||||
var nonObjects = [null, undefined, true, false, 1, 3, 'foo'];
|
||||
nonObjects.forEach(function (value) {
|
||||
expect(function () { Object.setPrototypeOf(value); }).to['throw'](TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw TypeError if second arg is not object or null', function () {
|
||||
expect(function () { Object.setPrototypeOf({}, null); }).not.to['throw'](TypeError);
|
||||
var invalidPrototypes = [true, false, 1, 3, 'foo'];
|
||||
invalidPrototypes.forEach(function (proto) {
|
||||
expect(function () { Object.setPrototypeOf({}, proto); }).to['throw'](TypeError);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('set prototype', function () {
|
||||
it('should work', function () {
|
||||
var Foo = function () {};
|
||||
var Bar = {};
|
||||
var foo = new Foo();
|
||||
expect(Object.getPrototypeOf(foo)).to.equal(Foo.prototype);
|
||||
|
||||
var fooBar = Object.setPrototypeOf(foo, Bar);
|
||||
expect(fooBar).to.equal(foo);
|
||||
expect(Object.getPrototypeOf(foo)).to.equal(Bar);
|
||||
});
|
||||
it('should be able to set to null', function () {
|
||||
var Foo = function () {};
|
||||
var foo = new Foo();
|
||||
|
||||
var fooNull = Object.setPrototypeOf(foo, null);
|
||||
expect(fooNull).to.equal(foo);
|
||||
expect(Object.getPrototypeOf(foo)).to.equal(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getPrototypeOf()', function () {
|
||||
ifObjectGetPrototypeOfIt('does not throw for a primitive', function () {
|
||||
expect(Object.getPrototypeOf(3)).to.equal(Number.prototype);
|
||||
});
|
||||
});
|
||||
});
|
43
node_modules/es6-shim/test/promise.js
generated
vendored
Normal file
43
node_modules/es6-shim/test/promise.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/* This file is for testing implementation regressions of Promises. */
|
||||
|
||||
describe('Promise', function () {
|
||||
if (typeof Promise === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(typeof Promise).to.be('function');
|
||||
});
|
||||
}
|
||||
|
||||
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.Promise).to.equal(Promise);
|
||||
});
|
||||
|
||||
it('ignores non-function .then arguments', function () {
|
||||
expect(function () {
|
||||
Promise.reject(42).then(null, 5).then(null, function () {});
|
||||
}).not.to['throw']();
|
||||
});
|
||||
|
||||
describe('extra methods (bad Chrome!)', function () {
|
||||
it('does not have accept', function () {
|
||||
expect(Promise).not.to.have.property('accept');
|
||||
});
|
||||
|
||||
it('does not have defer', function () {
|
||||
expect(Promise).not.to.have.property('defer');
|
||||
});
|
||||
|
||||
it('does not have chain', function () {
|
||||
expect(Promise.prototype).not.to.have.property('chain');
|
||||
});
|
||||
});
|
||||
|
||||
it('requires an object context', function () {
|
||||
// this fails in Safari 7.1 - 9
|
||||
expect(function promiseDotCallThree() {
|
||||
Promise.call(3, function () {});
|
||||
}).to['throw']();
|
||||
});
|
||||
});
|
203
node_modules/es6-shim/test/promise/all.js
generated
vendored
Normal file
203
node_modules/es6-shim/test/promise/all.js
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
/* global it, describe, expect, assert, Promise */
|
||||
|
||||
var failIfThrows = function (done) {
|
||||
'use strict';
|
||||
|
||||
return function (e) {
|
||||
done(e || new Error());
|
||||
};
|
||||
};
|
||||
|
||||
describe('Promise.all', function () {
|
||||
'use strict';
|
||||
|
||||
it('should not be enumerable', function () {
|
||||
expect(Promise).ownPropertyDescriptor('all').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('fulfills if passed an empty array', function (done) {
|
||||
var iterable = [];
|
||||
|
||||
Promise.all(iterable).then(function (value) {
|
||||
assert(Array.isArray(value));
|
||||
assert.deepEqual(value, []);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('fulfills if passed an empty array-like', function (done) {
|
||||
var f = function () {
|
||||
Promise.all(arguments).then(function (value) {
|
||||
assert(Array.isArray(value));
|
||||
assert.deepEqual(value, []);
|
||||
}).then(done, failIfThrows(done));
|
||||
};
|
||||
f();
|
||||
});
|
||||
|
||||
it('fulfills if passed an array of mixed fulfilled promises and values', function (done) {
|
||||
var iterable = [0, Promise.resolve(1), 2, Promise.resolve(3)];
|
||||
|
||||
Promise.all(iterable).then(function (value) {
|
||||
assert(Array.isArray(value));
|
||||
assert.deepEqual(value, [0, 1, 2, 3]);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('rejects if any passed promise is rejected', function (done) {
|
||||
var foreverPending = new Promise(function () { });
|
||||
var error = new Error('Rejected');
|
||||
var rejected = Promise.reject(error);
|
||||
|
||||
var iterable = [foreverPending, rejected];
|
||||
|
||||
Promise.all(iterable).then(
|
||||
function () {
|
||||
assert(false, 'should never get here');
|
||||
},
|
||||
function (reason) {
|
||||
assert.strictEqual(reason, error);
|
||||
}
|
||||
).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('resolves foreign thenables', function (done) {
|
||||
var normal = Promise.resolve(1);
|
||||
var foreign = { then: function (f) { f(2); } };
|
||||
|
||||
var iterable = [normal, foreign];
|
||||
|
||||
Promise.all(iterable).then(function (value) {
|
||||
assert.deepEqual(value, [1, 2]);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('fulfills when passed an sparse array, giving `undefined` for the omitted values', function (done) {
|
||||
/* jshint elision: true */
|
||||
/* jscs:disable disallowSpaceBeforeComma */
|
||||
/* jscs:disable requireSpaceAfterComma */
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
var iterable = [Promise.resolve(0), , , Promise.resolve(1)];
|
||||
/* eslint-enable no-sparse-arrays */
|
||||
/* jscs:enable requireSpaceAfterComma */
|
||||
/* jscs:enable disallowSpaceBeforeComma */
|
||||
/* jshint elision: false */
|
||||
|
||||
Promise.all(iterable).then(function (value) {
|
||||
assert.deepEqual(value, [0, undefined, undefined, 1]);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('does not modify the input array', function (done) {
|
||||
var input = [0, 1];
|
||||
var iterable = input;
|
||||
|
||||
Promise.all(iterable).then(function (value) {
|
||||
assert.notStrictEqual(input, value);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('should reject with a TypeError if given a non-iterable', function (done) {
|
||||
var notIterable = {};
|
||||
|
||||
Promise.all(notIterable).then(
|
||||
function () {
|
||||
assert(false, 'should never get here');
|
||||
},
|
||||
function (reason) {
|
||||
assert(reason instanceof TypeError);
|
||||
}
|
||||
).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
// test cases from
|
||||
// https://github.com/domenic/promises-unwrapping/issues/89#issuecomment-33110203
|
||||
var tamper = function (p) {
|
||||
p.then = function (fulfill, reject) {
|
||||
fulfill('tampered');
|
||||
return Promise.prototype.then.call(this, fulfill, reject);
|
||||
};
|
||||
return p;
|
||||
};
|
||||
|
||||
it('should be robust against tampering (1)', function (done) {
|
||||
var g = [tamper(Promise.resolve(0))];
|
||||
// Prevent countdownHolder.[[Countdown]] from ever reaching zero
|
||||
Promise.all(g).then(
|
||||
function () { done(); },
|
||||
failIfThrows(done)
|
||||
);
|
||||
});
|
||||
|
||||
it('should be robust against tampering (2)', function (done) {
|
||||
// Promise from Promise.all resolved before arguments
|
||||
var fulfillCalled = false;
|
||||
|
||||
var g = [
|
||||
Promise.resolve(0),
|
||||
tamper(Promise.resolve(1)),
|
||||
Promise.resolve(2).then(function () {
|
||||
assert(!fulfillCalled, 'should be resolved before all()');
|
||||
}).then(function () {
|
||||
assert(!fulfillCalled, 'should be resolved before all()');
|
||||
})['catch'](failIfThrows(done))
|
||||
];
|
||||
Promise.all(g).then(function () {
|
||||
assert(!fulfillCalled, 'should be resolved last');
|
||||
fulfillCalled = true;
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('should be robust against tampering (3)', function (done) {
|
||||
var g = [
|
||||
Promise.resolve(0),
|
||||
tamper(Promise.resolve(1)),
|
||||
Promise.reject(2)
|
||||
];
|
||||
// Promise from Promise.all resolved despite rejected promise in arguments
|
||||
Promise.all(g).then(function () {
|
||||
throw new Error('should not reach here!');
|
||||
}, function (e) {
|
||||
assert.strictEqual(e, 2);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('should be robust against tampering (4)', function (done) {
|
||||
var hijack = true;
|
||||
var actualArguments = [];
|
||||
var P = function (resolver) {
|
||||
var self;
|
||||
if (hijack) {
|
||||
hijack = false;
|
||||
self = new Promise(function (resolve, reject) {
|
||||
return resolver(function (values) {
|
||||
// record arguments & # of times resolve function is called
|
||||
actualArguments.push(values.slice());
|
||||
return resolve(values);
|
||||
}, reject);
|
||||
});
|
||||
} else {
|
||||
self = new Promise(resolver);
|
||||
}
|
||||
Object.setPrototypeOf(self, P.prototype);
|
||||
return self;
|
||||
};
|
||||
if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11
|
||||
Object.setPrototypeOf(P, Promise);
|
||||
P.prototype = Object.create(Promise.prototype, {
|
||||
constructor: { value: P }
|
||||
});
|
||||
P.resolve = function (p) { return p; };
|
||||
|
||||
var g = [
|
||||
Promise.resolve(0),
|
||||
tamper(Promise.resolve(1)),
|
||||
Promise.resolve(2)
|
||||
];
|
||||
|
||||
// Promise.all calls resolver twice
|
||||
P.all(g)['catch'](failIfThrows(done));
|
||||
Promise.resolve().then(function () {
|
||||
assert.deepEqual(actualArguments, [[0, 'tampered', 2]]);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
});
|
36
node_modules/es6-shim/test/promise/evil-promises.js
generated
vendored
Normal file
36
node_modules/es6-shim/test/promise/evil-promises.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
describe('Evil promises should not be able to break invariants', function () {
|
||||
'use strict';
|
||||
|
||||
specify('resolving to a promise that calls onFulfilled twice', function (done) {
|
||||
// note that we have to create a trivial subclass, as otherwise the
|
||||
// Promise.resolve(evilPromise) is just the identity function.
|
||||
// (And in fact, most native Promise implementations use a private
|
||||
// [[PromiseConstructor]] field in `Promise.resolve` which can't be
|
||||
// easily patched in an ES5 engine, so instead of
|
||||
// `Promise.resolve(evilPromise)` we'll use
|
||||
// `new Promise(function(r){r(evilPromise);})` below.)
|
||||
var EvilPromise = function (executor) {
|
||||
var self = new Promise(executor);
|
||||
Object.setPrototypeOf(self, EvilPromise.prototype);
|
||||
return self;
|
||||
};
|
||||
if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11
|
||||
Object.setPrototypeOf(EvilPromise, Promise);
|
||||
EvilPromise.prototype = Object.create(Promise.prototype, {
|
||||
constructor: { value: EvilPromise }
|
||||
});
|
||||
|
||||
var evilPromise = EvilPromise.resolve();
|
||||
evilPromise.then = function (f) {
|
||||
f(1);
|
||||
f(2);
|
||||
};
|
||||
|
||||
var calledAlready = false;
|
||||
new Promise(function (r) { r(evilPromise); }).then(function (value) {
|
||||
assert.strictEqual(calledAlready, false);
|
||||
calledAlready = true;
|
||||
assert.strictEqual(value, 1);
|
||||
}).then(done, done);
|
||||
});
|
||||
});
|
23
node_modules/es6-shim/test/promise/promises-aplus.js
generated
vendored
Normal file
23
node_modules/es6-shim/test/promise/promises-aplus.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// tests from promises-aplus-tests
|
||||
|
||||
describe('Promises/A+ Tests', function () {
|
||||
'use strict';
|
||||
|
||||
if (typeof Promise === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
require('promises-aplus-tests').mocha({
|
||||
// an adapter from es6 spec to Promises/A+
|
||||
deferred: function () {
|
||||
var result = {};
|
||||
result.promise = new Promise(function (resolve, reject) {
|
||||
result.resolve = resolve;
|
||||
result.reject = reject;
|
||||
});
|
||||
return result;
|
||||
},
|
||||
resolved: Promise.resolve.bind(Promise),
|
||||
rejected: Promise.reject.bind(Promise)
|
||||
});
|
||||
});
|
22
node_modules/es6-shim/test/promise/promises-es6.js
generated
vendored
Normal file
22
node_modules/es6-shim/test/promise/promises-es6.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// tests from promises-es6-tests
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (typeof Promise === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
describe('Promises/ES6 Tests', function () {
|
||||
|
||||
// an adapter that sets up global.Promise
|
||||
// since it's already set up, empty functions will suffice
|
||||
var adapter = {
|
||||
defineGlobalPromise: function () {
|
||||
},
|
||||
removeGlobalPromise: function () {
|
||||
}
|
||||
};
|
||||
|
||||
require('promises-es6-tests').mocha(adapter);
|
||||
});
|
||||
}());
|
88
node_modules/es6-shim/test/promise/race.js
generated
vendored
Normal file
88
node_modules/es6-shim/test/promise/race.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
var failIfThrows = function (done) {
|
||||
'use strict';
|
||||
|
||||
return function (e) {
|
||||
done(e || new Error());
|
||||
};
|
||||
};
|
||||
|
||||
var delayPromise = function (value, ms) {
|
||||
'use strict';
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(function () {
|
||||
resolve(value);
|
||||
}, ms);
|
||||
});
|
||||
};
|
||||
|
||||
describe('Promise.race', function () {
|
||||
'use strict';
|
||||
|
||||
it('should not be enumerable', function () {
|
||||
expect(Promise).ownPropertyDescriptor('race').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('should fulfill if all promises are settled and the ordinally-first is fulfilled', function (done) {
|
||||
var iterable = [Promise.resolve(1), Promise.reject(2), Promise.resolve(3)];
|
||||
|
||||
Promise.race(iterable).then(function (value) {
|
||||
assert.strictEqual(value, 1);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('should reject if all promises are settled and the ordinally-first is rejected', function (done) {
|
||||
var iterable = [Promise.reject(1), Promise.reject(2), Promise.resolve(3)];
|
||||
|
||||
Promise.race(iterable).then(
|
||||
function () {
|
||||
assert(false, 'should never get here');
|
||||
},
|
||||
function (reason) {
|
||||
assert.strictEqual(reason, 1);
|
||||
}
|
||||
).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('should settle in the same way as the first promise to settle', function (done) {
|
||||
// ensure that even if timeouts are delayed an all execute together,
|
||||
// p2 will settle first.
|
||||
var p2 = delayPromise(2, 200);
|
||||
var p1 = delayPromise(1, 1000);
|
||||
var p3 = delayPromise(3, 500);
|
||||
var iterable = [p1, p2, p3];
|
||||
|
||||
Promise.race(iterable).then(function (value) {
|
||||
assert.strictEqual(value, 2);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
// see https://github.com/domenic/promises-unwrapping/issues/75
|
||||
it('should never settle when given an empty iterable', function (done) {
|
||||
var iterable = [];
|
||||
var settled = false;
|
||||
|
||||
Promise.race(iterable).then(
|
||||
function () { settled = true; },
|
||||
function () { settled = true; }
|
||||
);
|
||||
|
||||
setTimeout(function () {
|
||||
assert.strictEqual(settled, false);
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('should reject with a TypeError if given a non-iterable', function (done) {
|
||||
var notIterable = {};
|
||||
|
||||
Promise.race(notIterable).then(
|
||||
function () {
|
||||
assert(false, 'should never get here');
|
||||
},
|
||||
function (reason) {
|
||||
assert(reason instanceof TypeError);
|
||||
}
|
||||
).then(done, failIfThrows(done));
|
||||
});
|
||||
});
|
34
node_modules/es6-shim/test/promise/reject.js
generated
vendored
Normal file
34
node_modules/es6-shim/test/promise/reject.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
var failIfThrows = function (done) {
|
||||
'use strict';
|
||||
|
||||
return function (e) {
|
||||
done(e || new Error());
|
||||
};
|
||||
};
|
||||
|
||||
describe('Promise.reject', function () {
|
||||
'use strict';
|
||||
|
||||
it('should not be enumerable', function () {
|
||||
expect(Promise).ownPropertyDescriptor('reject').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('should return a rejected promise', function (done) {
|
||||
var value = {};
|
||||
Promise.reject(value).then(failIfThrows(done), function (result) {
|
||||
expect(result).to.equal(value);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('throws when receiver is a primitive', function () {
|
||||
var promise = Promise.reject();
|
||||
expect(function () { Promise.reject.call(undefined, promise); }).to['throw']();
|
||||
expect(function () { Promise.reject.call(null, promise); }).to['throw']();
|
||||
expect(function () { Promise.reject.call('', promise); }).to['throw']();
|
||||
expect(function () { Promise.reject.call(42, promise); }).to['throw']();
|
||||
expect(function () { Promise.reject.call(false, promise); }).to['throw']();
|
||||
expect(function () { Promise.reject.call(true, promise); }).to['throw']();
|
||||
promise.then(null, function () {}); // silence unhandled rejection errors in Chrome
|
||||
});
|
||||
});
|
33
node_modules/es6-shim/test/promise/resolve.js
generated
vendored
Normal file
33
node_modules/es6-shim/test/promise/resolve.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var failIfThrows = function (done) {
|
||||
'use strict';
|
||||
|
||||
return function (e) {
|
||||
done(e || new Error());
|
||||
};
|
||||
};
|
||||
|
||||
describe('Promise.resolve', function () {
|
||||
'use strict';
|
||||
|
||||
it('should not be enumerable', function () {
|
||||
expect(Promise).ownPropertyDescriptor('resolve').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('should return a resolved promise', function (done) {
|
||||
var value = {};
|
||||
Promise.resolve(value).then(function (result) {
|
||||
expect(result).to.equal(value);
|
||||
done();
|
||||
}, failIfThrows(done));
|
||||
});
|
||||
|
||||
it('throws when receiver is a primitive', function () {
|
||||
var promise = Promise.resolve();
|
||||
expect(function () { Promise.resolve.call(undefined, promise); }).to['throw']();
|
||||
expect(function () { Promise.resolve.call(null, promise); }).to['throw']();
|
||||
expect(function () { Promise.resolve.call('', promise); }).to['throw']();
|
||||
expect(function () { Promise.resolve.call(42, promise); }).to['throw']();
|
||||
expect(function () { Promise.resolve.call(false, promise); }).to['throw']();
|
||||
expect(function () { Promise.resolve.call(true, promise); }).to['throw']();
|
||||
});
|
||||
});
|
96
node_modules/es6-shim/test/promise/simple.js
generated
vendored
Normal file
96
node_modules/es6-shim/test/promise/simple.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
var failIfThrows = function (done) {
|
||||
'use strict';
|
||||
|
||||
return function (e) {
|
||||
done(e || new Error());
|
||||
};
|
||||
};
|
||||
|
||||
describe('Promise', function () {
|
||||
'use strict';
|
||||
|
||||
specify('sanity check: a fulfilled promise calls its fulfillment handler', function (done) {
|
||||
Promise.resolve(5).then(function (value) {
|
||||
assert.strictEqual(value, 5);
|
||||
}).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
specify('directly resolving the promise with itself', function (done) {
|
||||
var resolvePromise;
|
||||
var promise = new Promise(function (resolve) { resolvePromise = resolve; });
|
||||
|
||||
resolvePromise(promise);
|
||||
|
||||
promise.then(
|
||||
function () {
|
||||
assert(false, 'Should not be fulfilled');
|
||||
},
|
||||
function (err) {
|
||||
assert(err instanceof TypeError);
|
||||
}
|
||||
).then(done, failIfThrows(done));
|
||||
});
|
||||
|
||||
specify('Stealing a resolver and using it to trigger possible reentrancy bug (#83)', function () {
|
||||
var stolenResolver;
|
||||
var StealingPromiseConstructor = function StealingPromiseConstructor(resolver) {
|
||||
stolenResolver = resolver;
|
||||
resolver(function () { }, function () { });
|
||||
};
|
||||
|
||||
var iterable = {};
|
||||
var atAtIterator = '@@iterator'; // on firefox, at least.
|
||||
iterable[atAtIterator] = function () {
|
||||
stolenResolver(null, null);
|
||||
throw new Error(0);
|
||||
};
|
||||
|
||||
assert.doesNotThrow(function () {
|
||||
Promise.all.call(StealingPromiseConstructor, iterable);
|
||||
});
|
||||
});
|
||||
|
||||
specify('resolve with a thenable calls it once', function () {
|
||||
var resolve;
|
||||
var p = new Promise(function (r) { resolve = r; });
|
||||
var count = 0;
|
||||
resolve({
|
||||
then: function () {
|
||||
count += 1;
|
||||
throw new RangeError('reject the promise');
|
||||
}
|
||||
});
|
||||
var a = p.then(function () {})['catch'](function (err) {
|
||||
assert.equal(count, 1);
|
||||
assert.ok(err instanceof RangeError);
|
||||
});
|
||||
var b = p.then(function () {})['catch'](function (err) {
|
||||
assert.equal(count, 1);
|
||||
assert.ok(err instanceof RangeError);
|
||||
});
|
||||
return Promise.all([a, b]);
|
||||
});
|
||||
|
||||
specify('resolve with a thenable that throws on .then, rejects the promise synchronously', function () {
|
||||
var resolve;
|
||||
var p = new Promise(function (r) { resolve = r; });
|
||||
var count = 0;
|
||||
var thenable = Object.defineProperty({}, 'then', {
|
||||
get: function () {
|
||||
count += 1;
|
||||
throw new RangeError('no then for you');
|
||||
}
|
||||
});
|
||||
resolve(thenable);
|
||||
assert.equal(count, 1);
|
||||
var a = p.then(function () {})['catch'](function (err) {
|
||||
assert.equal(count, 1);
|
||||
assert.ok(err instanceof RangeError);
|
||||
});
|
||||
var b = p.then(function () {})['catch'](function (err) {
|
||||
assert.equal(count, 1);
|
||||
assert.ok(err instanceof RangeError);
|
||||
});
|
||||
return Promise.all([a, b]);
|
||||
});
|
||||
});
|
47
node_modules/es6-shim/test/promise/subclass.js
generated
vendored
Normal file
47
node_modules/es6-shim/test/promise/subclass.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/* global it, describe, assert, Promise */
|
||||
|
||||
describe('Support user subclassing of Promise', function () {
|
||||
'use strict';
|
||||
|
||||
it('should work if you do it right', function (done) {
|
||||
// This is the "correct" es6-compatible way.
|
||||
// (Thanks, @domenic and @zloirock!)
|
||||
var MyPromise = function (executor) {
|
||||
var self = new Promise(executor);
|
||||
Object.setPrototypeOf(self, MyPromise.prototype);
|
||||
self.mine = 'yeah';
|
||||
return self;
|
||||
};
|
||||
if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11
|
||||
Object.setPrototypeOf(MyPromise, Promise);
|
||||
MyPromise.prototype = Object.create(Promise.prototype, {
|
||||
constructor: { value: MyPromise }
|
||||
});
|
||||
|
||||
// let's try it!
|
||||
var p1 = MyPromise.resolve(5);
|
||||
assert.strictEqual(p1.mine, 'yeah');
|
||||
p1 = p1.then(function (x) {
|
||||
assert.strictEqual(x, 5);
|
||||
});
|
||||
assert.strictEqual(p1.mine, 'yeah');
|
||||
|
||||
var p2 = new MyPromise(function (r) { r(6); });
|
||||
assert.strictEqual(p2.mine, 'yeah');
|
||||
p2 = p2.then(function (x) {
|
||||
assert.strictEqual(x, 6);
|
||||
});
|
||||
assert.strictEqual(p2.mine, 'yeah');
|
||||
|
||||
var p3 = MyPromise.all([p1, p2]);
|
||||
assert.strictEqual(p3.mine, 'yeah');
|
||||
p3.then(function () { done(); }, done);
|
||||
});
|
||||
|
||||
it("should throw if you don't inherit at all", function () {
|
||||
var MyPromise = function () {};
|
||||
assert['throws'](function () {
|
||||
Promise.all.call(MyPromise, []);
|
||||
}, TypeError);
|
||||
});
|
||||
});
|
679
node_modules/es6-shim/test/reflect.js
generated
vendored
Normal file
679
node_modules/es6-shim/test/reflect.js
generated
vendored
Normal file
@ -0,0 +1,679 @@
|
||||
var arePropertyDescriptorsSupported = function () {
|
||||
try {
|
||||
Object.defineProperty({}, 'x', {});
|
||||
return true;
|
||||
} catch (e) { /* this is IE 8. */
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
|
||||
var functionsHaveNames = function f() {}.name === 'f';
|
||||
|
||||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
|
||||
var ifSymbolsIt = hasSymbols ? it : xit;
|
||||
var describeIfGetProto = Object.getPrototypeOf ? describe : xdescribe;
|
||||
var describeIfSetProto = Object.setPrototypeOf ? describe : xdescribe;
|
||||
var describeIfES5 = supportsDescriptors ? describe : xdescribe;
|
||||
var describeIfExtensionsPreventible = Object.preventExtensions ? describe : xdescribe;
|
||||
var describeIfGetOwnPropertyNames = Object.getOwnPropertyNames ? describe : xdescribe;
|
||||
var ifExtensionsPreventibleIt = Object.preventExtensions ? it : xit;
|
||||
var ifES5It = supportsDescriptors ? it : xit;
|
||||
var ifFreezeIt = typeof Object.freeze === 'function' ? it : xit;
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
|
||||
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
|
||||
|
||||
describe('Reflect', function () {
|
||||
if (typeof Reflect === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(this).to.have.property('Reflect');
|
||||
});
|
||||
}
|
||||
|
||||
var object = {
|
||||
something: 1,
|
||||
_value: 0
|
||||
};
|
||||
|
||||
if (supportsDescriptors) {
|
||||
/* eslint-disable accessor-pairs */
|
||||
Object.defineProperties(object, {
|
||||
value: {
|
||||
get: function () {
|
||||
return this._value;
|
||||
}
|
||||
},
|
||||
|
||||
setter: {
|
||||
set: function (val) {
|
||||
this._value = val;
|
||||
}
|
||||
},
|
||||
|
||||
bool: {
|
||||
value: true
|
||||
}
|
||||
});
|
||||
/* eslint-enable accessor-pairs */
|
||||
}
|
||||
|
||||
var testXThrow = function (values, func) {
|
||||
var checker = function checker(item) {
|
||||
try {
|
||||
func(item);
|
||||
return false;
|
||||
} catch (e) {
|
||||
return e instanceof TypeError;
|
||||
}
|
||||
};
|
||||
|
||||
values.forEach(function (item) {
|
||||
expect(item).to.satisfy(checker);
|
||||
});
|
||||
};
|
||||
|
||||
var testCallableThrow = testXThrow.bind(null, [null, undefined, 1, 'string', true, [], {}]);
|
||||
|
||||
var testPrimitiveThrow = testXThrow.bind(null, [null, undefined, 1, 'string', true]);
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.Reflect).to.equal(Reflect);
|
||||
});
|
||||
|
||||
describe('.apply()', function () {
|
||||
if (typeof Reflect.apply === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('apply');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.apply).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.apply.name).to.equal('apply');
|
||||
});
|
||||
|
||||
it('throws if target isn’t callable', function () {
|
||||
testCallableThrow(function (item) {
|
||||
return Reflect.apply(item, null, []);
|
||||
});
|
||||
});
|
||||
|
||||
it('works also with redefined apply', function () {
|
||||
expect(Reflect.apply(Array.prototype.push, [1, 2], [3, 4, 5])).to.equal(5);
|
||||
|
||||
var F = function F(a, b, c) {
|
||||
return a + b + c;
|
||||
};
|
||||
|
||||
F.apply = false;
|
||||
|
||||
expect(Reflect.apply(F, null, [1, 2, 3])).to.equal(6);
|
||||
|
||||
var G = function G(last) {
|
||||
return this.x + 'lo' + last;
|
||||
};
|
||||
|
||||
G.apply = function nop() {};
|
||||
|
||||
expect(Reflect.apply(G, { x: 'yel' }, ['!'])).to.equal('yello!');
|
||||
});
|
||||
});
|
||||
|
||||
describe('.construct()', function () {
|
||||
if (typeof Reflect.construct === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('construct');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.construct).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.construct.name).to.equal('construct');
|
||||
});
|
||||
|
||||
it('throws if target isn’t callable', function () {
|
||||
testCallableThrow(function (item) {
|
||||
return Reflect.apply(item, null, []);
|
||||
});
|
||||
});
|
||||
|
||||
it('works also with redefined apply', function () {
|
||||
var C = function C(a, b, c) {
|
||||
this.qux = [a, b, c].join('|');
|
||||
};
|
||||
|
||||
C.apply = undefined;
|
||||
|
||||
expect(Reflect.construct(C, ['foo', 'bar', 'baz']).qux).to.equal('foo|bar|baz');
|
||||
});
|
||||
|
||||
it('correctly handles newTarget param', function () {
|
||||
var F = function F() {};
|
||||
expect(Reflect.construct(function () {}, [], F) instanceof F).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describeIfES5('.defineProperty()', function () {
|
||||
if (typeof Reflect.defineProperty === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('defineProperty');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.defineProperty).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.defineProperty.name).to.equal('defineProperty');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.defineProperty(item, 'prop', { value: true });
|
||||
});
|
||||
});
|
||||
|
||||
ifExtensionsPreventibleIt('returns false for non-extensible objects', function () {
|
||||
var o = Object.preventExtensions({});
|
||||
|
||||
expect(Reflect.defineProperty(o, 'prop', {})).to.equal(false);
|
||||
});
|
||||
|
||||
it('can return true, even for non-configurable, non-writable properties', function () {
|
||||
var o = {};
|
||||
var desc = {
|
||||
value: 13,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: false
|
||||
};
|
||||
|
||||
expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(true);
|
||||
|
||||
// Defined as non-configurable, but descriptor is identical.
|
||||
expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(true);
|
||||
|
||||
desc.value = 37; // Change
|
||||
|
||||
expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(false);
|
||||
});
|
||||
|
||||
it('can change from one property type to another, if configurable', function () {
|
||||
var o = {};
|
||||
|
||||
var desc1 = {
|
||||
set: function () {},
|
||||
configurable: true
|
||||
};
|
||||
|
||||
var desc2 = {
|
||||
value: 13,
|
||||
configurable: false
|
||||
};
|
||||
|
||||
var desc3 = {
|
||||
get: function () {}
|
||||
};
|
||||
|
||||
expect(Reflect.defineProperty(o, 'prop', desc1)).to.equal(true);
|
||||
|
||||
expect(Reflect.defineProperty(o, 'prop', desc2)).to.equal(true);
|
||||
|
||||
expect(Reflect.defineProperty(o, 'prop', desc3)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.deleteProperty()', function () {
|
||||
if (typeof Reflect.deleteProperty === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('deleteProperty');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.deleteProperty).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.deleteProperty.name).to.equal('deleteProperty');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.deleteProperty(item, 'prop');
|
||||
});
|
||||
});
|
||||
|
||||
ifES5It('returns true for success and false for failure', function () {
|
||||
var o = { a: 1 };
|
||||
|
||||
Object.defineProperty(o, 'b', { value: 2 });
|
||||
|
||||
expect(o).to.have.property('a');
|
||||
expect(o).to.have.property('b');
|
||||
expect(o.a).to.equal(1);
|
||||
expect(o.b).to.equal(2);
|
||||
|
||||
expect(Reflect.deleteProperty(o, 'a')).to.equal(true);
|
||||
|
||||
expect(o).not.to.have.property('a');
|
||||
expect(o.b).to.equal(2);
|
||||
|
||||
expect(Reflect.deleteProperty(o, 'b')).to.equal(false);
|
||||
|
||||
expect(o).to.have.property('b');
|
||||
expect(o.b).to.equal(2);
|
||||
|
||||
expect(Reflect.deleteProperty(o, 'a')).to.equal(true);
|
||||
});
|
||||
|
||||
it('cannot delete an array’s length property', function () {
|
||||
expect(Reflect.deleteProperty([], 'length')).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describeIfES5('.get()', function () {
|
||||
if (typeof Reflect.get === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('get');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.get).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.get.name).to.equal('get');
|
||||
});
|
||||
|
||||
it('throws on null and undefined', function () {
|
||||
[null, undefined].forEach(function (item) {
|
||||
expect(function () {
|
||||
return Reflect.get(item, 'property');
|
||||
}).to['throw'](TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
it('can retrieve a simple value, from the target', function () {
|
||||
var p = { something: 2, bool: false };
|
||||
|
||||
expect(Reflect.get(object, 'something')).to.equal(1);
|
||||
// p has no effect
|
||||
expect(Reflect.get(object, 'something', p)).to.equal(1);
|
||||
|
||||
// Value-defined properties take the target's value,
|
||||
// and ignore that of the receiver.
|
||||
expect(Reflect.get(object, 'bool', p)).to.equal(true);
|
||||
|
||||
// Undefined values
|
||||
expect(Reflect.get(object, 'undefined_property')).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('will invoke getters on the receiver rather than target', function () {
|
||||
var other = { _value: 1337 };
|
||||
|
||||
expect(Reflect.get(object, 'value', other)).to.equal(1337);
|
||||
|
||||
// No getter for setter property
|
||||
expect(Reflect.get(object, 'setter', other)).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('will search the prototype chain', function () {
|
||||
var other = Object.create(object);
|
||||
other._value = 17;
|
||||
|
||||
var yetAnother = { _value: 4711 };
|
||||
|
||||
expect(Reflect.get(other, 'value', yetAnother)).to.equal(4711);
|
||||
|
||||
expect(Reflect.get(other, 'bool', yetAnother)).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describeIfES5('.set()', function () {
|
||||
if (typeof Reflect.set === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('set');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.set).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.set.name).to.equal('set');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.set(item, 'prop', 'value');
|
||||
});
|
||||
});
|
||||
|
||||
it('sets values on receiver', function () {
|
||||
var target = {};
|
||||
var receiver = {};
|
||||
|
||||
expect(Reflect.set(target, 'foo', 1, receiver)).to.equal(true);
|
||||
|
||||
expect('foo' in target).to.equal(false);
|
||||
expect(receiver.foo).to.equal(1);
|
||||
|
||||
expect(Reflect.defineProperty(receiver, 'bar', {
|
||||
value: 0,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
})).to.equal(true);
|
||||
|
||||
expect(Reflect.set(target, 'bar', 1, receiver)).to.equal(true);
|
||||
expect(receiver.bar).to.equal(1);
|
||||
expect(Reflect.getOwnPropertyDescriptor(receiver, 'bar').enumerable).to.equal(false);
|
||||
|
||||
var out;
|
||||
/* eslint-disable accessor-pairs */
|
||||
target = Object.create({}, {
|
||||
o: {
|
||||
set: function () { out = this; }
|
||||
}
|
||||
});
|
||||
/* eslint-enable accessor-pairs */
|
||||
|
||||
expect(Reflect.set(target, 'o', 17, receiver)).to.equal(true);
|
||||
expect(out).to.equal(receiver);
|
||||
});
|
||||
});
|
||||
|
||||
describeIfES5('.getOwnPropertyDescriptor()', function () {
|
||||
if (typeof Reflect.getOwnPropertyDescriptor === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('getOwnPropertyDescriptor');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.getOwnPropertyDescriptor).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.getOwnPropertyDescriptor.name).to.equal('getOwnPropertyDescriptor');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.getOwnPropertyDescriptor(item, 'prop');
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves property descriptors', function () {
|
||||
var obj = { a: 4711 };
|
||||
|
||||
var desc = Reflect.getOwnPropertyDescriptor(obj, 'a');
|
||||
|
||||
expect(desc).to.deep.equal({
|
||||
value: 4711,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
enumerable: true
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describeIfGetProto('.getPrototypeOf()', function () {
|
||||
if (typeof Reflect.getPrototypeOf === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('getPrototypeOf');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.getPrototypeOf).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.getPrototypeOf.name).to.equal('getPrototypeOf');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.getPrototypeOf(item);
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves prototypes', function () {
|
||||
expect(Reflect.getPrototypeOf(Object.create(null))).to.equal(null);
|
||||
|
||||
expect(Reflect.getPrototypeOf([])).to.equal(Array.prototype);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.has()', function () {
|
||||
if (typeof Reflect.has === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('has');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.has).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.has.name).to.equal('has');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.has(item, 'prop');
|
||||
});
|
||||
});
|
||||
|
||||
it('will detect own properties', function () {
|
||||
var target = Object.create ? Object.create(null) : {};
|
||||
|
||||
expect(Reflect.has(target, 'prop')).to.equal(false);
|
||||
|
||||
target.prop = undefined;
|
||||
expect(Reflect.has(target, 'prop')).to.equal(true);
|
||||
|
||||
delete target.prop;
|
||||
expect(Reflect.has(target, 'prop')).to.equal(false);
|
||||
|
||||
expect(Reflect.has(Reflect.has, 'length')).to.equal(true);
|
||||
});
|
||||
|
||||
ifES5It('will detect an own accessor property', function () {
|
||||
var target = Object.create(null);
|
||||
/* eslint-disable accessor-pairs */
|
||||
Object.defineProperty(target, 'accessor', {
|
||||
set: function () {}
|
||||
});
|
||||
/* eslint-enable accessor-pairs */
|
||||
|
||||
expect(Reflect.has(target, 'accessor')).to.equal(true);
|
||||
});
|
||||
|
||||
it('will search the prototype chain', function () {
|
||||
var Parent = function () {};
|
||||
Parent.prototype.someProperty = undefined;
|
||||
|
||||
var Child = function () {};
|
||||
Child.prototype = new Parent();
|
||||
|
||||
var target = new Child();
|
||||
target.bool = true;
|
||||
|
||||
expect(Reflect.has(target, 'bool')).to.equal(true);
|
||||
expect(Reflect.has(target, 'someProperty')).to.equal(true);
|
||||
expect(Reflect.has(target, 'undefinedProperty')).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describeIfExtensionsPreventible('.isExtensible()', function () {
|
||||
if (typeof Reflect.isExtensible === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('isExtensible');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.isExtensible).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.isExtensible.name).to.equal('isExtensible');
|
||||
});
|
||||
|
||||
it('returns true for plain objects', function () {
|
||||
expect(Reflect.isExtensible({})).to.equal(true);
|
||||
expect(Reflect.isExtensible(Object.preventExtensions({}))).to.equal(false);
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.isExtensible(item);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describeIfGetOwnPropertyNames('.ownKeys()', function () {
|
||||
if (typeof Reflect.ownKeys === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('ownKeys');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.ownKeys).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.ownKeys.name).to.equal('ownKeys');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.ownKeys(item);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the same result as Object.getOwnPropertyNames if there are no Symbols', function () {
|
||||
var obj = { foo: 1, bar: 2 };
|
||||
|
||||
obj[1] = 'first';
|
||||
|
||||
var result = Object.getOwnPropertyNames(obj);
|
||||
|
||||
// Reflect.ownKeys depends on the implementation of
|
||||
// Object.getOwnPropertyNames, at least for non-symbol keys.
|
||||
expect(Reflect.ownKeys(obj)).to.deep.equal(result);
|
||||
|
||||
// We can only be sure of which keys should exist.
|
||||
expect(result.sort()).to.deep.equal(['1', 'bar', 'foo']);
|
||||
});
|
||||
|
||||
ifSymbolsIt('symbols come last', function () {
|
||||
var s = Symbol();
|
||||
|
||||
var o = {
|
||||
'non-symbol': true
|
||||
};
|
||||
|
||||
o[s] = true;
|
||||
|
||||
expect(Reflect.ownKeys(o)).to.deep.equal(['non-symbol', s]);
|
||||
});
|
||||
});
|
||||
|
||||
describeIfExtensionsPreventible('.preventExtensions()', function () {
|
||||
if (typeof Reflect.preventExtensions === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('preventExtensions');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.preventExtensions).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.preventExtensions.name).to.equal('preventExtensions');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.preventExtensions(item);
|
||||
});
|
||||
});
|
||||
|
||||
it('prevents extensions on objects', function () {
|
||||
var obj = {};
|
||||
Reflect.preventExtensions(obj);
|
||||
expect(Object.isExtensible(obj)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describeIfSetProto('.setPrototypeOf()', function () {
|
||||
if (typeof Reflect.setPrototypeOf === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(Reflect).to.have.property('setPrototypeOf');
|
||||
});
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(typeof Reflect.setPrototypeOf).to.equal('function');
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Reflect.setPrototypeOf.name).to.equal('setPrototypeOf');
|
||||
});
|
||||
|
||||
it('throws if the target isn’t an object', function () {
|
||||
testPrimitiveThrow(function (item) {
|
||||
return Reflect.setPrototypeOf(item, null);
|
||||
});
|
||||
});
|
||||
|
||||
it('throws if the prototype is neither object nor null', function () {
|
||||
var o = {};
|
||||
|
||||
[undefined, 1, 'string', true].forEach(function (item) {
|
||||
expect(function () {
|
||||
return Reflect.setPrototypeOf(o, item);
|
||||
}).to['throw'](TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
it('can set prototypes, and returns true on success', function () {
|
||||
var obj = {};
|
||||
|
||||
expect(Reflect.setPrototypeOf(obj, Array.prototype)).to.equal(true);
|
||||
expect(obj).to.be.an.instanceOf(Array);
|
||||
|
||||
expect(obj.toString).not.to.equal(undefined);
|
||||
expect(Reflect.setPrototypeOf(obj, null)).to.equal(true);
|
||||
expect(obj.toString).to.equal(undefined);
|
||||
});
|
||||
|
||||
ifFreezeIt('is returns false on failure', function () {
|
||||
var obj = Object.freeze({});
|
||||
|
||||
expect(Reflect.setPrototypeOf(obj, null)).to.equal(false);
|
||||
});
|
||||
|
||||
it('fails when attempting to create a circular prototype chain', function () {
|
||||
var o = {};
|
||||
|
||||
expect(Reflect.setPrototypeOf(o, o)).to.equal(false);
|
||||
});
|
||||
});
|
||||
});
|
415
node_modules/es6-shim/test/regexp.js
generated
vendored
Normal file
415
node_modules/es6-shim/test/regexp.js
generated
vendored
Normal file
@ -0,0 +1,415 @@
|
||||
var getRegexLiteral = function (stringRegex) {
|
||||
try {
|
||||
/* jshint evil: true */
|
||||
/* eslint-disable no-new-func */
|
||||
return Function('return ' + stringRegex + ';')();
|
||||
/* eslint-enable no-new-func */
|
||||
/* jshint evil: false */
|
||||
} catch (e) { /**/ }
|
||||
};
|
||||
var describeIfSupportsDescriptors = Object.getOwnPropertyDescriptor ? describe : describe.skip;
|
||||
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 ifSymbolsDescribe = hasSymbols ? describe : describe.skip;
|
||||
var defaultRegex = (function () {
|
||||
// Chrome Canary 51 has an undefined RegExp#toSource, and
|
||||
// RegExp#toString produces `/undefined/`
|
||||
try {
|
||||
return RegExp.prototype.source ? String(RegExp.prototype) : '/(?:)/';
|
||||
} catch (e) {
|
||||
return '/(?:)/';
|
||||
}
|
||||
}());
|
||||
|
||||
describe('RegExp', function () {
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.RegExp).to.equal(RegExp);
|
||||
});
|
||||
|
||||
it('can be called with no arguments', function () {
|
||||
var regex = RegExp();
|
||||
expect(String(regex)).to.equal(defaultRegex);
|
||||
expect(regex).to.be.an.instanceOf(RegExp);
|
||||
});
|
||||
|
||||
it('can be called with null/undefined', function () {
|
||||
expect(String(RegExp(null))).to.equal('/null/');
|
||||
expect(String(RegExp(undefined))).to.equal(defaultRegex);
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
it('allows a regex as the pattern', function () {
|
||||
var a = /a/g;
|
||||
var b = new RegExp(a);
|
||||
if (typeof a !== 'function') {
|
||||
// in browsers like Safari 5, new RegExp with a regex returns the same instance.
|
||||
expect(a).not.to.equal(b);
|
||||
}
|
||||
expect(a).to.eql(b);
|
||||
});
|
||||
|
||||
it('allows a string with flags', function () {
|
||||
expect(new RegExp('a', 'mgi')).to.eql(/a/gim);
|
||||
expect(String(new RegExp('a', 'mgi'))).to.equal('/a/gim');
|
||||
});
|
||||
|
||||
it('allows a regex with flags', function () {
|
||||
var a = /a/g;
|
||||
var makeRegex = function () { return new RegExp(a, 'mi'); };
|
||||
expect(makeRegex).not.to['throw'](TypeError);
|
||||
expect(makeRegex()).to.eql(/a/mi);
|
||||
expect(String(makeRegex())).to.equal('/a/im');
|
||||
});
|
||||
|
||||
it('works with instanceof', function () {
|
||||
expect(/a/g).to.be.an.instanceOf(RegExp);
|
||||
expect(new RegExp('a', 'im')).to.be.an.instanceOf(RegExp);
|
||||
expect(new RegExp(/a/g, 'im')).to.be.an.instanceOf(RegExp);
|
||||
});
|
||||
|
||||
it('has the right constructor', function () {
|
||||
expect(/a/g).to.have.property('constructor', RegExp);
|
||||
expect(new RegExp('a', 'im')).to.have.property('constructor', RegExp);
|
||||
expect(new RegExp(/a/g, 'im')).to.have.property('constructor', RegExp);
|
||||
});
|
||||
|
||||
it('toStrings properly', function () {
|
||||
expect(Object.prototype.toString.call(/a/g)).to.equal('[object RegExp]');
|
||||
expect(Object.prototype.toString.call(new RegExp('a', 'g'))).to.equal('[object RegExp]');
|
||||
expect(Object.prototype.toString.call(new RegExp(/a/g, 'im'))).to.equal('[object RegExp]');
|
||||
});
|
||||
|
||||
it('functions as a boxed primitive wrapper', function () {
|
||||
var regex = /a/g;
|
||||
expect(RegExp(regex)).to.equal(regex);
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.replace', function () {
|
||||
if (!hasSymbols || typeof Symbol.replace === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(RegExp.prototype).to.have.property(Symbol.replace);
|
||||
expect(typeof RegExp.prototype[Symbol.replace]).to.equal('function');
|
||||
});
|
||||
|
||||
it('is the same as String#replace', function () {
|
||||
var regex = /a/g;
|
||||
var str = 'abc';
|
||||
var symbolReplace = regex[Symbol.replace](str);
|
||||
var stringReplace = str.replace(regex);
|
||||
expect(Object.keys(symbolReplace)).to.eql(Object.keys(stringReplace));
|
||||
expect(symbolReplace).to.eql(stringReplace);
|
||||
});
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.search', function () {
|
||||
if (!hasSymbols || typeof Symbol.search === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(RegExp.prototype).to.have.property(Symbol.search);
|
||||
expect(typeof RegExp.prototype[Symbol.search]).to.equal('function');
|
||||
});
|
||||
|
||||
it('is the same as String#search', function () {
|
||||
var regex = /a/g;
|
||||
var str = 'abc';
|
||||
var symbolSearch = regex[Symbol.search](str);
|
||||
var stringSearch = str.search(regex);
|
||||
expect(Object.keys(symbolSearch)).to.eql(Object.keys(stringSearch));
|
||||
expect(symbolSearch).to.eql(stringSearch);
|
||||
});
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.split', function () {
|
||||
if (!hasSymbols || typeof Symbol.split === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('is a function', function () {
|
||||
expect(RegExp.prototype).to.have.property(Symbol.split);
|
||||
expect(typeof RegExp.prototype[Symbol.split]).to.equal('function');
|
||||
});
|
||||
|
||||
it('is the same as String#split', function () {
|
||||
var regex = /a/g;
|
||||
var str = 'abcabc';
|
||||
var symbolSplit = regex[Symbol.split](str, 1);
|
||||
var stringSplit = str.split(regex, 1);
|
||||
expect(Object.keys(symbolSplit)).to.eql(Object.keys(stringSplit));
|
||||
expect(symbolSplit).to.eql(stringSplit);
|
||||
});
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.match', function () {
|
||||
if (!hasSymbols || typeof Symbol.match === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
var regexFalsyMatch;
|
||||
var nonregexTruthyMatch;
|
||||
|
||||
beforeEach(function () {
|
||||
regexFalsyMatch = /./;
|
||||
regexFalsyMatch[Symbol.match] = false;
|
||||
nonregexTruthyMatch = { constructor: RegExp };
|
||||
nonregexTruthyMatch[Symbol.match] = true;
|
||||
});
|
||||
|
||||
it('is a function', function () {
|
||||
expect(RegExp.prototype).to.have.property(Symbol.match);
|
||||
expect(typeof RegExp.prototype[Symbol.match]).to.equal('function');
|
||||
});
|
||||
|
||||
it('is the same as String#match', function () {
|
||||
var regex = /a/g;
|
||||
var str = 'abc';
|
||||
var symbolMatch = regex[Symbol.match](str);
|
||||
var stringMatch = str.match(regex);
|
||||
expect(Object.keys(symbolMatch)).to.eql(Object.keys(stringMatch));
|
||||
expect(symbolMatch).to.eql(stringMatch);
|
||||
});
|
||||
|
||||
it('function does not passthrough regexes with a falsy Symbol.match', function () {
|
||||
expect(RegExp(regexFalsyMatch)).not.to.equal(regexFalsyMatch);
|
||||
});
|
||||
|
||||
it('constructor does not passthrough regexes with a falsy Symbol.match', function () {
|
||||
expect(new RegExp(regexFalsyMatch)).not.to.equal(regexFalsyMatch);
|
||||
});
|
||||
|
||||
it('function passes through non-regexes with a truthy Symbol.match', function () {
|
||||
expect(RegExp(nonregexTruthyMatch)).to.equal(nonregexTruthyMatch);
|
||||
});
|
||||
|
||||
it('constructor does not pass through non-regexes with a truthy Symbol.match', function () {
|
||||
expect(new RegExp(nonregexTruthyMatch)).not.to.equal(nonregexTruthyMatch);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describeIfSupportsDescriptors('#flags', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(RegExp.prototype, 'flags')) {
|
||||
return it('exists', function () {
|
||||
expect(RegExp.prototype).to.have.property('flags');
|
||||
});
|
||||
}
|
||||
|
||||
var regexpFlagsDescriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
|
||||
var testGenericRegExpFlags = function (object) {
|
||||
return regexpFlagsDescriptor.get.call(object);
|
||||
};
|
||||
|
||||
it('has the correct descriptor', function () {
|
||||
expect(regexpFlagsDescriptor.configurable).to.equal(true);
|
||||
expect(regexpFlagsDescriptor.enumerable).to.equal(false);
|
||||
expect(regexpFlagsDescriptor.get instanceof Function).to.equal(true);
|
||||
expect(regexpFlagsDescriptor.set).to.equal(undefined);
|
||||
});
|
||||
|
||||
ifCallAllowsPrimitivesIt('throws when not called on an object', function () {
|
||||
var nonObjects = ['', false, true, 42, NaN, null, undefined];
|
||||
nonObjects.forEach(function (nonObject) {
|
||||
expect(function () { testGenericRegExpFlags(nonObject); }).to['throw'](TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
it('has the correct flags on a literal', function () {
|
||||
expect((/a/g).flags).to.equal('g');
|
||||
expect((/a/i).flags).to.equal('i');
|
||||
expect((/a/m).flags).to.equal('m');
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
|
||||
expect(getRegexLiteral('/a/y').flags).to.equal('y');
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
|
||||
expect(getRegexLiteral('/a/u').flags).to.equal('u');
|
||||
}
|
||||
});
|
||||
|
||||
it('has the correct flags on a constructed 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 (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
|
||||
expect(new RegExp('a', 'y').flags).to.equal('y');
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
|
||||
expect(new RegExp('a', 'u').flags).to.equal('u');
|
||||
}
|
||||
});
|
||||
|
||||
it('returns flags sorted on a literal', function () {
|
||||
expect((/a/gim).flags).to.equal('gim');
|
||||
expect((/a/mig).flags).to.equal('gim');
|
||||
expect((/a/mgi).flags).to.equal('gim');
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
|
||||
expect(getRegexLiteral('/a/gyim').flags).to.equal('gimy');
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
|
||||
expect(getRegexLiteral('/a/ugmi').flags).to.equal('gimu');
|
||||
}
|
||||
});
|
||||
|
||||
it('returns flags sorted on a constructed 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 (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
|
||||
expect(new RegExp('a', 'mygi').flags).to.equal('gimy');
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
|
||||
expect(new RegExp('a', 'mugi').flags).to.equal('gimu');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toString()', function () {
|
||||
it('throws on null/undefined', function () {
|
||||
expect(function () { RegExp.prototype.toString.call(null); }).to['throw'](TypeError);
|
||||
expect(function () { RegExp.prototype.toString.call(undefined); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('works on regexes', function () {
|
||||
expect(RegExp.prototype.toString.call(/a/g)).to.equal('/a/g');
|
||||
expect(RegExp.prototype.toString.call(new RegExp('a', 'g'))).to.equal('/a/g');
|
||||
});
|
||||
|
||||
it('works on non-regexes', function () {
|
||||
expect(RegExp.prototype.toString.call({ source: 'abc', flags: '' })).to.equal('/abc/');
|
||||
expect(RegExp.prototype.toString.call({ source: 'abc', flags: 'xyz' })).to.equal('/abc/xyz');
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.match', function () {
|
||||
if (!hasSymbols || typeof Symbol.match === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('accepts a non-regex with Symbol.match', function () {
|
||||
var obj = { source: 'abc', flags: 'def' };
|
||||
obj[Symbol.match] = RegExp.prototype[Symbol.match];
|
||||
expect(RegExp.prototype.toString.call(obj)).to.equal('/abc/def');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Object properties', function () {
|
||||
it('does not have the nonstandard $input property', function () {
|
||||
expect(RegExp).not.to.have.property('$input'); // Chrome < 39, Opera < 26 have this
|
||||
});
|
||||
|
||||
it('has "input" property', function () {
|
||||
expect(RegExp).to.have.ownProperty('input');
|
||||
expect(RegExp).to.have.ownProperty('$_');
|
||||
});
|
||||
|
||||
it('has "last match" property', function () {
|
||||
expect(RegExp).to.have.ownProperty('lastMatch');
|
||||
expect(RegExp).to.have.ownProperty('$+');
|
||||
});
|
||||
|
||||
it('has "last paren" property', function () {
|
||||
expect(RegExp).to.have.ownProperty('lastParen');
|
||||
expect(RegExp).to.have.ownProperty('$&');
|
||||
});
|
||||
|
||||
it('has "leftContext" property', function () {
|
||||
expect(RegExp).to.have.ownProperty('leftContext');
|
||||
expect(RegExp).to.have.ownProperty('$`');
|
||||
});
|
||||
|
||||
it('has "rightContext" property', function () {
|
||||
expect(RegExp).to.have.ownProperty('rightContext');
|
||||
expect(RegExp).to.have.ownProperty("$'");
|
||||
});
|
||||
|
||||
it.skip('has "multiline" property', function () {
|
||||
// fails in IE 9, 10, 11
|
||||
expect(RegExp).to.have.ownProperty('multiline');
|
||||
expect(RegExp).to.have.ownProperty('$*');
|
||||
});
|
||||
|
||||
it('has the right globals', function () {
|
||||
var matchVars = [
|
||||
'$1',
|
||||
'$2',
|
||||
'$3',
|
||||
'$4',
|
||||
'$5',
|
||||
'$6',
|
||||
'$7',
|
||||
'$8',
|
||||
'$9'
|
||||
];
|
||||
matchVars.forEach(function (match) {
|
||||
expect(RegExp).to.have.property(match);
|
||||
});
|
||||
});
|
||||
|
||||
describe('updates RegExp globals', function () {
|
||||
var str = 'abcdefghijklmnopq';
|
||||
var re;
|
||||
beforeEach(function () {
|
||||
re = /(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)/;
|
||||
re.exec(str);
|
||||
});
|
||||
|
||||
it('has "input"', function () {
|
||||
expect(RegExp.input).to.equal(str);
|
||||
expect(RegExp.$_).to.equal(str);
|
||||
});
|
||||
|
||||
it('has "multiline"', function () {
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp, 'multiline')) {
|
||||
expect(RegExp.multiline).to.equal(false);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(RegExp, '$*')) {
|
||||
expect(RegExp['$*']).to.equal(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('has "lastMatch"', function () {
|
||||
expect(RegExp.lastMatch).to.equal('bcdefghijklmnop');
|
||||
expect(RegExp['$&']).to.equal('bcdefghijklmnop');
|
||||
});
|
||||
|
||||
// in all but IE, this works. IE lastParen breaks after 11 tokens.
|
||||
it.skip('has "lastParen"', function () {
|
||||
expect(RegExp.lastParen).to.equal('p');
|
||||
expect(RegExp['$+']).to.equal('p');
|
||||
});
|
||||
it('has "lastParen" for less than 11 tokens', function () {
|
||||
(/(b)(c)(d)/).exec('abcdef');
|
||||
expect(RegExp.lastParen).to.equal('d');
|
||||
expect(RegExp['$+']).to.equal('d');
|
||||
});
|
||||
|
||||
it('has "leftContext"', function () {
|
||||
expect(RegExp.leftContext).to.equal('a');
|
||||
expect(RegExp['$`']).to.equal('a');
|
||||
});
|
||||
|
||||
it('has "rightContext"', function () {
|
||||
expect(RegExp.rightContext).to.equal('q');
|
||||
expect(RegExp["$'"]).to.equal('q');
|
||||
});
|
||||
|
||||
it('has $1 - $9', function () {
|
||||
expect(RegExp.$1).to.equal('b');
|
||||
expect(RegExp.$2).to.equal('c');
|
||||
expect(RegExp.$3).to.equal('d');
|
||||
expect(RegExp.$4).to.equal('e');
|
||||
expect(RegExp.$5).to.equal('f');
|
||||
expect(RegExp.$6).to.equal('g');
|
||||
expect(RegExp.$7).to.equal('h');
|
||||
expect(RegExp.$8).to.equal('i');
|
||||
expect(RegExp.$9).to.equal('j');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
637
node_modules/es6-shim/test/set.js
generated
vendored
Normal file
637
node_modules/es6-shim/test/set.js
generated
vendored
Normal file
@ -0,0 +1,637 @@
|
||||
// Big thanks to V8 folks for test ideas.
|
||||
// v8/test/mjsunit/harmony/collections.js
|
||||
|
||||
var Assertion = expect().constructor;
|
||||
Assertion.addMethod('theSameSet', function (otherArray) {
|
||||
var array = this._obj;
|
||||
|
||||
expect(Array.isArray(array)).to.equal(true);
|
||||
expect(Array.isArray(otherArray)).to.equal(true);
|
||||
|
||||
var diff = array.filter(function (value) {
|
||||
return otherArray.every(function (otherValue) {
|
||||
var areBothNaN = typeof value === 'number' && typeof otherValue === 'number' && value !== value && otherValue !== otherValue;
|
||||
return !areBothNaN && value !== otherValue;
|
||||
});
|
||||
});
|
||||
|
||||
this.assert(
|
||||
diff.length === 0,
|
||||
'expected #{this} to be equal to #{exp} (as sets, i.e. no order)',
|
||||
array,
|
||||
otherArray
|
||||
);
|
||||
});
|
||||
|
||||
var $iterator$ = typeof Symbol === 'function' ? Symbol.iterator : void 0;
|
||||
if (!$iterator$ && typeof Set === 'function') {
|
||||
$iterator$ = typeof Set['@@iterator'] === 'function' ? '@@iterator' : '_es6-shim iterator_';
|
||||
}
|
||||
|
||||
Assertion.addMethod('iterations', function (expected) {
|
||||
var iterator = this._obj[$iterator$]();
|
||||
|
||||
expect(Array.isArray(expected)).to.equal(true);
|
||||
var expectedValues = expected.slice();
|
||||
|
||||
var result;
|
||||
do {
|
||||
result = iterator.next();
|
||||
expect(result.value).to.eql(expectedValues.shift());
|
||||
} while (!result.done);
|
||||
});
|
||||
|
||||
describe('Set', function () {
|
||||
var functionsHaveNames = (function foo() {}).name === 'foo';
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
|
||||
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
|
||||
|
||||
var range = function (from, to) {
|
||||
var result = [];
|
||||
for (var value = from; value < to; value++) {
|
||||
result.push(value);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype');
|
||||
var expectNotEnumerable = function (object) {
|
||||
if (prototypePropIsEnumerable && typeof object === 'function') {
|
||||
expect(Object.keys(object)).to.eql(['prototype']);
|
||||
} else {
|
||||
expect(Object.keys(object)).to.eql([]);
|
||||
}
|
||||
};
|
||||
|
||||
var Sym = typeof Symbol === 'undefined' ? {} : Symbol;
|
||||
var isSymbol = function (sym) {
|
||||
return typeof Sym === 'function' && typeof sym === 'symbol';
|
||||
};
|
||||
var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit;
|
||||
|
||||
var testSet = function (set, key) {
|
||||
expect(set.has(key)).to.equal(false);
|
||||
expect(set['delete'](key)).to.equal(false);
|
||||
expect(set.add(key)).to.equal(set);
|
||||
expect(set.has(key)).to.equal(true);
|
||||
expect(set['delete'](key)).to.equal(true);
|
||||
expect(set.has(key)).to.equal(false);
|
||||
expect(set.add(key)).to.equal(set); // add it back
|
||||
};
|
||||
|
||||
if (typeof Set === 'undefined') {
|
||||
return it('exists', function () {
|
||||
expect(typeof Set).to.equal('function');
|
||||
});
|
||||
}
|
||||
|
||||
var set;
|
||||
beforeEach(function () {
|
||||
set = new Set();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
set = null;
|
||||
});
|
||||
|
||||
it('set iteration', function () {
|
||||
expect(set.add('a')).to.equal(set);
|
||||
expect(set.add('b')).to.equal(set);
|
||||
expect(set.add('c')).to.equal(set);
|
||||
expect(set.add('d')).to.equal(set);
|
||||
|
||||
var keys = [];
|
||||
var iterator = set.keys();
|
||||
keys.push(iterator.next().value);
|
||||
expect(set['delete']('a')).to.equal(true);
|
||||
expect(set['delete']('b')).to.equal(true);
|
||||
expect(set['delete']('c')).to.equal(true);
|
||||
expect(set.add('e')).to.equal(set);
|
||||
keys.push(iterator.next().value);
|
||||
keys.push(iterator.next().value);
|
||||
|
||||
expect(iterator.next().done).to.equal(true);
|
||||
expect(set.add('f')).to.equal(set);
|
||||
expect(iterator.next().done).to.equal(true);
|
||||
expect(keys).to.eql(['a', 'd', 'e']);
|
||||
});
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.Set).to.equal(Set);
|
||||
});
|
||||
|
||||
it('should exist in global namespace', function () {
|
||||
expect(typeof Set).to.equal('function');
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Set).to.have.property('length', 0);
|
||||
});
|
||||
|
||||
it('returns the set from #add() for chaining', function () {
|
||||
expect(set.add({})).to.equal(set);
|
||||
});
|
||||
|
||||
it('should return false when deleting an item not in the set', function () {
|
||||
expect(set.has('a')).to.equal(false);
|
||||
expect(set['delete']('a')).to.equal(false);
|
||||
});
|
||||
|
||||
it('should accept an iterable as argument', function () {
|
||||
testSet(set, 'a');
|
||||
testSet(set, 'b');
|
||||
var set2 = new Set(set);
|
||||
expect(set2.has('a')).to.equal(true);
|
||||
expect(set2.has('b')).to.equal(true);
|
||||
expect(set2).to.have.iterations(['a', 'b']);
|
||||
});
|
||||
|
||||
it('accepts an array as an argument', function () {
|
||||
var arr = ['a', 'b', 'c'];
|
||||
var setFromArray = new Set(arr);
|
||||
expect(setFromArray).to.have.iterations(['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
it('should not be callable without "new"', function () {
|
||||
expect(Set).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('should be subclassable', function () {
|
||||
if (!Object.setPrototypeOf) { return; } // skip test if on IE < 11
|
||||
var MySet = function MySet() {
|
||||
var actualSet = new Set(['a', 'b']);
|
||||
Object.setPrototypeOf(actualSet, MySet.prototype);
|
||||
return actualSet;
|
||||
};
|
||||
Object.setPrototypeOf(MySet, Set);
|
||||
MySet.prototype = Object.create(Set.prototype, {
|
||||
constructor: { value: MySet }
|
||||
});
|
||||
|
||||
var mySet = new MySet();
|
||||
testSet(mySet, 'c');
|
||||
testSet(mySet, 'd');
|
||||
expect(mySet).to.have.iterations(['a', 'b', 'c', 'd']);
|
||||
});
|
||||
|
||||
it('should has valid getter and setter calls', function () {
|
||||
['add', 'has', 'delete'].forEach(function (method) {
|
||||
expect(function () {
|
||||
set[method]({});
|
||||
}).to.not['throw']();
|
||||
});
|
||||
});
|
||||
|
||||
it('uses SameValueZero even on a Set of size > 4', function () {
|
||||
var firstFour = [1, 2, 3, 4];
|
||||
var fourSet = new Set(firstFour);
|
||||
expect(fourSet.size).to.equal(4);
|
||||
expect(fourSet.has(-0)).to.equal(false);
|
||||
expect(fourSet.has(0)).to.equal(false);
|
||||
|
||||
fourSet.add(-0);
|
||||
|
||||
expect(fourSet.size).to.equal(5);
|
||||
expect(fourSet.has(0)).to.equal(true);
|
||||
expect(fourSet.has(-0)).to.equal(true);
|
||||
});
|
||||
|
||||
it('should work as expected', function () {
|
||||
// Run this test twice, one with the "fast" implementation (which only
|
||||
// allows string and numeric keys) and once with the "slow" impl.
|
||||
[true, false].forEach(function (slowkeys) {
|
||||
set = new Set();
|
||||
|
||||
range(1, 20).forEach(function (number) {
|
||||
if (slowkeys) { testSet(set, {}); }
|
||||
testSet(set, number);
|
||||
testSet(set, number / 100);
|
||||
testSet(set, 'key-' + number);
|
||||
testSet(set, String(number));
|
||||
if (slowkeys) { testSet(set, Object(String(number))); }
|
||||
});
|
||||
|
||||
var testkeys = [+0, Infinity, -Infinity, NaN];
|
||||
if (slowkeys) {
|
||||
testkeys.push(true, false, null, undefined);
|
||||
}
|
||||
testkeys.forEach(function (number) {
|
||||
testSet(set, number);
|
||||
testSet(set, String(number));
|
||||
});
|
||||
testSet(set, '');
|
||||
|
||||
// -0 and +0 should be the same key (Set uses SameValueZero)
|
||||
expect(set.has(-0)).to.equal(true);
|
||||
expect(set['delete'](+0)).to.equal(true);
|
||||
testSet(set, -0);
|
||||
expect(set.has(+0)).to.equal(true);
|
||||
|
||||
// verify that properties of Object don't peek through.
|
||||
[
|
||||
'hasOwnProperty',
|
||||
'constructor',
|
||||
'toString',
|
||||
'isPrototypeOf',
|
||||
'__proto__',
|
||||
'__parent__',
|
||||
'__count__'
|
||||
].forEach(function (prop) { testSet(set, prop); });
|
||||
});
|
||||
});
|
||||
|
||||
describe('#size', function () {
|
||||
it('returns the expected size', function () {
|
||||
expect(set.add(1)).to.equal(set);
|
||||
expect(set.add(5)).to.equal(set);
|
||||
expect(set.size).to.equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#clear()', function () {
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Set.prototype.clear).to.have.property('name', 'clear');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Set.prototype).ownPropertyDescriptor('clear').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Set.prototype.clear).to.have.property('length', 0);
|
||||
});
|
||||
|
||||
it('clears a Set with only primitives', function () {
|
||||
expect(set.add(1)).to.equal(set);
|
||||
expect(set.size).to.equal(1);
|
||||
expect(set.add(5)).to.equal(set);
|
||||
expect(set.size).to.equal(2);
|
||||
expect(set.has(5)).to.equal(true);
|
||||
set.clear();
|
||||
expect(set.size).to.equal(0);
|
||||
expect(set.has(5)).to.equal(false);
|
||||
});
|
||||
|
||||
it('clears a Set with primitives and objects', function () {
|
||||
expect(set.add(1)).to.equal(set);
|
||||
expect(set.size).to.equal(1);
|
||||
var obj = {};
|
||||
expect(set.add(obj)).to.equal(set);
|
||||
expect(set.size).to.equal(2);
|
||||
expect(set.has(obj)).to.equal(true);
|
||||
set.clear();
|
||||
expect(set.size).to.equal(0);
|
||||
expect(set.has(obj)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#keys()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'keys')) {
|
||||
return it('exists', function () {
|
||||
expect(Set.prototype).to.have.property('keys');
|
||||
});
|
||||
}
|
||||
|
||||
it('is the same object as #values()', function () {
|
||||
expect(Set.prototype.keys).to.equal(Set.prototype.values);
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Set.prototype.keys).to.have.property('name', 'values');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Set.prototype).ownPropertyDescriptor('keys').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Set.prototype.keys).to.have.property('length', 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#values()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'values')) {
|
||||
return it('exists', function () {
|
||||
expect(Set.prototype).to.have.property('values');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Set.prototype.values).to.have.property('name', 'values');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Set.prototype).ownPropertyDescriptor('values').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Set.prototype.values).to.have.property('length', 0);
|
||||
});
|
||||
|
||||
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$|^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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#entries()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'entries')) {
|
||||
return it('exists', function () {
|
||||
expect(Set.prototype).to.have.property('entries');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Set.prototype.entries).to.have.property('name', 'entries');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Set.prototype).ownPropertyDescriptor('entries').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Set.prototype.entries).to.have.property('length', 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#has()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'has')) {
|
||||
return it('exists', function () {
|
||||
expect(Set.prototype).to.have.property('has');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Set.prototype.has).to.have.property('name', 'has');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Set.prototype).ownPropertyDescriptor('has').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Set.prototype.has).to.have.property('length', 1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow NaN values as keys', function () {
|
||||
expect(set.has(NaN)).to.equal(false);
|
||||
expect(set.has(NaN + 1)).to.equal(false);
|
||||
expect(set.has(23)).to.equal(false);
|
||||
expect(set.add(NaN)).to.equal(set);
|
||||
expect(set.has(NaN)).to.equal(true);
|
||||
expect(set.has(NaN + 1)).to.equal(true);
|
||||
expect(set.has(23)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should not have [[Enumerable]] props', function () {
|
||||
expectNotEnumerable(Set);
|
||||
expectNotEnumerable(Set.prototype);
|
||||
expectNotEnumerable(new Set());
|
||||
});
|
||||
|
||||
it('should not have an own constructor', function () {
|
||||
var s = new Set();
|
||||
expect(s).not.to.haveOwnPropertyDescriptor('constructor');
|
||||
expect(s.constructor).to.equal(Set);
|
||||
});
|
||||
|
||||
it('should allow common ecmascript idioms', function () {
|
||||
expect(set instanceof Set).to.equal(true);
|
||||
expect(typeof Set.prototype.add).to.equal('function');
|
||||
expect(typeof Set.prototype.has).to.equal('function');
|
||||
expect(typeof Set.prototype['delete']).to.equal('function');
|
||||
});
|
||||
|
||||
it('should have a unique constructor', function () {
|
||||
expect(Set.prototype).to.not.equal(Object.prototype);
|
||||
});
|
||||
|
||||
describe('has an iterator that works with Array.from', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Array, 'from')) {
|
||||
return it('requires Array.from to exist', function () {
|
||||
expect(Array).to.have.property('from');
|
||||
});
|
||||
}
|
||||
|
||||
var values = [1, NaN, false, true, null, undefined, 'a'];
|
||||
|
||||
it('works with the full set', function () {
|
||||
expect(new Set(values)).to.have.iterations(values);
|
||||
});
|
||||
|
||||
it('works with Set#keys()', function () {
|
||||
expect(new Set(values).keys()).to.have.iterations(values);
|
||||
});
|
||||
|
||||
it('works with Set#values()', function () {
|
||||
expect(new Set(values).values()).to.have.iterations(values);
|
||||
});
|
||||
|
||||
it('works with Set#entries()', function () {
|
||||
expect(new Set(values).entries()).to.have.iterations([
|
||||
[1, 1],
|
||||
[NaN, NaN],
|
||||
[false, false],
|
||||
[true, true],
|
||||
[null, null],
|
||||
[undefined, undefined],
|
||||
['a', 'a']
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
ifSymbolIteratorIt('has the right default iteration function', function () {
|
||||
// fixed in Webkit https://bugs.webkit.org/show_bug.cgi?id=143838
|
||||
expect(Set.prototype).to.have.property(Sym.iterator, Set.prototype.values);
|
||||
});
|
||||
|
||||
it('should preserve insertion order', function () {
|
||||
var arr1 = ['d', 'a', 'b'];
|
||||
var arr2 = [3, 2, 'z', 'a', 1];
|
||||
var arr3 = [3, 2, 'z', {}, 'a', 1];
|
||||
|
||||
[arr1, arr2, arr3].forEach(function (array) {
|
||||
expect(new Set(array)).to.have.iterations(array);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#forEach', function () {
|
||||
var setToIterate;
|
||||
beforeEach(function () {
|
||||
setToIterate = new Set();
|
||||
expect(setToIterate.add('a')).to.equal(setToIterate);
|
||||
expect(setToIterate.add('b')).to.equal(setToIterate);
|
||||
expect(setToIterate.add('c')).to.equal(setToIterate);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
setToIterate = null;
|
||||
});
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(Set.prototype.forEach).to.have.property('name', 'forEach');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(Set.prototype).ownPropertyDescriptor('forEach').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(Set.prototype.forEach).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should be iterable via forEach', function () {
|
||||
var expectedSet = ['a', 'b', 'c'];
|
||||
var foundSet = [];
|
||||
setToIterate.forEach(function (value, alsoValue, entireSet) {
|
||||
expect(entireSet).to.equal(setToIterate);
|
||||
expect(value).to.equal(alsoValue);
|
||||
foundSet.push(value);
|
||||
});
|
||||
expect(foundSet).to.eql(expectedSet);
|
||||
});
|
||||
|
||||
it('should iterate over empty keys', function () {
|
||||
var setWithEmptyKeys = new Set();
|
||||
var expectedKeys = [{}, null, undefined, '', NaN, 0];
|
||||
expectedKeys.forEach(function (key) {
|
||||
expect(setWithEmptyKeys.add(key)).to.equal(setWithEmptyKeys);
|
||||
});
|
||||
var foundKeys = [];
|
||||
setWithEmptyKeys.forEach(function (value, key, entireSet) {
|
||||
expect([key]).to.be.theSameSet([value]); // handles NaN correctly
|
||||
expect(entireSet.has(key)).to.equal(true);
|
||||
foundKeys.push(key);
|
||||
});
|
||||
expect(foundKeys).to.be.theSameSet(expectedKeys);
|
||||
});
|
||||
|
||||
it('should support the thisArg', function () {
|
||||
var context = function () {};
|
||||
setToIterate.forEach(function () {
|
||||
expect(this).to.equal(context);
|
||||
}, context);
|
||||
});
|
||||
|
||||
it('should have a length of 1', function () {
|
||||
expect(Set.prototype.forEach.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('should not revisit modified keys', function () {
|
||||
var hasModifiedA = false;
|
||||
setToIterate.forEach(function (value, key) {
|
||||
if (!hasModifiedA && key === 'a') {
|
||||
expect(setToIterate.add('a')).to.equal(setToIterate);
|
||||
hasModifiedA = true;
|
||||
} else {
|
||||
expect(key).not.to.equal('a');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('visits keys added in the iterator', function () {
|
||||
var hasAdded = false;
|
||||
var hasFoundD = false;
|
||||
setToIterate.forEach(function (value, key) {
|
||||
if (!hasAdded) {
|
||||
expect(setToIterate.add('d')).to.equal(setToIterate);
|
||||
hasAdded = true;
|
||||
} else if (key === 'd') {
|
||||
hasFoundD = true;
|
||||
}
|
||||
});
|
||||
expect(hasFoundD).to.equal(true);
|
||||
});
|
||||
|
||||
it('visits keys added in the iterator when there is a deletion (slow path)', function () {
|
||||
var hasSeenFour = false;
|
||||
var setToMutate = new Set();
|
||||
expect(setToMutate.add({})).to.equal(setToMutate); // force use of the slow O(N) implementation
|
||||
expect(setToMutate.add('0')).to.equal(setToMutate);
|
||||
setToMutate.forEach(function (value, key) {
|
||||
if (key === '0') {
|
||||
expect(setToMutate['delete']('0')).to.equal(true);
|
||||
expect(setToMutate.add('4')).to.equal(setToMutate);
|
||||
} else if (key === '4') {
|
||||
hasSeenFour = true;
|
||||
}
|
||||
});
|
||||
expect(hasSeenFour).to.equal(true);
|
||||
});
|
||||
|
||||
it('visits keys added in the iterator when there is a deletion (fast path)', function () {
|
||||
var hasSeenFour = false;
|
||||
var setToMutate = new Set();
|
||||
expect(setToMutate.add('0')).to.equal(setToMutate);
|
||||
setToMutate.forEach(function (value, key) {
|
||||
if (key === '0') {
|
||||
expect(setToMutate['delete']('0')).to.equal(true);
|
||||
expect(setToMutate.add('4')).to.equal(setToMutate);
|
||||
} else if (key === '4') {
|
||||
hasSeenFour = true;
|
||||
}
|
||||
});
|
||||
expect(hasSeenFour).to.equal(true);
|
||||
});
|
||||
|
||||
it('does not visit keys deleted before a visit', function () {
|
||||
var hasVisitedC = false;
|
||||
var hasDeletedC = false;
|
||||
setToIterate.forEach(function (value, key) {
|
||||
if (key === 'c') {
|
||||
hasVisitedC = true;
|
||||
}
|
||||
if (!hasVisitedC && !hasDeletedC) {
|
||||
hasDeletedC = setToIterate['delete']('c');
|
||||
expect(hasDeletedC).to.equal(true);
|
||||
}
|
||||
});
|
||||
expect(hasVisitedC).to.equal(false);
|
||||
});
|
||||
|
||||
it('should work after deletion of the current key', function () {
|
||||
var expectedSet = {
|
||||
a: 'a',
|
||||
b: 'b',
|
||||
c: 'c'
|
||||
};
|
||||
var foundSet = {};
|
||||
setToIterate.forEach(function (value, key) {
|
||||
foundSet[key] = value;
|
||||
expect(setToIterate['delete'](key)).to.equal(true);
|
||||
});
|
||||
expect(foundSet).to.eql(expectedSet);
|
||||
});
|
||||
|
||||
it('should convert key -0 to +0', function () {
|
||||
var zeroSet = new Set();
|
||||
var result = [];
|
||||
expect(zeroSet.add(-0)).to.equal(zeroSet);
|
||||
zeroSet.forEach(function (key) {
|
||||
result.push(String(1 / key));
|
||||
});
|
||||
expect(zeroSet.add(1)).to.equal(zeroSet);
|
||||
expect(zeroSet.add(0)).to.equal(zeroSet); // shouldn't cause reordering
|
||||
zeroSet.forEach(function (key) {
|
||||
result.push(String(1 / key));
|
||||
});
|
||||
expect(result.join(', ')).to.equal(
|
||||
'Infinity, Infinity, 1'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Set.prototype.size should throw TypeError', function () {
|
||||
// see https://github.com/paulmillr/es6-shim/issues/176
|
||||
expect(function () { return Set.prototype.size; }).to['throw'](TypeError);
|
||||
expect(function () { return Set.prototype.size; }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it.skip('should throw proper errors when user invokes methods with wrong types of receiver', function () {
|
||||
});
|
||||
});
|
929
node_modules/es6-shim/test/string.js
generated
vendored
Normal file
929
node_modules/es6-shim/test/string.js
generated
vendored
Normal file
@ -0,0 +1,929 @@
|
||||
var runStringTests = function (it) {
|
||||
'use strict';
|
||||
|
||||
var functionsHaveNames = (function foo() {}).name === 'foo';
|
||||
var ifFunctionsHaveNamesIt = functionsHaveNames ? 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.iterator === 'symbol';
|
||||
var ifSymbolsDescribe = hasSymbols ? describe : describe.skip;
|
||||
|
||||
describe('String', function () {
|
||||
var hasStrictMode = (function () { return this === null; }.call(null));
|
||||
var testObjectCoercible = function (methodName) {
|
||||
var fn = String.prototype[methodName];
|
||||
if (!hasStrictMode) { return; } // skip these tests on IE <= 10
|
||||
expect(function () { return fn.call(undefined); }).to['throw'](TypeError);
|
||||
expect(function () { return fn.call(null); }).to['throw'](TypeError);
|
||||
expect(function () { return fn.apply(undefined); }).to['throw'](TypeError);
|
||||
expect(function () { return fn.apply(null); }).to['throw'](TypeError);
|
||||
};
|
||||
|
||||
ifShimIt('is on the exported object', function () {
|
||||
var exported = require('../');
|
||||
expect(exported.String).to.equal(String);
|
||||
});
|
||||
|
||||
describe('#repeat()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'repeat')) {
|
||||
return it('exists', function () {
|
||||
expect(String.prototype).to.have.property('repeat');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.prototype.repeat).to.have.property('name', 'repeat');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String.prototype).ownPropertyDescriptor('repeat').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(String.prototype.repeat).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should throw a TypeError when called on null or undefined', function () {
|
||||
testObjectCoercible('repeat');
|
||||
});
|
||||
|
||||
it('should throw a RangeError when negative or infinite', function () {
|
||||
expect(function negativeOne() { return 'test'.repeat(-1); }).to['throw'](RangeError);
|
||||
expect(function infinite() { return 'test'.repeat(Infinity); }).to['throw'](RangeError);
|
||||
});
|
||||
|
||||
it('should coerce to an integer', function () {
|
||||
expect('test'.repeat(null)).to.eql('');
|
||||
expect('test'.repeat(false)).to.eql('');
|
||||
expect('test'.repeat('')).to.eql('');
|
||||
expect('test'.repeat(NaN)).to.eql('');
|
||||
expect('test'.repeat({})).to.eql('');
|
||||
expect('test'.repeat([])).to.eql('');
|
||||
expect('test'.repeat({
|
||||
valueOf: function () { return 2; }
|
||||
})).to.eql('testtest');
|
||||
});
|
||||
it('should work', function () {
|
||||
expect('test'.repeat(3)).to.eql('testtesttest');
|
||||
});
|
||||
it('should work on integers', function () {
|
||||
expect(String.prototype.repeat.call(2, 3)).to.eql('222');
|
||||
});
|
||||
it('should work on booleans', function () {
|
||||
expect(String.prototype.repeat.call(true, 3)).to.eql('truetruetrue');
|
||||
});
|
||||
it('should work on dates', function () {
|
||||
var d = new Date();
|
||||
expect(String.prototype.repeat.call(d, 3)).to.eql([d, d, d].join(''));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#startsWith()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'startsWith')) {
|
||||
return it('exists', function () {
|
||||
expect(String.prototype).to.have.property('startsWith');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.prototype.startsWith).to.have.property('name', 'startsWith');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String.prototype).ownPropertyDescriptor('startsWith').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
// WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659
|
||||
expect(String.prototype.startsWith).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should throw a TypeError when called on null or undefined', function () {
|
||||
testObjectCoercible('startsWith');
|
||||
});
|
||||
|
||||
it('should throw a TypeError when called on null or undefined', function () {
|
||||
testObjectCoercible('startsWith');
|
||||
});
|
||||
|
||||
it('should be truthy on correct results', function () {
|
||||
expect('test'.startsWith('te')).to.equal(true);
|
||||
expect('test'.startsWith('st')).to.equal(false);
|
||||
expect(''.startsWith('/')).to.equal(false);
|
||||
expect('#'.startsWith('/')).to.equal(false);
|
||||
expect('##'.startsWith('///')).to.equal(false);
|
||||
|
||||
expect('abc'.startsWith('abc')).to.equal(true);
|
||||
expect('abcd'.startsWith('abc')).to.equal(true);
|
||||
expect('abc'.startsWith('a')).to.equal(true);
|
||||
expect('abc'.startsWith('abcd')).to.equal(false);
|
||||
expect('abc'.startsWith('bcde')).to.equal(false);
|
||||
expect('abc'.startsWith('b')).to.equal(false);
|
||||
expect('abc'.startsWith('abc', 0)).to.equal(true);
|
||||
expect('abc'.startsWith('bc', 0)).to.equal(false);
|
||||
expect('abc'.startsWith('bc', 1)).to.equal(true);
|
||||
expect('abc'.startsWith('c', 1)).to.equal(false);
|
||||
expect('abc'.startsWith('abc', 1)).to.equal(false);
|
||||
expect('abc'.startsWith('c', 2)).to.equal(true);
|
||||
expect('abc'.startsWith('d', 2)).to.equal(false);
|
||||
expect('abc'.startsWith('dcd', 2)).to.equal(false);
|
||||
expect('abc'.startsWith('a', NaN)).to.equal(true);
|
||||
expect('abc'.startsWith('b', NaN)).to.equal(false);
|
||||
expect('abc'.startsWith('ab', -43)).to.equal(true);
|
||||
expect('abc'.startsWith('ab', -Infinity)).to.equal(true);
|
||||
expect('abc'.startsWith('bc', -42)).to.equal(false);
|
||||
expect('abc'.startsWith('bc', -Infinity)).to.equal(false);
|
||||
if (hasStrictMode) {
|
||||
expect(function () {
|
||||
return ''.startsWith.call(null, 'nu');
|
||||
}).to['throw'](TypeError);
|
||||
expect(function () {
|
||||
return ''.startsWith.call(undefined, 'un');
|
||||
}).to['throw'](TypeError);
|
||||
}
|
||||
var myobj = {
|
||||
toString: function () { return 'abc'; },
|
||||
startsWith: String.prototype.startsWith
|
||||
};
|
||||
expect(myobj.startsWith('abc')).to.equal(true);
|
||||
expect(myobj.startsWith('bc')).to.equal(false);
|
||||
|
||||
var gotStr = false;
|
||||
var gotPos = false;
|
||||
|
||||
myobj = {
|
||||
toString: function () {
|
||||
expect(gotPos).to.equal(false);
|
||||
gotStr = true;
|
||||
return 'xyz';
|
||||
},
|
||||
startsWith: String.prototype.startsWith
|
||||
};
|
||||
var idx = {
|
||||
valueOf: function () {
|
||||
expect(gotStr).to.equal(true);
|
||||
gotPos = true;
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
myobj.startsWith('elephant', idx);
|
||||
expect(gotPos).to.equal(true);
|
||||
});
|
||||
|
||||
it('should handle large positions', function () {
|
||||
expect('abc'.startsWith('a', 42)).to.equal(false);
|
||||
expect('abc'.startsWith('a', Infinity)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should coerce to a string', function () {
|
||||
expect('abcd'.startsWith({ toString: function () { return 'ab'; } })).to.equal(true);
|
||||
expect('abcd'.startsWith({ toString: function () { return 'foo'; } })).to.equal(false);
|
||||
});
|
||||
|
||||
it('should not allow a regex', function () {
|
||||
expect(function () { return 'abcd'.startsWith(/abc/); }).to['throw'](TypeError);
|
||||
expect(function () { return 'abcd'.startsWith(new RegExp('abc')); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.match', function () {
|
||||
if (!hasSymbols || !Symbol.match) {
|
||||
return it('exists', function () {
|
||||
expect(Symbol).to.have.property('match');
|
||||
});
|
||||
}
|
||||
|
||||
it('allows a regex with Symbol.match set to a falsy value', function () {
|
||||
var re = /a/g;
|
||||
re[Symbol.match] = false;
|
||||
expect(function () { return 'abcd'.startsWith(re); }).not.to['throw']();
|
||||
expect('abcd'.startsWith(re)).to.equal('abcd'.startsWith(String(re)));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#endsWith()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'endsWith')) {
|
||||
return it('exists', function () {
|
||||
expect(String.prototype).to.have.property('endsWith');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.prototype.endsWith).to.have.property('name', 'endsWith');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String.prototype).ownPropertyDescriptor('endsWith').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
// WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659
|
||||
expect(String.prototype.endsWith).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should throw a TypeError when called on null or undefined', function () {
|
||||
testObjectCoercible('endsWith');
|
||||
});
|
||||
|
||||
it('should be truthy on correct results', function () {
|
||||
expect('test'.endsWith('st')).to.equal(true);
|
||||
expect('test'.endsWith('te')).to.equal(false);
|
||||
expect(''.endsWith('/')).to.equal(false);
|
||||
expect('#'.endsWith('/')).to.equal(false);
|
||||
expect('##'.endsWith('///')).to.equal(false);
|
||||
|
||||
expect('abc'.endsWith('abc')).to.equal(true);
|
||||
expect('abcd'.endsWith('bcd')).to.equal(true);
|
||||
expect('abc'.endsWith('c')).to.equal(true);
|
||||
expect('abc'.endsWith('abcd')).to.equal(false);
|
||||
expect('abc'.endsWith('bbc')).to.equal(false);
|
||||
expect('abc'.endsWith('b')).to.equal(false);
|
||||
expect('abc'.endsWith('abc', 3)).to.equal(true);
|
||||
expect('abc'.endsWith('bc', 3)).to.equal(true);
|
||||
expect('abc'.endsWith('a', 3)).to.equal(false);
|
||||
expect('abc'.endsWith('bc', 3)).to.equal(true);
|
||||
expect('abc'.endsWith('a', 1)).to.equal(true);
|
||||
expect('abc'.endsWith('abc', 1)).to.equal(false);
|
||||
expect('abc'.endsWith('b', 2)).to.equal(true);
|
||||
expect('abc'.endsWith('d', 2)).to.equal(false);
|
||||
expect('abc'.endsWith('dcd', 2)).to.equal(false);
|
||||
expect('abc'.endsWith('bc', undefined)).to.equal(true);
|
||||
expect('abc'.endsWith('bc', NaN)).to.equal(false);
|
||||
if (hasStrictMode) {
|
||||
expect(function () {
|
||||
return ''.endsWith.call(null, 'ull');
|
||||
}).to['throw'](TypeError);
|
||||
expect(function () {
|
||||
return ''.endsWith.call(undefined, 'ned');
|
||||
}).to['throw'](TypeError);
|
||||
}
|
||||
|
||||
var myobj = {
|
||||
toString: function () { return 'abc'; },
|
||||
endsWith: String.prototype.endsWith
|
||||
};
|
||||
expect(myobj.endsWith('abc')).to.equal(true);
|
||||
expect(myobj.endsWith('ab')).to.equal(false);
|
||||
var gotStr = false;
|
||||
var gotPos = false;
|
||||
|
||||
myobj = {
|
||||
toString: function () {
|
||||
expect(gotPos).to.equal(false);
|
||||
gotStr = true;
|
||||
return 'xyz';
|
||||
},
|
||||
endsWith: String.prototype.endsWith
|
||||
};
|
||||
var idx = {
|
||||
valueOf: function () {
|
||||
expect(gotStr).to.equal(true);
|
||||
gotPos = true;
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
myobj.endsWith('elephant', idx);
|
||||
expect(gotPos).to.equal(true);
|
||||
});
|
||||
|
||||
it('should coerce to a string', function () {
|
||||
expect('abcd'.endsWith({ toString: function () { return 'cd'; } })).to.equal(true);
|
||||
expect('abcd'.endsWith({ toString: function () { return 'foo'; } })).to.equal(false);
|
||||
});
|
||||
|
||||
it('should not allow a regex', function () {
|
||||
expect(function () { return 'abcd'.endsWith(/abc/); }).to['throw'](TypeError);
|
||||
expect(function () { return 'abcd'.endsWith(new RegExp('abc')); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('should handle negative and zero endPositions properly', function () {
|
||||
expect('abcd'.endsWith('bcd', 0)).to.equal(false);
|
||||
expect('abcd'.endsWith('bcd', -2)).to.equal(false);
|
||||
expect('abcd'.endsWith('b', -2)).to.equal(false);
|
||||
expect('abcd'.endsWith('ab', -2)).to.equal(false);
|
||||
expect('abc'.endsWith('bc', -43)).to.equal(false);
|
||||
expect('abc'.endsWith('bc', -Infinity)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should handle large endPositions properly', function () {
|
||||
expect('abc'.endsWith('a', 42)).to.equal(false);
|
||||
expect('abc'.endsWith('bc', Infinity)).to.equal(true);
|
||||
expect('abc'.endsWith('a', Infinity)).to.equal(false);
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.match', function () {
|
||||
if (!hasSymbols || !Symbol.match) {
|
||||
return it('exists', function () {
|
||||
expect(Symbol).to.have.property('match');
|
||||
});
|
||||
}
|
||||
|
||||
it('allows a regex with Symbol.match set to a falsy value', function () {
|
||||
var re = /a/g;
|
||||
re[Symbol.match] = false;
|
||||
expect(function () { return 'abcd'.startsWith(re); }).not.to['throw']();
|
||||
expect('abcd'.endsWith(re)).to.equal('abcd'.endsWith(String(re)));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#includes()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'includes')) {
|
||||
return it('exists', function () {
|
||||
expect(String.prototype).to.have.property('includes');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.prototype.includes).to.have.property('name', 'includes');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String.prototype).ownPropertyDescriptor('includes').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
// WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659
|
||||
expect(String.prototype.includes).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should throw a TypeError when called on null or undefined', function () {
|
||||
testObjectCoercible('includes');
|
||||
});
|
||||
|
||||
it('throws a TypeError when given a regex', function () {
|
||||
expect(function () { 'foo'.includes(/a/g); }).to['throw'](TypeError);
|
||||
});
|
||||
|
||||
it('should be truthy on correct results', function () {
|
||||
expect('test'.includes('es')).to.equal(true);
|
||||
expect('abc'.includes('a')).to.equal(true);
|
||||
expect('abc'.includes('b')).to.equal(true);
|
||||
expect('abc'.includes('abc')).to.equal(true);
|
||||
expect('abc'.includes('bc')).to.equal(true);
|
||||
expect('abc'.includes('d')).to.equal(false);
|
||||
expect('abc'.includes('abcd')).to.equal(false);
|
||||
expect('abc'.includes('ac')).to.equal(false);
|
||||
expect('abc'.includes('abc', 0)).to.equal(true);
|
||||
expect('abc'.includes('bc', 0)).to.equal(true);
|
||||
expect('abc'.includes('de', 0)).to.equal(false);
|
||||
expect('abc'.includes('bc', 1)).to.equal(true);
|
||||
expect('abc'.includes('c', 1)).to.equal(true);
|
||||
expect('abc'.includes('a', 1)).to.equal(false);
|
||||
expect('abc'.includes('abc', 1)).to.equal(false);
|
||||
expect('abc'.includes('c', 2)).to.equal(true);
|
||||
expect('abc'.includes('d', 2)).to.equal(false);
|
||||
expect('abc'.includes('dcd', 2)).to.equal(false);
|
||||
expect('abc'.includes('ab', NaN)).to.equal(true);
|
||||
expect('abc'.includes('cd', NaN)).to.equal(false);
|
||||
|
||||
var myobj = {
|
||||
toString: function () { return 'abc'; },
|
||||
includes: String.prototype.includes
|
||||
};
|
||||
|
||||
expect(myobj.includes('abc')).to.equal(true);
|
||||
expect(myobj.includes('cd')).to.equal(false);
|
||||
|
||||
var gotStr = false;
|
||||
var gotPos = false;
|
||||
|
||||
myobj = {
|
||||
toString: function () {
|
||||
expect(gotPos).to.equal(false);
|
||||
gotStr = true;
|
||||
return 'xyz';
|
||||
},
|
||||
|
||||
includes: String.prototype.includes
|
||||
};
|
||||
|
||||
var idx = {
|
||||
valueOf: function () {
|
||||
expect(gotStr).to.equal(true);
|
||||
gotPos = true;
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
|
||||
myobj.includes('elephant', idx);
|
||||
expect(gotPos).to.equal(true);
|
||||
});
|
||||
|
||||
it('should handle large positions', function () {
|
||||
expect('abc'.includes('a', 42)).to.equal(false);
|
||||
expect('abc'.includes('a', Infinity)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should handle negative positions', function () {
|
||||
expect('abc'.includes('ab', -43)).to.equal(true);
|
||||
expect('abc'.includes('cd', -42)).to.equal(false);
|
||||
expect('abc'.includes('ab', -Infinity)).to.equal(true);
|
||||
expect('abc'.includes('cd', -Infinity)).to.equal(false);
|
||||
});
|
||||
|
||||
it('should be falsy on incorrect results', function () {
|
||||
expect('test'.includes('1290')).to.equal(false);
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.match', function () {
|
||||
if (!hasSymbols || !Symbol.match) {
|
||||
return it('exists', function () {
|
||||
expect(Symbol).to.have.property('match');
|
||||
});
|
||||
}
|
||||
|
||||
it('allows a regex with Symbol.match set to a falsy value', function () {
|
||||
var re = /a/g;
|
||||
re[Symbol.match] = false;
|
||||
expect(function () { return 'abcd'.includes(re); }).not.to['throw']();
|
||||
expect('abcd'.includes(re)).to.equal('abcd'.includes(String(re)));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.fromCodePoint()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String, 'fromCodePoint')) {
|
||||
return it('exists', function () {
|
||||
expect(String).to.have.property('fromCodePoint');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.fromCodePoint).to.have.property('name', 'fromCodePoint');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String).ownPropertyDescriptor('fromCodePoint').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(String.fromCodePoint).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('throws a RangeError', function () {
|
||||
var invalidValues = [
|
||||
'abc',
|
||||
{},
|
||||
-1,
|
||||
0x10FFFF + 1
|
||||
];
|
||||
invalidValues.forEach(function (value) {
|
||||
expect(function () { return String.fromCodePoint(value); }).to['throw'](RangeError);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the empty string with no args', function () {
|
||||
expect(String.fromCodePoint()).to.equal('');
|
||||
});
|
||||
|
||||
it('works', function () {
|
||||
var codePoints = [];
|
||||
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789…?!';
|
||||
for (var i = 0; i < chars.length; ++i) {
|
||||
codePoints.push(chars.charCodeAt(i));
|
||||
expect(String.fromCodePoint(chars.charCodeAt(i))).to.equal(chars[i]);
|
||||
}
|
||||
expect(String.fromCodePoint.apply(String, codePoints)).to.equal(chars);
|
||||
});
|
||||
|
||||
it('works with unicode', function () {
|
||||
expect(String.fromCodePoint(0x2500)).to.equal('\u2500');
|
||||
expect(String.fromCodePoint(0x010000)).to.equal('\ud800\udc00');
|
||||
expect(String.fromCodePoint(0x10FFFF)).to.equal('\udbff\udfff');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#codePointAt()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'codePointAt')) {
|
||||
return it('exists', function () {
|
||||
expect(String.prototype).to.have.property('codePointAt');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.prototype.codePointAt).to.have.property('name', 'codePointAt');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String.prototype).ownPropertyDescriptor('codePointAt').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(String.prototype.codePointAt).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('should throw a TypeError when called on null or undefined', function () {
|
||||
testObjectCoercible('codePointAt');
|
||||
});
|
||||
|
||||
it('should work', function () {
|
||||
var str = 'abc';
|
||||
expect(str.codePointAt(0)).to.equal(97);
|
||||
expect(str.codePointAt(1)).to.equal(98);
|
||||
expect(str.codePointAt(2)).to.equal(99);
|
||||
});
|
||||
|
||||
it('should work with unicode', function () {
|
||||
expect('\u2500'.codePointAt(0)).to.equal(0x2500);
|
||||
expect('\ud800\udc00'.codePointAt(0)).to.equal(0x10000);
|
||||
expect('\udbff\udfff'.codePointAt(0)).to.equal(0x10ffff);
|
||||
expect('\ud800\udc00\udbff\udfff'.codePointAt(0)).to.equal(0x10000);
|
||||
expect('\ud800\udc00\udbff\udfff'.codePointAt(1)).to.equal(0xdc00);
|
||||
expect('\ud800\udc00\udbff\udfff'.codePointAt(2)).to.equal(0x10ffff);
|
||||
expect('\ud800\udc00\udbff\udfff'.codePointAt(3)).to.equal(0xdfff);
|
||||
});
|
||||
|
||||
it('should return undefined when pos is negative or too large', function () {
|
||||
var str = 'abc';
|
||||
expect(str.codePointAt(-1)).to.equal(undefined);
|
||||
expect(str.codePointAt(str.length)).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#[Symbol.iterator]()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(Array, 'from')) {
|
||||
return it('requires Array.from to test', function () {
|
||||
expect(Array).to.have.property('from');
|
||||
});
|
||||
}
|
||||
|
||||
it('should work with plain strings', function () {
|
||||
var str = 'abc';
|
||||
expect(Array.from(str)).to.eql(['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
it('should work with surrogate characters', function () {
|
||||
var str = '\u2500\ud800\udc00\udbff\udfff\ud800';
|
||||
expect(Array.from(str)).to.eql(
|
||||
['\u2500', '\ud800\udc00', '\udbff\udfff', '\ud800']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.raw()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String, 'raw')) {
|
||||
return it('exists', function () {
|
||||
expect(String).to.have.property('raw');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.raw).to.have.property('name', 'raw');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String).ownPropertyDescriptor('raw').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(String.raw).to.have.property('length', 1);
|
||||
});
|
||||
|
||||
it('works with callSite.raw: Array', function () {
|
||||
var callSite = {};
|
||||
|
||||
var str = 'The total is 10 ($11 with tax)';
|
||||
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);
|
||||
});
|
||||
|
||||
it('works with callSite.raw: array-like object', function () {
|
||||
var callSite = {};
|
||||
|
||||
var str = 'The total is 10 ($11 with tax)';
|
||||
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);
|
||||
});
|
||||
|
||||
it('works with callSite.raw: empty Objects', function () {
|
||||
var callSite = { raw: {} };
|
||||
expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql('');
|
||||
expect(String.raw(callSite)).to.equal('');
|
||||
});
|
||||
|
||||
it('ReturnIfAbrupt - Less Substitutions', function () {
|
||||
var callSite = {
|
||||
raw: { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 }
|
||||
};
|
||||
var str = 'The total is 10 ($ with tax)';
|
||||
expect(String.raw(callSite, 10)).to.equal(str);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#trim()', function () {
|
||||
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'trim')) {
|
||||
return it('exists', function () {
|
||||
expect(String.prototype).to.have.property('trim');
|
||||
});
|
||||
}
|
||||
|
||||
ifFunctionsHaveNamesIt('has the right name', function () {
|
||||
expect(String.prototype.trim).to.have.property('name', 'trim');
|
||||
});
|
||||
|
||||
it('is not enumerable', function () {
|
||||
expect(String.prototype).ownPropertyDescriptor('trim').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('has the right arity', function () {
|
||||
expect(String.prototype.trim).to.have.property('length', 0);
|
||||
});
|
||||
|
||||
it('should trim the correct characters', function () {
|
||||
var whitespace = [
|
||||
'\u0009',
|
||||
'\u000b',
|
||||
'\u000c',
|
||||
'\u0020',
|
||||
'\u00a0',
|
||||
'\u1680',
|
||||
'\u2000',
|
||||
'\u2001',
|
||||
'\u2002',
|
||||
'\u2003',
|
||||
'\u2004',
|
||||
'\u2005',
|
||||
'\u2006',
|
||||
'\u2007',
|
||||
'\u2008',
|
||||
'\u2009',
|
||||
'\u200A',
|
||||
'\u202f',
|
||||
'\u205f',
|
||||
'\u3000'
|
||||
].join('');
|
||||
|
||||
var lineTerminators = [
|
||||
'\u000a',
|
||||
'\u000d',
|
||||
'\u2028',
|
||||
'\u2029'
|
||||
].join('');
|
||||
|
||||
var trimmed = (whitespace + lineTerminators).trim();
|
||||
expect(trimmed).to.have.property('length', 0);
|
||||
expect(trimmed).to.equal('');
|
||||
});
|
||||
|
||||
it('should not trim U+0085', function () {
|
||||
var trimmed = '\u0085'.trim();
|
||||
expect(trimmed).to.have.property('length', 1);
|
||||
expect(trimmed).to.equal('\u0085');
|
||||
});
|
||||
|
||||
it('should trim on both sides', function () {
|
||||
var trimmed = ' a '.trim();
|
||||
expect(trimmed).to.have.property('length', 1);
|
||||
expect(trimmed).to.equal('a');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#search()', function () {
|
||||
it('works with strings', function () {
|
||||
expect('abc'.search('a')).to.equal(0);
|
||||
expect('abc'.search('b')).to.equal(1);
|
||||
expect('abc'.search('c')).to.equal(2);
|
||||
expect('abc'.search('d')).to.equal(-1);
|
||||
});
|
||||
|
||||
it('works with regexes', function () {
|
||||
expect('abc'.search(/a/)).to.equal(0);
|
||||
expect('abc'.search(/b/)).to.equal(1);
|
||||
expect('abc'.search(/c/)).to.equal(2);
|
||||
expect('abc'.search(/d/)).to.equal(-1);
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.search', function () {
|
||||
it('is a symbol', function () {
|
||||
expect(typeof Symbol.search).to.equal('symbol');
|
||||
});
|
||||
|
||||
if (!hasSymbols || typeof Symbol.search !== 'symbol') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('is nonconfigurable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('search').to.have.property('configurable', false);
|
||||
});
|
||||
|
||||
it('is nonenumerable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('search').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('is nonwritable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('search').to.have.property('writable', false);
|
||||
});
|
||||
|
||||
it('is respected', function () {
|
||||
var str = Object('a');
|
||||
var obj = {};
|
||||
obj[Symbol.search] = function (string) { return string === str && this === obj; };
|
||||
expect(str.search(obj)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#replace()', function () {
|
||||
it('works', function () {
|
||||
expect('abcabc'.replace('c', 'd')).to.equal('abdabc');
|
||||
expect('abcabc'.replace(/c/, 'd')).to.equal('abdabc');
|
||||
expect('abcabc'.replace(/c/g, 'd')).to.equal('abdabd');
|
||||
expect('abcabc'.replace(/C/ig, 'd')).to.equal('abdabd');
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.replace', function () {
|
||||
it('is a symbol', function () {
|
||||
expect(typeof Symbol.replace).to.equal('symbol');
|
||||
});
|
||||
|
||||
if (!hasSymbols || typeof Symbol.replace !== 'symbol') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('is nonconfigurable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('replace').to.have.property('configurable', false);
|
||||
});
|
||||
|
||||
it('is nonenumerable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('replace').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('is nonwritable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('replace').to.have.property('writable', false);
|
||||
});
|
||||
|
||||
it('respects Symbol.replace', function () {
|
||||
var str = Object('a');
|
||||
var replaceVal = Object('replaceValue');
|
||||
var obj = {};
|
||||
obj[Symbol.replace] = function (string, replaceValue) {
|
||||
return string === str && replaceValue === replaceVal && this === obj;
|
||||
};
|
||||
expect(str.replace(obj, replaceVal)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#split()', function () {
|
||||
it('works', function () {
|
||||
expect('abcabc'.split('b')).to.eql(['a', 'ca', 'c']);
|
||||
expect('abcabc'.split('b', 2)).to.eql(['a', 'ca']);
|
||||
expect('abcabc'.split(/b.?/)).to.eql(['a', 'a', '']);
|
||||
expect('abcabc'.split(/b.?/, 2)).to.eql(['a', 'a']);
|
||||
expect('abcabc'.split(/b/)).to.eql(['a', 'ca', 'c']);
|
||||
expect('abcabc'.split(/b/, 2)).to.eql(['a', 'ca']);
|
||||
expect('abcabc'.split(/b/g)).to.eql(['a', 'ca', 'c']);
|
||||
expect('abcabc'.split(/b/g, 2)).to.eql(['a', 'ca']);
|
||||
expect('abcabc'.split(/B/i)).to.eql(['a', 'ca', 'c']);
|
||||
expect('abcabc'.split(/B/i, 2)).to.eql(['a', 'ca']);
|
||||
expect('abcabc'.split(/B/gi)).to.eql(['a', 'ca', 'c']);
|
||||
expect('abcabc'.split(/B/gi, 2)).to.eql(['a', 'ca']);
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.split', function () {
|
||||
it('is a symbol', function () {
|
||||
expect(typeof Symbol.split).to.equal('symbol');
|
||||
});
|
||||
|
||||
if (!hasSymbols || typeof Symbol.split !== 'symbol') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('is nonconfigurable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('split').to.have.property('configurable', false);
|
||||
});
|
||||
|
||||
it('is nonenumerable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('split').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('is nonwritable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('split').to.have.property('writable', false);
|
||||
});
|
||||
|
||||
it('respects Symbol.split', function () {
|
||||
var str = Object('a');
|
||||
var limitVal = Object(42);
|
||||
var obj = {};
|
||||
obj[Symbol.split] = function (string, limit) { return string === str && limit === limitVal && this === obj; };
|
||||
expect(str.split(obj, limitVal)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#match()', function () {
|
||||
it('works with a string', function () {
|
||||
var str = 'abca';
|
||||
var match = str.match('a');
|
||||
expect(match.index).to.equal(0);
|
||||
expect(match.input).to.equal(str);
|
||||
expect(Array.prototype.slice.call(match)).to.eql(['a']);
|
||||
});
|
||||
|
||||
it('works with a regex', function () {
|
||||
var str = 'abca';
|
||||
var match = str.match(/a/);
|
||||
expect(match.index).to.equal(0);
|
||||
expect(match.input).to.equal(str);
|
||||
expect(Array.prototype.slice.call(match)).to.eql(['a']);
|
||||
});
|
||||
|
||||
ifSymbolsDescribe('Symbol.match', function () {
|
||||
it('is a symbol', function () {
|
||||
expect(typeof Symbol.match).to.equal('symbol');
|
||||
});
|
||||
|
||||
if (!hasSymbols || typeof Symbol.match !== 'symbol') {
|
||||
return;
|
||||
}
|
||||
|
||||
it('is nonconfigurable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('match').to.have.property('configurable', false);
|
||||
});
|
||||
|
||||
it('is nonenumerable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('match').to.have.property('enumerable', false);
|
||||
});
|
||||
|
||||
it('is nonwritable', function () {
|
||||
expect(Symbol).ownPropertyDescriptor('match').to.have.property('writable', false);
|
||||
});
|
||||
|
||||
it('respects Symbol.match', function () {
|
||||
var str = Object('a');
|
||||
var obj = {};
|
||||
obj[Symbol.match] = function (string) { return string === str && this === obj; };
|
||||
expect(str.match(obj)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Annex B', function () {
|
||||
it('has #anchor', function () {
|
||||
expect('foo'.anchor('bar"baz"')).to.equal('<a name="bar"baz"">foo</a>');
|
||||
});
|
||||
it('has #big', function () {
|
||||
expect('foo'.big()).to.equal('<big>foo</big>');
|
||||
});
|
||||
it('has #blink', function () {
|
||||
expect('foo'.blink()).to.equal('<blink>foo</blink>');
|
||||
});
|
||||
it('has #bold', function () {
|
||||
expect('foo'.bold()).to.equal('<b>foo</b>');
|
||||
});
|
||||
it('has #fixed', function () {
|
||||
expect('foo'.fixed()).to.equal('<tt>foo</tt>');
|
||||
});
|
||||
it('has #fontcolor', function () {
|
||||
expect('foo'.fontcolor('blue"red"green')).to.equal('<font color="blue"red"green">foo</font>');
|
||||
});
|
||||
it('has #fontsize', function () {
|
||||
expect('foo'.fontsize('10"large"small')).to.equal('<font size="10"large"small">foo</font>');
|
||||
});
|
||||
it('has #italics', function () {
|
||||
expect('foo'.italics()).to.equal('<i>foo</i>');
|
||||
});
|
||||
it('has #link', function () {
|
||||
expect('foo'.link('url"http://"')).to.equal('<a href="url"http://"">foo</a>');
|
||||
});
|
||||
it('has #small', function () {
|
||||
expect('foo'.small()).to.equal('<small>foo</small>');
|
||||
});
|
||||
it('has #strike', function () {
|
||||
expect('foo'.strike()).to.equal('<strike>foo</strike>');
|
||||
});
|
||||
it('has #sub', function () {
|
||||
expect('foo'.sub()).to.equal('<sub>foo</sub>');
|
||||
});
|
||||
it('has #sup', function () {
|
||||
expect('foo'.sup()).to.equal('<sup>foo</sup>');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
describe('clean Object.prototype', function () {
|
||||
return runStringTests.call(this, it);
|
||||
});
|
||||
|
||||
describe('polluted Object.prototype', function () {
|
||||
var shimmedIt = function () {
|
||||
/* eslint-disable no-extend-native */
|
||||
Object.prototype[1] = 42;
|
||||
/* eslint-enable no-extend-native */
|
||||
it.apply(this, arguments);
|
||||
delete Object.prototype[1];
|
||||
};
|
||||
shimmedIt.skip = it.skip;
|
||||
return runStringTests.call(this, shimmedIt);
|
||||
});
|
17
node_modules/es6-shim/test/test_helpers.js
generated
vendored
Normal file
17
node_modules/es6-shim/test/test_helpers.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/* global expect: true, assert: true, require, process */
|
||||
|
||||
expect = (function () {
|
||||
var chai = require('chai');
|
||||
chai.config.includeStack = true;
|
||||
return chai.expect;
|
||||
}());
|
||||
|
||||
assert = (function () {
|
||||
var chai = require('chai');
|
||||
chai.config.includeStack = true;
|
||||
return chai.assert;
|
||||
}());
|
||||
|
||||
if (typeof process === 'undefined' || !process.env.NO_ES6_SHIM) {
|
||||
require('../');
|
||||
}
|
7
node_modules/es6-shim/test/worker-runner.workerjs
generated
vendored
Normal file
7
node_modules/es6-shim/test/worker-runner.workerjs
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
importScripts(
|
||||
'../node_modules/es5-shim/es5-shim.js',
|
||||
'../node_modules/es5-shim/es5-sham.js',
|
||||
'../es6-shim.js'
|
||||
);
|
||||
|
||||
postMessage('ready');
|
39
node_modules/es6-shim/test/worker-test.js
generated
vendored
Normal file
39
node_modules/es6-shim/test/worker-test.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/* globals Worker, location */
|
||||
|
||||
describe('Worker', function () {
|
||||
var workerErrorEventToError = function (errorEvent) {
|
||||
var errorText = 'Error in Worker';
|
||||
if (errorEvent.filename !== undefined) {
|
||||
errorText += ' ' + errorEvent.filename;
|
||||
}
|
||||
if (errorEvent.lineno !== undefined) {
|
||||
errorText += '(' + errorEvent.lineno + ')';
|
||||
}
|
||||
if (errorEvent.message !== undefined) {
|
||||
errorText += ': ' + errorEvent.message;
|
||||
}
|
||||
return new Error(errorText);
|
||||
};
|
||||
var canRunWorkerTestInCurrentContext = function () {
|
||||
var workerConstructorExists = typeof Worker !== 'undefined';
|
||||
var locationPropertyExists = typeof location !== 'undefined';
|
||||
var runningOnFileUriScheme = locationPropertyExists && location.protocol === 'file:';
|
||||
|
||||
// The Worker constructor doesn't exist in some older browsers nor does it exist in non-browser contexts like Node.
|
||||
// Additionally some browsers (at least Chrome) don't allow Workers over file URIs.
|
||||
// To prevent false negative test failures in the cases where Workers are unavailable for either of those reasons
|
||||
// we skip this test.
|
||||
return workerConstructorExists && !runningOnFileUriScheme;
|
||||
};
|
||||
|
||||
if (canRunWorkerTestInCurrentContext()) {
|
||||
it('can import es6-shim', function (done) {
|
||||
var worker = new Worker('worker-runner.workerjs');
|
||||
worker.addEventListener('error', function (errorEvent) { throw workerErrorEventToError(errorEvent); });
|
||||
worker.addEventListener('message', function (messageEvent) {
|
||||
expect(messageEvent.data).to.eql('ready');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user