Skip to content
Permalink
Browse files
lua-nucleo/strict: added declare(_PROMPT) for interactive mode
test/cases/0420-code-foreign-globals-luajit2: added test for missing _PROMPT
test/cases/0430-code-foreign-globals-lua5_1: added test for missing _PROMPT
  • Loading branch information
vstebunov committed Sep 17, 2013
1 parent 3a7e9ab commit fb918f6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
@@ -44,6 +44,9 @@ if getmetatable(_G) ~= nil then
error("_G already got metatable")
end

-- NOTE: declare _PROMPT global variable for interactive mode
declare('_PROMPT')

setmetatable(_G, {
__index = function(t, k)
if declared[k] then
@@ -4,10 +4,29 @@
-- Copyright (c) lua-nucleo authors (see file `COPYRIGHT` for the license)
--------------------------------------------------------------------------------

-- TODO: Add description!
-- TODO: Write tests!
-- #tmp679
local make_suite = assert(loadfile('test/test-lib/init/strict-import-as-require.lua'))(...)

--------------------------------------------------------------------------------

local make_suite = assert(loadfile('test/test-lib/init/strict.lua'))(...)
local test = make_suite("code_foreign_globals_luajit2")
test:TODO "write tests"

--------------------------------------------------------------------------------

local shell_write,
shell_read
= import 'lua-aplicado/shell.lua'
{
'shell_write',
'shell_read'
}
local ensure_equals = import 'lua-nucleo/ensure.lua' { 'ensure_equals' }

-- TODO: Add check error message when maked next ticket
-- https://github.com/lua-aplicado/lua-aplicado/issues/34
test 'global_variable__PROMPT_error_on_load_in_interactive_mode' (function ()
local ok, _ = pcall(shell_read, "which","luajit")
ensure_equals('Interpreter not found!', ok, true)
-- NOTE: _PROMPT created when lua in interactive mode
local _, msg = pcall(shell_write, 'require "lua-nucleo"', "luajit", "-i")
ensure_equals('Lua failed on start in intarective mode', msg, nil)
end)
@@ -4,10 +4,21 @@
-- Copyright (c) lua-nucleo authors (see file `COPYRIGHT` for the license)
--------------------------------------------------------------------------------

-- TODO: Add description!
-- TODO: Write tests!
-- #tmp680
local make_suite = assert(loadfile('test/test-lib/init/strict-import-as-require.lua'))(...)

--------------------------------------------------------------------------------

local make_suite = assert(loadfile('test/test-lib/init/strict.lua'))(...)
local test = make_suite("code_foreign_globals_lua5_1")
test:TODO "write tests"

--------------------------------------------------------------------------------

local shell_write = import 'lua-aplicado/shell.lua' { 'shell_write' }
local ensure_equals = import 'lua-nucleo/ensure.lua' { 'ensure_equals' }

-- TODO: Add check error message when maked next ticket
-- https://github.com/lua-aplicado/lua-aplicado/issues/34
test 'global_variable__PROMPT_error_on_load_in_interactive_mode' (function ()
-- NOTE: _PROMPT created when lua in interactive mode
local _, msg = pcall(shell_write, 'require "lua-nucleo"', "lua", "-i")
ensure_equals('Lua failed on start in intarective mode', msg, nil)
end)

0 comments on commit fb918f6

Please sign in to comment.