Warning: file_get_contents(http://localhost:8000/calc?cmd=174&userid=0&debug=1): failed to open stream: Cannot assign requested address in /var/www/tb/show-snippet.php on line 158
Nested sandboxes (test case) [174]

Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

15
LINES

< > BotCompany Repo | #174 // Nested sandboxes (test case)

Lua code - System test

env = newCleanEnv()
load([[
  x = 1
  env2 = newCleanEnv()
  load("x=2", "", "t", env2)()
  assert(x == 1, x)
  assert(env2.x == 2)
  
  -- now with nil env - must default to env (not outer sandbox)
  load("x=3")()
  assert(x == 3, x)
]], "", "t", env)()
assert(x == nil)
assert(env.x == 3, env.x)
return true

Author comment

Began life as a copy of #173

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
644 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
env = newCleanEnv()
load([[
x = 1
env2 = newCleanEnv()
load("x=2", "", "t", env2)()
assert(x == 1, x)
assert(env2.x == 2)

-- now with nil env - must default to env (not outer sandbox)
load("x=3")()
assert(x == 3, x)
]], "", "t", env)()
assert(x == nil)
assert(env.x == 3, env.x)
return true
}}
2015-08-19 02:32:06  delete 
642 #1000604 (pitcher) 2015-08-18 00:07:22

add comment

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 323 [visualize]

Snippet ID: #174
Snippet name: Nested sandboxes (test case)
Eternal ID of this version: #174/1
Text MD5: 99d331e7f8b502dd3f08305f525b42ca
Author: stefan
Category: system tests
Type: Lua code - System test
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2014-01-15 23:36:12
Source code size: 323 bytes / 15 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1256 / 198
Referenced in: [show references]