Skip to content

Commit 2730775

Browse files
author
DreamAndDead
committed
basic c api test
1 parent bdad415 commit 2730775

File tree

6 files changed

+8
-118
lines changed

6 files changed

+8
-118
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
test:
2+
gcc -g -I$(CURDIR)/install/include -I$(CURDIR)/install/lib -ldl -lm -o test/test.out test/test.c $(CURDIR)/install/lib/liblua.a
3+
(cd test;./test.out;cd ..)
4+
5+
.PHONY: test

main.sh

-5
This file was deleted.

test.c

-110
This file was deleted.

script.lua test/script.lua

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-- script.lua
22
-- Receives a table, returns the sum of its components.
3+
34
io.write("The table the script received has:\n");
45
x = 0
56
for i = 1, #foo do

test/test.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ main(void)
5151

5252
luaL_openlibs(L); /* Load Lua libraries */
5353

54-
/* Load the file containing the script we are going to run */
5554
status = luaL_loadfile(L, "script.lua");
5655
if (status) {
5756
/* If something went wrong, error message is at the top of */
@@ -104,6 +103,8 @@ main(void)
104103
printf("Script returned: %.0f\n", sum);
105104

106105
lua_pop(L, 1); /* Take the returned value out of the stack */
106+
107+
107108
lua_close(L); /* Cya, Lua */
108109

109110
return 0;

test/test.lua

-2
This file was deleted.

0 commit comments

Comments
 (0)