michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 306591; michael@0: var summary = 'String static methods'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: printStatus ('See https://bugzilla.mozilla.org/show_bug.cgi?id=304828'); michael@0: michael@0: expect = ['a', 'b', 'c'].toString(); michael@0: actual = String.split(new String('abc'), '').toString(); michael@0: reportCompare(expect, actual, summary + michael@0: " String.split(new String('abc'), '')"); michael@0: michael@0: expect = '2'; michael@0: actual = String.substring(new Number(123), 1, 2); michael@0: reportCompare(expect, actual, summary + michael@0: " String.substring(new Number(123), 1, 2)"); michael@0: michael@0: expect = 'TRUE'; michael@0: actual = String.toUpperCase(new Boolean(true)); michael@0: reportCompare(expect, actual, summary + michael@0: " String.toUpperCase(new Boolean(true))"); michael@0: michael@0: try michael@0: { michael@0: String.indexOf(null, 'l'); michael@0: throw new Error("should have thrown a TypeError"); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof TypeError, true, michael@0: "String.indexOf(null [, ...]) didn't work correctly"); michael@0: } michael@0: michael@0: expect = 2; michael@0: actual = String.indexOf(String(null), 'l'); michael@0: reportCompare(expect, actual, summary + michael@0: " String.indexOf(String(null), 'l')"); michael@0: michael@0: expect = ['a', 'b', 'c'].toString(); michael@0: actual = String.split('abc', '').toString(); michael@0: reportCompare(expect, actual, summary + michael@0: " String.split('abc', '')"); michael@0: michael@0: expect = '2'; michael@0: actual = String.substring(123, 1, 2); michael@0: reportCompare(expect, actual, summary + michael@0: " String.substring(123, 1, 2)"); michael@0: michael@0: expect = 'TRUE'; michael@0: actual = String.toUpperCase(true); michael@0: reportCompare(expect, actual, summary + michael@0: " String.toUpperCase(true)"); michael@0: michael@0: try michael@0: { michael@0: String.indexOf(undefined, 'd'); michael@0: throw new Error("should have thrown a TypeError"); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof TypeError, true, michael@0: "String.indexOf(undefined [, ...]) didn't work correctly"); michael@0: } michael@0: michael@0: expect = 2; michael@0: actual = String.indexOf(String(undefined), 'd'); michael@0: reportCompare(expect, actual, summary + michael@0: " String.indexOf(String(undefined), 'd')");