duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 1 | |
sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 2 | var ScriptContext = javax.script.ScriptContext; |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 3 | print(count); |
| 4 | |
| 5 | switch (count) { |
| 6 | // engine only |
| 7 | case 1: |
| 8 | if (key != 'value in engine') { |
| 9 | throw "unexpected engine scope value"; |
| 10 | } |
sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 11 | if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != null) { |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 12 | throw "unexpected global scope value"; |
| 13 | } |
| 14 | break; |
| 15 | |
| 16 | // both scopes |
| 17 | case 2: |
| 18 | if (key != 'value in engine') { |
| 19 | throw "unexpected engine scope value"; |
| 20 | } |
sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 21 | if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 22 | "value in global") { |
| 23 | throw "unexpected global scope value"; |
| 24 | } |
| 25 | break; |
| 26 | |
| 27 | // global only |
| 28 | case 3: |
| 29 | if (key != 'value in global') { |
| 30 | throw "unexpected global scope value"; |
| 31 | } |
sundar | affd2db | 2013-02-27 17:22:44 +0530 | [diff] [blame] | 32 | if (context.getAttribute("key", ScriptContext.GLOBAL_SCOPE ) != |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 33 | "value in global") { |
| 34 | throw "unexpected global scope value"; |
| 35 | } |
| 36 | break; |
| 37 | |
| 38 | default: |
| 39 | throw "unexpected count"; |
| 40 | break; |
| 41 | } |