summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshmuz <shmuz>2006-11-29 19:33:05 +0000
committershmuz <shmuz>2006-11-29 19:33:05 +0000
commit352e64ad1577c67ca25ddd13153724807a940c5a (patch)
treea0a6799e2a94e8d86115fd3228b738ad50a574ec /test
parent0f7cd94c0e15225205904755534c98687a1c32ad (diff)
downloadlrexlib-352e64ad1577c67ca25ddd13153724807a940c5a.tar.gz
Method renamed: oldmatch to tfind.
Method renamed: oldgmatch to tgfind.
Diffstat (limited to 'test')
-rwxr-xr-xtest/Spencer/test.lua2
-rwxr-xr-xtest/all_test.lua7
-rwxr-xr-xtest/pcre_test.lua28
-rwxr-xr-xtest/posix_test.lua22
4 files changed, 32 insertions, 27 deletions
diff --git a/test/Spencer/test.lua b/test/Spencer/test.lua
index a0c1442..5ce22e4 100755
--- a/test/Spencer/test.lua
+++ b/test/Spencer/test.lua
@@ -134,7 +134,7 @@ local function DoOneTest(line, lineno)
end
local function Match(expr)
- local s,e,t = expr:oldmatch(Prop.f3, Start, Eflags)
+ local s,e,t = expr:tfind(Prop.f3, Start, Eflags)
if Mustfail and s or not Mustfail and not s then
return Error("match result is not as expected")
end
diff --git a/test/all_test.lua b/test/all_test.lua
index dbba196..886e373 100755
--- a/test/all_test.lua
+++ b/test/all_test.lua
@@ -4,8 +4,13 @@ require "posix_test"
require "pcre_test"
do
+ local arg1 = ...
+ local verbose = (arg1 == "-v")
local oldprint = print
- print = function() end -- make it silent
+ if not verbose then
+ print = function() end
+ end
+
local n = 0
n = n + pcre_test.testlib ("rex_pcre")
n = n + pcre_test.testlib ("rex_pcre_nr")
diff --git a/test/pcre_test.lua b/test/pcre_test.lua
index 3a23953..5df3569 100755
--- a/test/pcre_test.lua
+++ b/test/pcre_test.lua
@@ -51,9 +51,9 @@ function testlib (libname)
end
}
- local set_m_oldgmatch = {
- -- r:oldgmatch (s, f, [n], [ef])
- SetName = "Method oldgmatch",
+ local set_m_tgfind = {
+ -- r:tgfind (s, f, [n], [ef])
+ SetName = "Method tgfind",
Test = "custom",
Func = function (lib)
local r = lib.new ("(.)b.(d)")
@@ -64,11 +64,11 @@ function testlib (libname)
local decr = function (m, t)
if m == "abcd" and fw.eq (t, {"a","d"}) then rep = rep - 1 end
end
- r:oldgmatch (subj, decr)
+ r:tgfind (subj, decr)
if rep ~= 0 then return 1 end
-------- 2: limiting number of matches in advance
rep, n = 10, 4
- r:oldgmatch (subj, decr, n)
+ r:tgfind (subj, decr, n)
if rep + n ~= 10 then return 1 end
-------- 3: break iterations from the callback
rep = 10
@@ -76,11 +76,11 @@ function testlib (libname)
decr (m, t)
if rep == 3 then return true end
end
- r:oldgmatch (subj, f2)
+ r:tgfind (subj, f2)
if rep ~= 3 then return 1 end
-------- 4: named subpatterns
r = lib.new ("(?P<dog>.)b.(?P<cat>d)")
- rep = r:oldgmatch (subj,
+ rep = r:tgfind (subj,
function (m, t)
if t.dog ~= "a" or t.cat ~= "d" then return true end
end)
@@ -90,11 +90,11 @@ function testlib (libname)
}
local set_named_subpatterns = {
- SetName = "Named Subpatterns (method oldmatch)",
+ SetName = "Named Subpatterns (method tfind)",
Test = "custom",
Func = function (lib)
local r = lib.new ("(?P<dog>.)b.(?P<cat>d)")
- local _,_,caps = r:oldmatch ("abcd")
+ local _,_,caps = r:tfind ("abcd")
if caps.dog ~= "a" or caps.cat ~= "d" then return 1 end
return 0
end
@@ -205,9 +205,9 @@ function testlib (libname)
{ { "(.)b.(d)"}, {"abcd"}, {1,4,{1,1,4,4},3}},--[captures]
}
- local set_m_oldmatch = {
- SetName = "Method oldmatch",
- FMName = "oldmatch",
+ local set_m_tfind = {
+ SetName = "Method tfind",
+ FMName = "tfind",
Test = "method",
-- {patt,cf,lo}, {subj,st,ef,co} { results }
{ {".+"}, {"abcd"}, {1,4,{},1} }, -- [none]
@@ -276,10 +276,10 @@ function testlib (libname)
n = n + fw.test2 (lib, set_m_match)
n = n + fw.test2 (lib, set_m_find)
n = n + fw.test2 (lib, set_m_exec)
- n = n + fw.test2 (lib, set_m_oldmatch)
+ n = n + fw.test2 (lib, set_m_tfind)
n = n + fw.test2 (lib, set_f_gmatch)
n = n + fw.test2 (lib, set_m_gmatch)
- n = n + fw.test2 (lib, set_m_oldgmatch)
+ n = n + fw.test2 (lib, set_m_tgfind)
n = n + fw.test2 (lib, set_named_subpatterns)
if lib.MAJOR >= 6 then
diff --git a/test/posix_test.lua b/test/posix_test.lua
index a9e646d..4a261b5 100755
--- a/test/posix_test.lua
+++ b/test/posix_test.lua
@@ -42,9 +42,9 @@ function testlib (libname)
end
}
- local set_m_oldgmatch = {
- -- r:oldgmatch (s, f, [n], [ef])
- SetName = "Method oldgmatch",
+ local set_m_tgfind = {
+ -- r:tgfind (s, f, [n], [ef])
+ SetName = "Method tgfind",
Test = "custom",
Func = function (lib)
local r = lib.new ("(.)b.(d)")
@@ -55,11 +55,11 @@ function testlib (libname)
local decr = function (m, t)
if m == "abcd" and fw.eq (t, {"a","d"}) then rep = rep - 1 end
end
- r:oldgmatch (subj, decr)
+ r:tgfind (subj, decr)
if rep ~= 0 then return 1 end
-------- 2: limiting number of matches in advance
rep, n = 10, 4
- r:oldgmatch (subj, decr, n)
+ r:tgfind (subj, decr, n)
if rep + n ~= 10 then return 1 end
-------- 3: break iterations from the callback
rep = 10
@@ -67,7 +67,7 @@ function testlib (libname)
decr (m, t)
if rep == 3 then return true end
end
- r:oldgmatch (subj, f2)
+ r:tgfind (subj, f2)
if rep ~= 3 then return 1 end
return 0
end
@@ -158,9 +158,9 @@ function testlib (libname)
{ { "(.)b.(d)"}, {"abcd"}, {1,4,{1,1,4,4},0}},--[captures]
}
- local set_m_oldmatch = {
- SetName = "Method oldmatch",
- FMName = "oldmatch",
+ local set_m_tfind = {
+ SetName = "Method tfind",
+ FMName = "tfind",
Test = "method",
-- {patt,cf}, {subj,st,ef} { results }
{ {".+"}, {"abcd"}, {1,4,{},0} }, -- [none]
@@ -201,10 +201,10 @@ function testlib (libname)
n = n + fw.test2 (lib, set_m_match)
n = n + fw.test2 (lib, set_m_find)
n = n + fw.test2 (lib, set_m_exec)
- n = n + fw.test2 (lib, set_m_oldmatch)
+ n = n + fw.test2 (lib, set_m_tfind)
n = n + fw.test2 (lib, set_f_gmatch)
n = n + fw.test2 (lib, set_m_gmatch)
- n = n + fw.test2 (lib, set_m_oldgmatch)
+ n = n + fw.test2 (lib, set_m_tgfind)
print ""
return n
end