Skip to content

Commit b504cf2

Browse files
committed
refactor(tests): update code to use main
1 parent 08455d8 commit b504cf2

File tree

10 files changed

+40
-10
lines changed

10 files changed

+40
-10
lines changed

tests/fail/array_index_string.err

Whitespace-only changes.

tests/fail/bad_if.err

Whitespace-only changes.

tests/fail/int_plus_string.err

Whitespace-only changes.

tests/fail/wrong_assign.err

Whitespace-only changes.

tests/pass/arith.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
os.exit((function(args)
2+
local a = 1
3+
local b = 2.5
4+
local c = (a + b)
5+
local x = 7
6+
local y = 3
7+
local z = (x % y)
8+
return x
9+
end)(arg))

tests/pass/arrays.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
os.exit((function(args)
2+
local arr = { 10, 20, 30 }
3+
arr[2] = 99
4+
local x = arr[1]
5+
return 0
6+
end)(arg))

tests/pass/logic.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
os.exit((function(args)
2+
local a = 1
3+
local b = 0.0
4+
if a and not b then
5+
print("ok")
6+
end
7+
return 0
8+
end)(arg))

tests/pass/printf.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
os.exit((function(args)
2+
local a = 42
3+
local b = 3.14
4+
print(string.format("Valor: %d e %f", a, b))
5+
print("fim")
6+
return 0
7+
end)(arg))

tests/pass/testes.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
int sum(int a, int b)
22
{
3-
return a + b;
3+
return a + b;
44
}
55

66
int main()
77
{
8-
int r = sum(1, 3);
9-
print_int(r); // assume que o runtime exporta print_int
10-
return 0;
8+
int r = sum(1, 3);
9+
print_int(r); // assume que o runtime exporta print_int
10+
return 0;
1111
}

tests/pass/testes.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
-- função gerada para sum
21
local function sum(a, b)
3-
return (a + b)
2+
return a + b
43
end
54

6-
-- main
7-
local r = sum(1, 3)
8-
io.write(tostring(r), "\n")
9-
-- return 0 (opcional no Lua)
5+
os.exit((function(args)
6+
local r = sum(1, 3)
7+
print(r)
8+
return 0
9+
end)(arg))

0 commit comments

Comments
 (0)