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

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-010.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:          try-010.js
 
3
 *  ECMA Section:
 
4
 *  Description:        The try statement
 
5
 *
 
6
 *  This has a try block nested in the try block.  Verify that the
 
7
 *  exception is caught by the right try block, and all finally blocks
 
8
 *  are executed.
 
9
 *
 
10
 *  Author:             christine@netscape.com
 
11
 *  Date:               11 August 1998
 
12
 */
 
13
    var SECTION = "try-010";
 
14
    var VERSION = "ECMA_2";
 
15
    var TITLE   = "The try statement: try in a tryblock";
 
16
 
 
17
    startTest();
 
18
    writeHeaderToLog( SECTION + " "+ TITLE);
 
19
 
 
20
    var tc = 0;
 
21
    var testcases = new Array();
 
22
 
 
23
    var EXCEPTION_STRING = "Exception thrown: ";
 
24
    var NO_EXCEPTION_STRING = "No exception thrown:  ";
 
25
 
 
26
 
 
27
    NestedTry( new TryObject( "No Exceptions Thrown",  NoException, NoException, 43 ) );
 
28
    NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 ));
 
29
    NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 ));
 
30
    NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 ));
 
31
 
 
32
    test();
 
33
 
 
34
    function TryObject( description, tryOne, tryTwo, result ) {
 
35
        this.description = description;
 
36
        this.tryOne = tryOne;
 
37
        this.tryTwo = tryTwo;
 
38
        this.result = result;
 
39
    }
 
40
    function ThrowException() {
 
41
        throw EXCEPTION_STRING + this.value;
 
42
    }
 
43
    function NoException() {
 
44
        return NO_EXCEPTION_STRING + this.value;
 
45
    }
 
46
    function NestedTry( object ) {
 
47
        result = 0;
 
48
        try {
 
49
            object.tryOne();
 
50
            result += 1;
 
51
            try {
 
52
                object.tryTwo();
 
53
                result += 2;
 
54
            } catch ( e ) {
 
55
                result +=4;
 
56
            } finally {
 
57
                result += 8;
 
58
            }
 
59
        } catch ( e ) {
 
60
            result += 16;
 
61
        } finally {
 
62
            result += 32;
 
63
        }
 
64
 
 
65
        testcases[tc++] = new TestCase(
 
66
            SECTION,
 
67
            object.description,
 
68
            object.result,
 
69
            result );
 
70
    }