]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Exceptions/number-002.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma_2 / Exceptions / number-002.js
1 /**
2 File Name: number-002.js
3 Corresponds To: ecma/Number/15.7.4.3-2-n.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-002";
16 var VERSION = "JS1_4";
17 var TITLE = "Exceptions for Number.valueOf()";
18
19 startTest();
20 writeHeaderToLog( SECTION + " Number.prototype.valueOf()");
21
22 var testcases = new Array();
23 var tc = 0;
24
25 var result = "Failed";
26 var exception = "No exception thrown";
27 var expect = "Passed";
28
29 try {
30 object= new Object();
31 object.toString = Number.prototype.valueOf;
32 result = object.toString();
33 } catch ( e ) {
34 result = expect;
35 exception = e.toString();
36 }
37
38 testcases[tc++] = new TestCase(
39 SECTION,
40 "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" +
41 " (threw " + exception +")",
42 expect,
43 result );
44
45 test();