From 460925c2c65af3ba25bff4cfaacfc9f3bfd603b9 Mon Sep 17 00:00:00 2001 From: hokaccha Date: Wed, 25 Jan 2012 18:01:59 +0900 Subject: [PATCH] Fix bug `indexOf`. when arr is number, it was return 0 --- expect.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/expect.js b/expect.js index b394de6..26e95fe 100644 --- a/expect.js +++ b/expect.js @@ -449,6 +449,10 @@ return Array.prototype.indexOf.call(arr, o, i); } + if (arr.length === undefined) { + return -1; + } + for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0 ; i < j && arr[i] !== o; i++);