tests/pass/upvalue.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 126
07ec490c7a6f
permissions
-rw-r--r--

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

126
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local u;
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local f = {};
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 for i=1,2 do
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 f[i] = function (set)
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 if set then
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 u = set;
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 end
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 return u;
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 end;
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 end
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 assert(f[1]("foo") == "foo");
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 assert(f[2]() == "foo");
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 assert(f[2]("bar") == "bar");
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 assert(f[1]() == "bar");
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17

mercurial