jdk/test/javax/script/Test5.js
author xdono
Thu, 30 Apr 2009 15:04:39 -0700
changeset 2691 bad7bbf42755
parent 2 90ce3da70b43
child 16038 de84354579d3
permissions -rw-r--r--
Added tag jdk7-b57 for changeset 93833fce07e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
var key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
var count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
print(count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
switch (count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
        // engine only
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
	case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
            if (key != 'value in engine') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
                throw "unexpected engine scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
            if (context.getAttribute("key", context.GLOBAL_SCOPE ) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
        // both scopes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
        case 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
            if (key != 'value in engine') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
                throw "unexpected engine scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
            if (context.getAttribute("key", context.GLOBAL_SCOPE ) != 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
                "value in global") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
        // global only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
        case 3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
            if (key != 'value in global') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
            if (context.getAttribute("key", context.GLOBAL_SCOPE ) != 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
                "value in global") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
            throw "unexpected count";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
}