| 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-001.js'; |
| 7 | |
| 8 | /** |
| 9 | File Name: number-001 |
| 10 | Corresponds To: 15.7.4.2-2-n.js |
| 11 | ECMA Section: 15.7.4.2.2 Number.prototype.toString() |
| 12 | Description: |
| 13 | If the radix is the number 10 or not supplied, then this number value is |
| 14 | given as an argument to the ToString operator; the resulting string value |
| 15 | is returned. |
| 16 | |
| 17 | If the radix is supplied and is an integer from 2 to 36, but not 10, the |
| 18 | result is a string, the choice of which is implementation dependent. |
| 19 | |
| 20 | The toString function is not generic; it generates a runtime error if its |
| 21 | this value is not a Number object. Therefore it cannot be transferred to |
| 22 | other kinds of objects for use as a method. |
| 23 | |
| 24 | Author: [email protected] |
| 25 | Date: 16 september 1997 |
| 26 | */ |
| 27 | var SECTION = "number-001"; |
| 28 | var VERSION = "JS1_4"; |
| 29 | var TITLE = "Exceptions for Number.toString()"; |
| 30 | |
| 31 | startTest(); |
| 32 | writeHeaderToLog( SECTION + " Number.prototype.toString()"); |
| 33 | |
| 34 | var result = "Failed"; |
| 35 | var exception = "No exception thrown"; |
| 36 | var expect = "Passed"; |
| 37 | |
| 38 | try { |
| 39 | object= new Object(); |
| 40 | object.toString = Number.prototype.toString; |
| 41 | result = object.toString(); |
| 42 | } catch ( e ) { |
| 43 | result = expect; |
| 44 | exception = e.toString(); |
| 45 | } |
| 46 | |
| 47 | new TestCase( |
| 48 | SECTION, |
| 49 | "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + |
| 50 | " (threw " + exception +")", |
| 51 | expect, |
| 52 | result ); |
| 53 | |
| 54 | test(); |