1 var key; |
|
2 var count; |
|
3 |
1 |
|
2 var ScriptContext = javax.script.ScriptContext; |
4 print(count); |
3 print(count); |
5 |
4 |
6 switch (count) { |
5 switch (count) { |
7 // engine only |
6 // engine only |
8 case 1: |
7 case 1: |
9 if (key != 'value in engine') { |
8 if (key != 'value in engine') { |
10 throw "unexpected engine scope value"; |
9 throw "unexpected engine scope value"; |
11 } |
10 } |
12 if (context.getAttribute("key", context.GLOBAL_SCOPE ) != null) { |
11 if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != null) { |
13 throw "unexpected global scope value"; |
12 throw "unexpected global scope value"; |
14 } |
13 } |
15 break; |
14 break; |
16 |
15 |
17 // both scopes |
16 // both scopes |
18 case 2: |
17 case 2: |
19 if (key != 'value in engine') { |
18 if (key != 'value in engine') { |
20 throw "unexpected engine scope value"; |
19 throw "unexpected engine scope value"; |
21 } |
20 } |
22 if (context.getAttribute("key", context.GLOBAL_SCOPE ) != |
21 if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != |
23 "value in global") { |
22 "value in global") { |
24 throw "unexpected global scope value"; |
23 throw "unexpected global scope value"; |
25 } |
24 } |
26 break; |
25 break; |
27 |
26 |
28 // global only |
27 // global only |
29 case 3: |
28 case 3: |
30 if (key != 'value in global') { |
29 if (key != 'value in global') { |
31 throw "unexpected global scope value"; |
30 throw "unexpected global scope value"; |
32 } |
31 } |
33 if (context.getAttribute("key", context.GLOBAL_SCOPE ) != |
32 if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != |
34 "value in global") { |
33 "value in global") { |
35 throw "unexpected global scope value"; |
34 throw "unexpected global scope value"; |
36 } |
35 } |
37 break; |
36 break; |
38 |
37 |