Debian Codegraph @

rhino/testsrc/tests/ecma_2/Exceptions/number-003.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-003.js';
7
8 /**
9 File Name: number-003.js
10 Corresponds To: 15.7.4.3-3.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-003";
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 VALUE_OF = Number.prototype.valueOf;
35 OBJECT = new String("Infinity");
36 OBJECT.valueOf = VALUE_OF;
37 result = OBJECT.valueOf();
38 } catch ( e ) {
39 result = expect;
40 exception = e.toString();
41 }
42
43 new TestCase(
44 SECTION,
45 "Assigning Number.prototype.valueOf as the valueOf of a String object " +
46 " (threw " + exception +")",
47 expect,
48 result );
49
50 test();
51