tests/pass/gmatch.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 i = 1;
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local s = "the rain in spain stays mainly in the plain";
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local st = { "the", "rain", "in", "spain", "stays", "mainly", "in", "the", "plain" };
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 for word in string.gmatch(s, "%a+") do
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 print(word)
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 assert(word == st[i], word.." == "..st[i]);
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 i = i + 1;
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 end
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9
07ec490c7a6f Add a whole bunch of tests I've been using for recent additions
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 assert(i == 10, i.." == 10");

mercurial