Skip to content
Permalink
Browse files
Lua I/O test
  • Loading branch information
Sebastien Bourdeauducq committed Jun 3, 2012
1 parent 07ab4d2 commit db24317a156ccc1d20383ec3619c4c2a05fd9367
Showing with 14 additions and 2 deletions.
  1. +14 −2 main.c
16 main.c
@@ -11,15 +11,20 @@
#include <lauxlib.h>
#include <lualib.h>

//#define TEST_BASIC
//#define TEST_DIR
#define TEST_FILE

static void test_lua(void)
{
lua_State *L;

// /patchpool/nil - Cid and Lucy.fnp

L = luaL_newstate();
luaL_openlibs(L);
#ifdef TEST_BASIC
luaL_dostring(L, "for i=10,1,-1 do print(i) end\n");
#endif
#ifdef TEST_DIR
luaL_dostring(L, "function attrdir (path)\n"
" for file in lfs.dir(path) do\n"
" if file ~= \".\" and file ~= \"..\" then\n"
@@ -39,6 +44,13 @@ static void test_lua(void)
"end\n"
"\n"
"attrdir (\"/\")\n");
#endif
#ifdef TEST_FILE
luaL_dostring(L, "f = assert(io.open(\"/patchpool/nil - Cid and Lucy.fnp\"))\n"
"t = f:read(\"*all\")\n"
"print(t)\n"
"f:close()\n");
#endif
lua_close(L);
}

0 comments on commit db24317

Please sign in to comment.