aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test.lua23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/test.lua b/tests/test.lua
index ddc00fe..503e3f4 100755
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -36,6 +36,8 @@ end
36local V = _VERSION:gsub("^.*(%d+)%.(%d+)$", "%1%2") 36local V = _VERSION:gsub("^.*(%d+)%.(%d+)$", "%1%2")
37if jit then V = "jit" end 37if jit then V = "jit" end
38 38
39local is_puclua51 = (_VERSION == "Lua 5.1" and not jit)
40
39local mode = "global" 41local mode = "global"
40if arg[1] == "module" then 42if arg[1] == "module" then
41 mode = "module" 43 mode = "module"
@@ -576,7 +578,7 @@ ___''
576do 578do
577 print("io.write()", io.type(io.write("hello world\n"))) 579 print("io.write()", io.type(io.write("hello world\n")))
578 local f = assert(io.tmpfile()) 580 local f = assert(io.tmpfile())
579 print("file:write()", io.type(f:write("hello world\n"))) 581 print("io.tmpfile => file:write()", io.type(f:write("hello world\n")))
580 f:close() 582 f:close()
581end 583end
582 584
@@ -589,13 +591,18 @@ do
589 io.input("data.txt") 591 io.input("data.txt")
590 print("io.read()", io.read("n", "number", "l", "a")) 592 print("io.read()", io.read("n", "number", "l", "a"))
591 io.input(io.stdin) 593 io.input(io.stdin)
592 if mode ~= "module" then 594 if not is_puclua51 then
593 local f = assert(io.open("data.txt", "r")) 595 local f = assert(io.open("data.txt", "r"))
594 print("file:read()", f:read("*n", "*number", "*l", "*a")) 596 print("file:read()", f:read("*n", "*number", "*l", "*a"))
595 f:close() 597 f:close()
596 f = assert(io.open("data.txt", "r")) 598 f = assert(io.open("data.txt", "r"))
597 print("file:read()", f:read("n", "number", "l", "a")) 599 print("file:read()", f:read("n", "number", "l", "a"))
598 f:close() 600 f:close()
601 os.remove("data.txt")
602
603 local g = assert(io.open("data.txt", "w"))
604 print("io.open => file:write()", type(g:write("hello")))
605 g:close()
599 end 606 end
600 os.remove("data.txt") 607 os.remove("data.txt")
601end 608end