]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | /** |
2 | File Name: number-003.js | |
3 | Corresponds To: 15.7.4.3-3.js | |
4 | ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() | |
5 | Description: | |
6 | Returns this number value. | |
7 | ||
8 | The valueOf function is not generic; it generates a runtime error if its | |
9 | this value is not a Number object. Therefore it cannot be transferred to | |
10 | other kinds of objects for use as a method. | |
11 | ||
12 | Author: christine@netscape.com | |
13 | Date: 16 september 1997 | |
14 | */ | |
15 | var SECTION = "number-003"; | |
16 | var VERSION = "JS1_4"; | |
17 | var TITLE = "Exceptions for Number.valueOf()"; | |
18 | ||
19 | var tc = 0; | |
20 | var testcases = new Array(); | |
21 | ||
22 | startTest(); | |
23 | writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); | |
24 | ||
25 | var result = "Failed"; | |
26 | var exception = "No exception thrown"; | |
27 | var expect = "Passed"; | |
28 | ||
29 | try { | |
30 | VALUE_OF = Number.prototype.valueOf; | |
31 | OBJECT = new String("Infinity"); | |
32 | OBJECT.valueOf = VALUE_OF; | |
33 | result = OBJECT.valueOf(); | |
34 | } catch ( e ) { | |
35 | result = expect; | |
36 | exception = e.toString(); | |
37 | } | |
38 | ||
39 | testcases[tc++] = new TestCase( | |
40 | SECTION, | |
41 | "Assigning Number.prototype.valueOf as the valueOf of a String object " + | |
42 | " (threw " + exception +")", | |
43 | expect, | |
44 | result ); | |
45 | ||
46 | test(); | |
47 |