tests/pass/gmatch.lua

Sat, 21 Sep 2013 14:02:16 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 21 Sep 2013 14:02:16 +0100
changeset 142
574e0baea136
parent 126
07ec490c7a6f
permissions
-rw-r--r--

Add math.frexp() and tests (many thanks to Florob and Link Mauve!)

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