lastIndexOf-ToNumber-when-searchStr-larger-than-string.js (615B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 var str = "a"; 6 var searchStr = "abc"; 7 8 var position = new Object(); 9 var valueOfCalled = false; 10 function positionValueOf() { 11 assertEq(valueOfCalled, false); 12 valueOfCalled = true; 13 return 0; 14 } 15 position.valueOf = positionValueOf; 16 17 var result = str.lastIndexOf(searchStr, position); 18 assertEq(result, -1); 19 assertEq(valueOfCalled, true); 20 21 if (typeof reportCompare == "function") 22 reportCompare(0, 0);