[Pkg-javascript-commits] [node-es5-shim] 01/03: Import node-es5-shim_4.2.0.orig.tar.gz

Julien Puydt julien.puydt at laposte.net
Thu Nov 5 07:36:23 UTC 2015


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-es5-shim.

commit 04e9ff53ce8ff69cb14153ba0b801f89b8caf2e0
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Thu Nov 5 08:10:23 2015 +0100

    Import node-es5-shim_4.2.0.orig.tar.gz
---
 .eslintrc              |  1 +
 .jscs.json             | 13 +++++++--
 .travis.yml            |  2 ++
 CHANGES                | 11 ++++++++
 component.json         |  2 +-
 es5-sham.js            |  6 ++--
 es5-sham.map           |  2 +-
 es5-sham.min.js        |  4 +--
 es5-shim.js            | 74 +++++++++++++++++++++++++++++++++++++++++---------
 es5-shim.map           |  2 +-
 es5-shim.min.js        |  4 +--
 package.json           | 10 +++----
 tests/spec/s-date.js   | 28 ++++++++++++++++++-
 tests/spec/s-object.js | 14 +++++-----
 tests/spec/s-string.js | 33 ++++++++++++++++++++++
 15 files changed, 167 insertions(+), 39 deletions(-)

diff --git a/.eslintrc b/.eslintrc
index 8ba8630..2cea9de 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -24,6 +24,7 @@
 			"string": true
 		 }],
 		"no-invalid-this": [0],
+		"no-magic-numbers": [0],
 		"no-native-reassign": [2, {"exceptions": ["Date", "parseInt"]}],
 		"no-new-func": [1],
 		"no-restricted-syntax": [2, "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"],
diff --git a/.jscs.json b/.jscs.json
index 191a0ed..bd4d449 100644
--- a/.jscs.json
+++ b/.jscs.json
@@ -26,7 +26,7 @@
 		"WithStatement"
 	],
 
-	"requireObjectKeysOnNewLine": false,
+	"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
 
 	"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
 	"requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
@@ -75,7 +75,7 @@
 
 	"disallowMultipleLineStrings": true,
 
-	"requireDotNotation": true,
+	"requireDotNotation": { "allExcept": ["keywords"] },
 
 	"requireParenthesesAroundIIFE": true,
 
@@ -120,6 +120,13 @@
 
 	"disallowMultiLineTernary": false,
 
-	"validateOrderInObjectKeys": false
+	"validateOrderInObjectKeys": false,
+
+	"disallowIdenticalDestructuringNames": true,
+
+	"disallowNestedTernaries": { "maxLevel": 7 },
+
+	"requireSpaceAfterComma": true,
+	"requireAlignedMultilineParams": false
 }
 
diff --git a/.travis.yml b/.travis.yml
index 4c29ed5..324496c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
 language: node_js
 node_js:
+  - "4.2"
   - "4.1"
   - "4.0"
   - "iojs-v3.3"
@@ -34,6 +35,7 @@ sudo: false
 matrix:
   fast_finish: true
   allow_failures:
+    - node_js: "4.1"
     - node_js: "4.0"
     - node_js: "iojs-v3.2"
     - node_js: "iojs-v3.1"
diff --git a/CHANGES b/CHANGES
index a509db2..43fed63 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,14 @@
+4.2.0
+  - [shim: new] Overwrite `String#lastIndexOf` in IE 9, 10, 11, and Edge, so it has proper unicode support.
+  - [Dev Deps] update `eslint`, `jscs`
+
+4.1.15
+  - [shim: fix] new Date + Date.parse: Fix a Safari 8 & 9 bug where the `ms` arg is treated as a signed instead of unsigned int (#329)
+  - [shim: fix] add 'frame' to blacklisted keys (#330)
+  - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`
+  - [Tests] on `node` `v4.2`
+  - [Tests] Date: prevent nondeterminism in the tests - this sometime produced values that are one ms off
+
 4.1.14
   - [shim: fix] Wrap more things in a try/catch, because IE sucks and sometimes throws on [[Get]] of window.localStorage (#327)
   - [Refactor] Use `ES.ToUint32` instead of inline `>>>`
diff --git a/component.json b/component.json
index 477eeca..60a6d6e 100644
--- a/component.json
+++ b/component.json
@@ -2,7 +2,7 @@
     "name": "es5-shim",
     "repo": "es-shims/es5-shim",
     "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
-    "version": "v4.1.14",
+    "version": "v4.2.0",
     "keywords": [
         "shim",
         "es5",
diff --git a/es5-sham.js b/es5-sham.js
index 42e9c98..9a15cbd 100644
--- a/es5-sham.js
+++ b/es5-sham.js
@@ -68,14 +68,14 @@ if (!Object.getPrototypeOf) {
             return proto;
         } else if (toStr(object.constructor) === '[object Function]') {
             return object.constructor.prototype;
-        } else if (!(object instanceof Object)) {
+        } else if (object instanceof Object) {
+          return prototypeOfObject;
+        } else {
           // Correctly return null for Objects created with `Object.create(null)`
           // (shammed or native) or `{ __proto__: null}`.  Also returns null for
           // cross-realm objects on browsers that lack `__proto__` support (like
           // IE <11), but that's the best we can do.
           return null;
-        } else {
-          return prototypeOfObject;
         }
     };
 }
diff --git a/es5-sham.map b/es5-sham.map
index cc4f3c2..f37dfcb 100644
--- a/es5-sham.map
+++ b/es5-sham.map
@@ -1 +1 @@
-{"version":3,"sources":["es5-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","call","Function","prototype","prototypeOfObject","Object","owns","bind","hasOwnProperty","propertyIsEnumerable","toStr","toString","defineGetter","defineSetter","lookupGetter","lookupSetter","supportsAccessors","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","getPrototypeOf","object","proto","__proto__","constructor","doesGetOwnPropertyDes [...]
\ No newline at end of file
+{"version":3,"sources":["es5-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","call","Function","prototype","prototypeOfObject","Object","owns","bind","hasOwnProperty","propertyIsEnumerable","toStr","toString","defineGetter","defineSetter","lookupGetter","lookupSetter","supportsAccessors","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","getPrototypeOf","object","proto","__proto__","constructor","doesGetOwnPropertyDes [...]
\ No newline at end of file
diff --git a/es5-sham.min.js b/es5-sham.min.js
index c48414c..415504b 100644
--- a/es5-sham.min.js
+++ b/es5-sham.min.js
@@ -1,7 +1,7 @@
 /*!
  * https://github.com/es-shims/es5-shim
  * @license es5-shim Copyright 2009-2015 by contributors, MIT License
- * see https://github.com/es-shims/es5-shim/blob/v4.1.14/LICENSE
+ * see https://github.com/es-shims/es5-shim/blob/v4.2.0/LICENSE
  */
-(function(e,t){"use strict";if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){var e=Function.prototype.call;var t=Object.prototype;var r=e.bind(t.hasOwnProperty);var n=e.bind(t.propertyIsEnumerable);var o=e.bind(t.toString);var i;var c;var f;var a;var l=r(t,"__defineGetter__");if(l){i=e.bind(t.__defineGetter__);c=e.bind(t.__defineSetter__);f=e.bind(t.__lookupGetter__);a=e.bind(t.__lookupS [...]
+(function(e,t){"use strict";if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){var e=Function.prototype.call;var t=Object.prototype;var r=e.bind(t.hasOwnProperty);var n=e.bind(t.propertyIsEnumerable);var o=e.bind(t.toString);var i;var c;var f;var a;var l=r(t,"__defineGetter__");if(l){i=e.bind(t.__defineGetter__);c=e.bind(t.__defineSetter__);f=e.bind(t.__lookupGetter__);a=e.bind(t.__lookupS [...]
 //# sourceMappingURL=es5-sham.map
diff --git a/es5-shim.js b/es5-shim.js
index 879597e..5daa667 100644
--- a/es5-shim.js
+++ b/es5-shim.js
@@ -119,6 +119,8 @@ var isPrimitive = function isPrimitive(input) {
     return input === null || (type !== 'object' && type !== 'function');
 };
 
+var isActualNaN = $Number.isNaN || function (x) { return x !== x; };
+
 var ES = {
     // ES5 9.4
     // http://es5.github.com/#x9.4
@@ -126,7 +128,7 @@ var ES = {
     /* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */
     ToInteger: function ToInteger(num) {
         var n = +num;
-        if (n !== n) { // isNaN
+        if (isActualNaN(n)) {
             n = 0;
         } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
             n = (n > 0 || -1) * Math.floor(Math.abs(n));
@@ -324,6 +326,7 @@ var owns = call.bind(ObjectPrototype.hasOwnProperty);
 var toStr = call.bind(ObjectPrototype.toString);
 var strSlice = call.bind(StringPrototype.slice);
 var strSplit = call.bind(StringPrototype.split);
+var strIndexOf = call.bind(StringPrototype.indexOf);
 
 //
 // Array
@@ -411,10 +414,10 @@ defineProperties(ArrayPrototype, {
             if (i in self) {
                 // Invoke the callback function with call, passing arguments:
                 // context, property value, property key, thisArg object
-                if (typeof T !== 'undefined') {
-                    callbackfn.call(T, self[i], i, object);
-                } else {
+                if (typeof T === 'undefined') {
                     callbackfn(self[i], i, object);
+                } else {
+                    callbackfn.call(T, self[i], i, object);
                 }
             }
         }
@@ -442,10 +445,10 @@ defineProperties(ArrayPrototype, {
 
         for (var i = 0; i < length; i++) {
             if (i in self) {
-                if (typeof T !== 'undefined') {
-                    result[i] = callbackfn.call(T, self[i], i, object);
-                } else {
+                if (typeof T === 'undefined') {
                     result[i] = callbackfn(self[i], i, object);
+                } else {
+                    result[i] = callbackfn.call(T, self[i], i, object);
                 }
             }
         }
@@ -844,6 +847,7 @@ var blacklistedKeys = {
     $console: true,
     $parent: true,
     $self: true,
+    $frame: true,
     $frames: true,
     $frameElement: true,
     $webkitIndexedDB: true,
@@ -1076,6 +1080,9 @@ if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
     // an alternate object for the context.
     /* global Date: true */
     /* eslint-disable no-undef */
+    var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1;
+    var secondsWithinMaxSafeUnsigned32Bit = Math.floor(maxSafeUnsigned32Bit / 1e3);
+    var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime());
     Date = (function (NativeDate) {
     /* eslint-enable no-undef */
         // Date.length === 7
@@ -1083,13 +1090,22 @@ if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
             var length = arguments.length;
             var date;
             if (this instanceof NativeDate) {
+                var seconds = s;
+                var millis = ms;
+                if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) {
+                    // work around a Safari 8/9 bug where it treats the seconds as signed
+                    var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
+                    var sToShift = Math.floor(msToShift / 1e3);
+                    seconds += sToShift;
+                    millis -= sToShift * 1e3;
+                }
                 date = length === 1 && $String(Y) === Y ? // isString(Y)
                     // We explicitly pass it through parse:
                     new NativeDate(DateShim.parse(Y)) :
                     // We have to manually make calls depending on argument
                     // length here
-                    length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
-                    length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
+                    length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) :
+                    length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) :
                     length >= 5 ? new NativeDate(Y, M, D, h, m) :
                     length >= 4 ? new NativeDate(Y, M, D, h) :
                     length >= 3 ? new NativeDate(Y, M, D) :
@@ -1143,7 +1159,16 @@ if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
         };
 
         var toUTC = function toUTC(t) {
-            return $Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
+            var s = 0;
+            var ms = t;
+            if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) {
+                // work around a Safari 8/9 bug where it treats the seconds as signed
+                var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
+                var sToShift = Math.floor(msToShift / 1e3);
+                s += sToShift;
+                ms -= sToShift * 1e3;
+            }
+            return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms));
         };
 
         // Copy any custom methods a 3rd party library may have added
@@ -1303,7 +1328,7 @@ defineProperties(NumberPrototype, {
 
         // Test for NaN and round fractionDigits down
         f = $Number(fractionDigits);
-        f = f !== f ? 0 : Math.floor(f);
+        f = isActualNaN(f) ? 0 : Math.floor(f);
 
         if (f < 0 || f > 20) {
             throw new RangeError('Number.toFixed called with invalid number of decimals');
@@ -1311,8 +1336,7 @@ defineProperties(NumberPrototype, {
 
         x = $Number(this);
 
-        // Test for NaN
-        if (x !== x) {
+        if (isActualNaN(x)) {
             return 'NaN';
         }
 
@@ -1574,6 +1598,30 @@ defineProperties(StringPrototype, {
     }
 }, hasTrimWhitespaceBug);
 
+var hasLastIndexBug = String.prototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1;
+defineProperties(StringPrototype, {
+    lastIndexOf: function lastIndexOf(searchString) {
+        if (typeof this === 'undefined' || this === null) {
+            throw new TypeError("can't convert " + this + ' to object');
+        }
+        var S = $String(this);
+        var searchStr = $String(searchString);
+        var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN;
+        var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos);
+        var start = min(max(pos, 0), S.length);
+        var searchLen = searchStr.length;
+        var k = start + searchLen;
+        while (k > 0) {
+            k = max(0, k - searchLen);
+            var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr);
+            if (index !== -1) {
+                return k + index;
+            }
+        }
+        return -1;
+    }
+}, hasLastIndexBug);
+
 // ES-5 15.1.2.2
 if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
     /* global parseInt: true */
diff --git a/es5-shim.map b/es5-shim.map
index 8c301e8..d5aeacc 100644
--- a/es5-shim.map
+++ b/es5-shim.map
@@ -1 +1 @@
-{"version":3,"sources":["es5-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","$Array","Array","ArrayPrototype","prototype","$Object","Object","ObjectPrototype","FunctionPrototype","Function","$String","String","StringPrototype","$Number","Number","NumberPrototype","array_slice","slice","array_splice","splice","array_push","push","array_unshift","unshift","array_concat","concat","call","max","Math","min","to_string","toString","hasToStringTag", [...]
\ No newline at end of file
+{"version":3,"sources":["es5-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","$Array","Array","ArrayPrototype","prototype","$Object","Object","ObjectPrototype","FunctionPrototype","Function","$String","String","StringPrototype","$Number","Number","NumberPrototype","array_slice","slice","array_splice","splice","array_push","push","array_unshift","unshift","array_concat","concat","call","max","Math","min","to_string","toString","hasToStringTag", [...]
\ No newline at end of file
diff --git a/es5-shim.min.js b/es5-shim.min.js
index f4277c5..7a73022 100644
--- a/es5-shim.min.js
+++ b/es5-shim.min.js
@@ -1,7 +1,7 @@
 /*!
  * https://github.com/es-shims/es5-shim
  * @license es5-shim Copyright 2009-2015 by contributors, MIT License
- * see https://github.com/es-shims/es5-shim/blob/v4.1.14/LICENSE
+ * see https://github.com/es-shims/es5-shim/blob/v4.2.0/LICENSE
  */
-(function(e,t){"use strict";if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){var e=Array;var t=e.prototype;var r=Object;var n=r.prototype;var i=Function.prototype;var a=String;var o=a.prototype;var l=Number;var u=l.prototype;var f=t.slice;var s=t.splice;var c=t.push;var v=t.unshift;var p=t.concat;var h=i.call;var g=Math.max;var y=Math.min;var d=n.toString;var w=typeof Symbol==="function" [...]
+(function(e,t){"use strict";if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){var e=Array;var t=e.prototype;var r=Object;var n=r.prototype;var a=Function.prototype;var i=String;var o=i.prototype;var l=Number;var u=l.prototype;var f=t.slice;var s=t.splice;var c=t.push;var v=t.unshift;var p=t.concat;var h=a.call;var g=Math.max;var y=Math.min;var d=n.toString;var w=typeof Symbol==="function" [...]
 //# sourceMappingURL=es5-shim.map
diff --git a/package.json b/package.json
index b0775fd..fa958fa 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "es5-shim",
-  "version": "4.1.14",
+  "version": "4.2.0",
   "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
   "homepage": "http://github.com/es-shims/es5-shim/",
   "contributors": [
@@ -32,11 +32,11 @@
     "jscs": "jscs tests/helpers/*.js tests/spec/*.js es5-shim.js es5-sham.js"
   },
   "devDependencies": {
-    "eslint": "^1.5.1",
-    "@ljharb/eslint-config": "^1.2.0",
+    "eslint": "^1.7.3",
+    "@ljharb/eslint-config": "^1.4.1",
     "jasmine-node": "^1.14.5",
-    "jscs": "^2.2.1",
-    "uglify-js": "^2.4.24",
+    "jscs": "^2.4.0",
+    "uglify-js": "^2.5.0",
     "replace": "^0.3.0",
     "semver": "^5.0.3"
   },
diff --git a/tests/spec/s-date.js b/tests/spec/s-date.js
index c2ef3ce..49858f9 100644
--- a/tests/spec/s-date.js
+++ b/tests/spec/s-date.js
@@ -50,7 +50,28 @@ describe('Date', function () {
 
         it('works as a function', function () {
           expect(Date(0)).toBe(String(Date(0)));
-          expect(Date(1441705534578)).toBe(String(Date(1441705534578)));
+          var value = Date(1441705534578);
+          expect(value).toBe(String(value));
+        });
+
+        it('fixes this Safari 8/9 bug', function () {
+          var offset = new Date(1970).getTimezoneOffset() * 60e3;
+
+          var timestamp = 2147483647; // Math.pow(2, 31) - 1
+          var date = new Date(1970, 0, 1, 0, 0, 0, timestamp);
+          var expectedTimestamp = timestamp + offset;
+          expect(date.getTime()).toBe(expectedTimestamp);
+
+          var brokenTimestamp = 2147483648; // Math.pow(2, 31)
+          var brokenDate = new Date(1970, 0, 1, 0, 0, 0, brokenTimestamp);
+          var expectedBrokenTimestamp = brokenTimestamp + offset;
+          expect(brokenDate.getTime()).toBe(expectedBrokenTimestamp); // NaN in Safari 8/9
+
+          var veryBrokenTS = 1435734000000;
+          var veryBrokenDate = new Date(1970, 0, 1, 0, 0, 0, veryBrokenTS);
+          var largeDate = new Date('Wed Jul 01 2015 07:00:00 GMT-0700 (PDT)');
+          var expectedVeryBrokenTS = veryBrokenTS + (largeDate.getTimezoneOffset() * 60e3);
+          expect(veryBrokenDate.getTime()).toBe(expectedVeryBrokenTS); // NaN in Safari 8/9
         });
     });
 
@@ -102,6 +123,11 @@ describe('Date', function () {
 
         });
 
+        it('fixes a Safari 8/9 bug with parsing in UTC instead of local time', function () {
+            var offset = new Date('2015-07-01').getTimezoneOffset() * 60e3;
+            expect(Date.parse('2015-07-01T00:00:00')).toBe(1435708800000 + offset); // Safari 8/9 give NaN
+        });
+
         it('should support extended years', function () {
                                                                                //    Chrome 19     Opera 12      Firefox 11    IE 9          Safari 5.1.1
             expect(Date.parse('0000-01-01T00:00:00.000Z')).toBe(-621672192e5); //   -621672192e5  -621672192e5  -621672192e5  -621672192e5  -621672192e5
diff --git a/tests/spec/s-object.js b/tests/spec/s-object.js
index a638e5d..a86878d 100644
--- a/tests/spec/s-object.js
+++ b/tests/spec/s-object.js
@@ -38,8 +38,8 @@ describe('Object', function () {
         };
 
         var loopedValues = [];
-        for (var k in obj) {
-            loopedValues.push(k);
+        for (var key in obj) {
+            loopedValues.push(key);
         }
 
         var keys = Object.keys(obj);
@@ -129,20 +129,20 @@ describe('Object', function () {
 
         ifWindowIt('can serialize all objects on the `window`', function () {
           var has = Object.prototype.hasOwnProperty;
-          var keys, exception;
-          var blacklistedKeys = ['window', 'console', 'parent', 'self', 'frames', 'frameElement'];
+          var windowItemKeys, exception;
+          var blacklistedKeys = ['window', 'console', 'parent', 'self', 'frame', 'frames', 'frameElement'];
           if (Object.defineProperty) {
               Object.defineProperty(window, 'thrower', { configurable: true, get: function () { throw new RangeError('thrower!'); } });
           }
           for (var k in window) {
-              keys = exception = void 0;
+              windowItemKeys = exception = void 0;
               if (blacklistedKeys.indexOf(k) === -1 && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
                      try {
-                         keys = Object.keys(window[k]);
+                         windowItemKeys = Object.keys(window[k]);
                      } catch (e) {
                          exception = e;
                      }
-                     expect(Array.isArray(keys)).toEqual(true);
+                     expect(Array.isArray(windowItemKeys)).toEqual(true);
                      expect(exception).toBeUndefined();
               }
           }
diff --git a/tests/spec/s-string.js b/tests/spec/s-string.js
index de62924..5e5f6e6 100644
--- a/tests/spec/s-string.js
+++ b/tests/spec/s-string.js
@@ -229,4 +229,37 @@ describe('String', function () {
             });
         });
     });
+
+    describe('#indexOf()', function () {
+      it('has basic support', function () {
+          expect('abcab'.indexOf('a')).toEqual(0);
+          expect('abcab'.indexOf('a', 1)).toEqual(3);
+          expect('abcab'.indexOf('a', 4)).toEqual(-1);
+      });
+
+      it('works with unicode', function () {
+          expect('あいabcあいabc'.indexOf('あい')).toEqual(0);
+          expect('あいabcあいabc'.indexOf('あい', 0)).toEqual(0);
+          expect('あいabcあいabc'.indexOf('あい', 1)).toEqual(5);
+          expect('あいabcあいabc'.indexOf('あい', 6)).toEqual(-1);
+      });
+    });
+
+    describe('#lastIndexOf()', function () {
+      it('has the right length', function () {
+          expect(String.prototype.lastIndexOf.length).toEqual(1);
+      });
+
+      it('has basic support', function () {
+          expect('abcd'.lastIndexOf('d')).toEqual(3);
+          expect('abcd'.lastIndexOf('d', 3)).toEqual(3);
+          expect('abcd'.lastIndexOf('d', 2)).toEqual(-1);
+      });
+
+      it('works with unicode', function () {
+          expect('abcあい'.lastIndexOf('あい')).toEqual(3);
+          expect('abcあい'.lastIndexOf('あい', 3)).toEqual(3);
+          expect('abcあい'.lastIndexOf('あい', 2)).toEqual(-1);
+      });
+    });
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-es5-shim.git



More information about the Pkg-javascript-commits mailing list