From 739b5c1888b38b2580adbe52a42b86372a7d146b Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 16 Feb 2017 11:55:54 +0100 Subject: lua_pushnumber, lua_pushinteger, lua_pushstring, lua_pushboolean --- tests/C/Makefile | 7 +++++-- tests/C/lua_pushboolean.c | 21 +++++++++++++++++++++ tests/C/lua_pushinteger.c | 21 +++++++++++++++++++++ tests/C/lua_pushnumber.c | 2 +- tests/C/lua_pushstring.c | 21 +++++++++++++++++++++ 5 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 tests/C/lua_pushboolean.c create mode 100644 tests/C/lua_pushinteger.c create mode 100644 tests/C/lua_pushstring.c (limited to 'tests/C') diff --git a/tests/C/Makefile b/tests/C/Makefile index 28ff1c2..bc153a5 100644 --- a/tests/C/Makefile +++ b/tests/C/Makefile @@ -4,5 +4,8 @@ CFLAGS= -g -Wall -Wextra LIBS= -lm -llua all: - $(CC) $(CFLAGS) $(LIBS) lua_pushnil.c -o lua_pushnil.out - $(CC) $(CFLAGS) $(LIBS) lua_pushnumber.c -o lua_pushnumber.out \ No newline at end of file + $(CC) $(CFLAGS) $(LIBS) lua_pushnil.c -o lua_pushnil.out + $(CC) $(CFLAGS) $(LIBS) lua_pushnumber.c -o lua_pushnumber.out + $(CC) $(CFLAGS) $(LIBS) lua_pushinteger.c -o lua_pushinteger.out + $(CC) $(CFLAGS) $(LIBS) lua_pushstring.c -o lua_pushstring.out + $(CC) $(CFLAGS) $(LIBS) lua_pushboolean.c -o lua_pushboolean.out \ No newline at end of file diff --git a/tests/C/lua_pushboolean.c b/tests/C/lua_pushboolean.c new file mode 100644 index 0000000..d592691 --- /dev/null +++ b/tests/C/lua_pushboolean.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include + +int main(void) { + + lua_State *L = luaL_newstate(); + + luaL_openlibs(L); + + lua_pushboolean(L, 1); + + printf("L->top(%d): %s\n", lua_gettop(L), luaL_typename(L, lua_gettop(L))); + + lua_close(L); + + return 0; + +} \ No newline at end of file diff --git a/tests/C/lua_pushinteger.c b/tests/C/lua_pushinteger.c new file mode 100644 index 0000000..0c9a49f --- /dev/null +++ b/tests/C/lua_pushinteger.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include + +int main(void) { + + lua_State *L = luaL_newstate(); + + luaL_openlibs(L); + + lua_pushinteger(L, 10); + + printf("L->top(%d): %s\n", lua_gettop(L), luaL_typename(L, lua_gettop(L))); + + lua_close(L); + + return 0; + +} \ No newline at end of file diff --git a/tests/C/lua_pushnumber.c b/tests/C/lua_pushnumber.c index eca2564..697258f 100644 --- a/tests/C/lua_pushnumber.c +++ b/tests/C/lua_pushnumber.c @@ -10,7 +10,7 @@ int main(void) { luaL_openlibs(L); - lua_pushnumber(L, 10); + lua_pushnumber(L, 10.5); printf("L->top(%d): %s\n", lua_gettop(L), luaL_typename(L, lua_gettop(L))); diff --git a/tests/C/lua_pushstring.c b/tests/C/lua_pushstring.c new file mode 100644 index 0000000..fc675c7 --- /dev/null +++ b/tests/C/lua_pushstring.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include + +int main(void) { + + lua_State *L = luaL_newstate(); + + luaL_openlibs(L); + + lua_pushstring(L, "hello"); + + printf("L->top(%d): %s\n", lua_gettop(L), luaL_typename(L, lua_gettop(L))); + + lua_close(L); + + return 0; + +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf