jdk/test/javax/script/Test5.js
author sundar
Wed, 27 Feb 2013 17:22:44 +0530
changeset 16038 de84354579d3
parent 2 90ce3da70b43
permissions -rw-r--r--
8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
     2
var ScriptContext = javax.script.ScriptContext;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
print(count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
switch (count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
        // engine only
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
	case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
            if (key != 'value in engine') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
                throw "unexpected engine scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
            }
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
    11
            if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
        // both scopes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
        case 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
            if (key != 'value in engine') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
                throw "unexpected engine scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
            }
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
    21
            if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
                "value in global") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
        // global only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
        case 3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
            if (key != 'value in global') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
            }
16038
de84354579d3 8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
sundar
parents: 2
diff changeset
    32
            if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
                "value in global") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
                throw "unexpected global scope value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
            throw "unexpected count";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
}