Debian Codegraph @

rhino/testsrc/tests/ecma_2/Exceptions/number-002.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 = 'number-002.js';
7
8 /**
9 File Name: number-002.js
10 Corresponds To: ecma/Number/15.7.4.3-2-n.js
11 ECMA Section: 15.7.4.3.1 Number.prototype.valueOf()
12 Description:
13 Returns this number value.
14
15 The valueOf function is not generic; it generates a runtime error if its
16 this value is not a Number object. Therefore it cannot be transferred to
17 other kinds of objects for use as a method.
18
19 Author: [email protected]
20 Date: 16 september 1997
21 */
22 var SECTION = "number-002";
23 var VERSION = "JS1_4";
24 var TITLE = "Exceptions for Number.valueOf()";
25
26 startTest();
27 writeHeaderToLog( SECTION + " Number.prototype.valueOf()");
28
29 var result = "Failed";
30 var exception = "No exception thrown";
31 var expect = "Passed";
32
33 try {
34 object= new Object();
35 object.toString = Number.prototype.valueOf;
36 result = object.toString();
37 } catch ( e ) {
38 result = expect;
39 exception = e.toString();
40 }
41
42 new TestCase(
43 SECTION,
44 "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" +
45 " (threw " + exception +")",
46 expect,
47 result );
48
49 test();