-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_luapp.hlua
executable file
·96 lines (78 loc) · 1.99 KB
/
test_luapp.hlua
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
94
95
96
local errfmt = require'errfmt'
local zpp = require'zpp'
local pp = require'luapp'.pp
-- ### Simple PP Tests
---[[---------------
print$pp(_G,'_G')
print'++++++++++++'
io.flush()
print$pp({1,2,nil,4,[11]=3},nil,20,1)
print"++++++++++++"
--]]---------------
-- ### Errfmt Tests
---[[------------
print"+++ errfmt +++"
print$pcall$=>pp(zpp.text("I'am expected error"),2,3,"ok")
print"*this was expected error*\n"
function errfmt_test()
local fun boo
| 1,2,3 -> return ...;
end
local fun goo
| 1,2,3 -> 111
end
local Tip_mt = {}
Tip_mt.__index = Tip_mt
Tip_mt.type = =>'Tip'
local Tip = fun(o:'tab') -> setmetatable(o,Tip_mt) end
local hush = fn(x)=>print$pcall$x end
hush$=>boo(`A{"One",Tip{1},3,4,5,6,7,8,9,0,1,2,3},"e",12)
hush$=>boo(`A{1,2,3},Tip{2})
hush$=>boo(`A{1,2,3},"e",1,2,3)
hush$=>goo(`A{1,2,3,4,5,6,7,8,9,0,1,2,3},"e",12)
hush$=>goo(`A{1,2,3},"e")
hush$=>goo(`A{1,2,3},Tip{3},1,2,3)
end
errfmt_test()
print"++++++++++++"
print$pcall$=>pp(zpp.text("Hello"),2,3,"ok")
print"++++++++++++"
--]]------------
print$"key userdata ------------>"
local tab = {}
tab[newproxy()] = newproxy()
print$pp$tab
print$"key userdata <------------"
print"conses ----------->"
------------------------------------------------------------------------
print$pp${[1::[]]="List-Key"}
print$pp${[ [] ]="List-Key"}
print$pp$(1::2::3::[])
print$pp$(1::2::3::{"improper"})
print$pp$(1::2::3::1::2::3::{
{1,2,3},{4,5,6},{7,8,9},{0,1,2,3,4,5,6,7,8,9,0}
})
print$pp{1,2}
print$pp{1,{2,3}}
print$pp{1,{2,{3,4}}}
local fun setcadr lst@(_::_::_), y ->
lst[2][1]=y
return lst
end
local fun setcar lst@(_::_),y ->
lst[1]=y
return lst
end
local xs = [1,2,3,4]
setcadr(xs,xs[2])
print$pp(xs)
local xs = [1,2,3,4]
setcar(xs,xs)
print$pp(xs)
print('NULL',pp([]))
------------------------------------------------------------------------
print"conses <-----------"
-- misc
print$pp{1,[-1]=-1;2,[0]=0;a='a',3,['$']='$'}
local (\) = zpp.text
print$pp(\1 - \2 - \3 - \4 - \5 - \6 - \7)