tests/fail/demo_globals.lua

Sat, 21 Sep 2013 14:31:22 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 21 Sep 2013 14:31:22 +0100
changeset 143
a689e0187ef5
parent 57
3e148db7f933
permissions
-rw-r--r--

Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)

57
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 -- globals.lua
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 -- show all global variables
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local seen={}
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 function dump(t,i)
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 seen[t]=true
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local s={}
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 local n=0
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 for k in pairs(t) do
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 n=n+1 s[n]=k
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 end
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 table.sort(s)
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 for k,v in ipairs(s) do
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 print(i,v)
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 v=t[v]
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 if type(v)=="table" and not seen[v] then
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 dump(v,i.."\t")
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 end
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 end
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 dump(_G,"")
3e148db7f933 Add tests/ to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24

mercurial