Debian Codegraph @

rhino/testsrc/tests/ecma/Number/15.7.4.2-1.js

raw symbols SCIP
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 gTestfile = '15.7.4.2-1.js';
7
8 /**
9 File Name: 15.7.4.2.js
10 ECMA Section: 15.7.4.2.1 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: [email protected]
24 Date: 16 september 1997
25 */
26 var SECTION = "15.7.4.2-1";
27 var VERSION = "ECMA_1";
28 startTest();
29
30 writeHeaderToLog( SECTION + " Number.prototype.toString()");
31
32 // the following two lines cause navigator to crash -- cmb 9/16/97
33 new TestCase(SECTION,
34 "Number.prototype.toString()",
35 "0",
36 eval("Number.prototype.toString()") );
37
38 new TestCase(SECTION,
39 "typeof(Number.prototype.toString())",
40 "string",
41 eval("typeof(Number.prototype.toString())") );
42
43 new TestCase(SECTION,
44 "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()",
45 "0",
46 eval("s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()") );
47
48 new TestCase(SECTION,
49 "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()",
50 "1",
51 eval("s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()") );
52
53 new TestCase(SECTION,
54 "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()",
55 "-1",
56 eval("s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()") );
57
58 new TestCase(SECTION,
59 "var MYNUM = new Number(255); MYNUM.toString(10)",
60 "255",
61 eval("var MYNUM = new Number(255); MYNUM.toString(10)") );
62
63 new TestCase(SECTION,
64 "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)",
65 "NaN",
66 eval("var MYNUM = new Number(Number.NaN); MYNUM.toString(10)") );
67
68 new TestCase(SECTION,
69 "var MYNUM = new Number(Infinity); MYNUM.toString(10)",
70 "Infinity",
71 eval("var MYNUM = new Number(Infinity); MYNUM.toString(10)") );
72
73 new TestCase(SECTION,
74 "var MYNUM = new Number(-Infinity); MYNUM.toString(10)",
75 "-Infinity",
76 eval("var MYNUM = new Number(-Infinity); MYNUM.toString(10)") );
77
78 test();