tests/pass/gmatch.lua

Mon, 22 Nov 2010 04:56:38 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 22 Nov 2010 04:56:38 +0000
changeset 126
07ec490c7a6f
permissions
-rw-r--r--

Add a whole bunch of tests I've been using for recent additions

local i = 1;
local s = "the rain in spain stays mainly in the plain";
local st = { "the", "rain", "in", "spain", "stays", "mainly", "in", "the", "plain" };
for word in string.gmatch(s, "%a+") do
	print(word)
	assert(word == st[i], word.." == "..st[i]);
	i = i + 1;
end

assert(i == 10, i.." == 10");

mercurial