~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-001.js

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

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