js/src/tests/ecma_2/Exceptions/number-001.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:21905b874584
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
7 /**
8 File Name: number-001
9 Corresponds To: 15.7.4.2-2-n.js
10 ECMA Section: 15.7.4.2.2 Number.prototype.toString()
11 Description:
12 If the radix is the number 10 or not supplied, then this number value is
13 given as an argument to the ToString operator; the resulting string value
14 is returned.
15
16 If the radix is supplied and is an integer from 2 to 36, but not 10, the
17 result is a string, the choice of which is implementation dependent.
18
19 The toString function is not generic; it generates a runtime error if its
20 this value is not a Number object. Therefore it cannot be transferred to
21 other kinds of objects for use as a method.
22
23 Author: christine@netscape.com
24 Date: 16 september 1997
25 */
26 var SECTION = "number-001";
27 var VERSION = "JS1_4";
28 var TITLE = "Exceptions for Number.toString()";
29
30 startTest();
31 writeHeaderToLog( SECTION + " Number.prototype.toString()");
32
33 var result = "Failed";
34 var exception = "No exception thrown";
35 var expect = "Passed";
36
37 try {
38 object= new Object();
39 object.toString = Number.prototype.toString;
40 result = object.toString();
41 } catch ( e ) {
42 result = expect;
43 exception = e.toString();
44 }
45
46 new TestCase(
47 SECTION,
48 "object = new Object(); object.toString = Number.prototype.toString; object.toString()" +
49 " (threw " + exception +")",
50 expect,
51 result );
52
53 test();

mercurial