Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuptest.lua
More file actions
Latest commit
executable file
·93 lines (79 loc) · 2.81 KB
/
Copy pathpuptest.lua
File metadata and controls
executable file
·93 lines (79 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
-- $Id$
require"pluto"
permtable= { 1234 }
perms= { [1] =coroutine.yield, [2] =permtable }
functiontestcounter(counter)
locala=counter.cur()
counter.inc()
returncounter.cur() ==a+1
end
functiontestuvinthread(func)
localsuccess, result=coroutine.resume(func)
returnsuccessandresult==5
end
functiontest(rootobj)
localpassed=0
localtotal=0
localdotest=function(name,cond)
total=total+1
ifcondthen
print(name, " PASSED")
passed=passed+1
else
print(name, "* FAILED")
end
end
dotest("Boolean FALSE ", rootobj.testfalse==false)
dotest("Boolean TRUE ", rootobj.testtrue==true)
dotest("Number 7 ", rootobj.testseven==7)
dotest("String 'foobar' ", rootobj.testfoobar=="foobar")
dotest("Func returning 4 ", rootobj.testfuncreturnsfour() ==4)
dotest("Nil value ", rootobj.testnil==nil)
dotest("Thread resume ", coroutine.resume(rootobj.testthread) ==true,14)
dotest("Table ", rootobj.testtbl.a==2androotobj.testtbl[2] ==4);
dotest("Permanent table ", rootobj.testperm==permtable)
dotest("Table metatable ", rootobj.testmt() ==21)
dotest("Function env ", rootobj.testfenv() ==456)
dotest("Lua closure ", rootobj.testclosure() ==11)
dotest("Nil in closure ", rootobj.testnilclosure() ==nil)
dotest("Nested func ", rootobj.testnest(1) ==6)
dotest("Light userdata ", checkludata(rootobj.testludata))
dotest("Looped tables ",
rootobj.testlooptable.testloopb.testloopa==
rootobj.testlooptable)
dotest("Shared reference ", rootobj.testsharedrefa.sharedref==
rootobj.testsharedrefb.sharedref)
dotest("Identical tables ", rootobj.testsharedrefa~=
rootobj.testsharedrefb)
dotest("Table special persist", rootobj.testsptable.a==6)
dotest("Udata literal persist",
unboxinteger(rootobj.testliteraludata) ==71)
dotest("Udata special persist",
unboxboolean(rootobj.testspudata1) ==trueand
unboxboolean(rootobj.testspudata2) ==false)
dotest("Shared upvalues ",
testcounter(rootobj.testsharedupval))
dotest("Open upvalues ",
testuvinthread(rootobj.testuvinthread))
dotest("Upvalue cycles ",
rootobj.testuvcycle()[1] ==rootobj.testuvcycle()[2])
dotest("__newindex metamethod", rootobj.testniinmt.a==3)
dotest("Debug info ", (rootobj.testdebuginfo(2)) =="foo")
print()
ifpassed==totalthen
print("All tests passed.")
else
print(passed.."/" ..total.." tests passed.")
end
end
infile, err=io.open("test.plh", "rb")
ifinfile==nilthen
error("While opening: " .. (error"no error"))
end
buf, err=infile:read("*a")
ifbuf==nilthen
error("While reading: " .. (error"no error"))
end
infile:close()
rootobj=pluto.unpersist(perms, buf)
test(rootobj)