diff options
-rwxr-xr-x | test/gnu_sets.lua | 38 | ||||
-rwxr-xr-x | test/runtest.lua | 2 |
2 files changed, 39 insertions, 1 deletions
diff --git a/test/gnu_sets.lua b/test/gnu_sets.lua new file mode 100755 index 0000000..cd8f689 --- /dev/null +++ b/test/gnu_sets.lua @@ -0,0 +1,38 @@ +-- See Copyright Notice in the file LICENSE + +-- This file should contain only test sets that behave identically +-- when being run with pcre or posix regex libraries. + +local luatest = require "luatest" +local N = luatest.NT + +local function norm(a) return a==nil and N or a end + +local function set_f_gmatch (lib, flg) + local downcase = {} + for i = 0, 255 do -- 255 == UCHAR_MAX + downcase[i] = string.gsub(string.char (i), ".", function (s) return string.lower(s) end) + end + -- gmatch (s, p, [cf], [ef], [tr]) + local function test_gmatch (subj, patt) + local out, guard = {}, 10 + for a, b in lib.gmatch (subj, patt, nil, nil, downcase) do + table.insert (out, { norm(a), norm(b) }) + guard = guard - 1 + if guard == 0 then break end + end + return unpack (out) + end + return { + Name = "Function gmatch", + Func = test_gmatch, + --{ subj patt results } + { {"abA", "a"}, {{"a",N}, {"A",N} } }, + } +end +return function (libname) + local lib = require (libname) + return { + set_f_gmatch (lib), + } +end diff --git a/test/runtest.lua b/test/runtest.lua index 06616c3..354b50e 100755 --- a/test/runtest.lua +++ b/test/runtest.lua @@ -37,7 +37,7 @@ local function test_library (libname, setfile, verbose) end local avail_tests = { - gnu = { lib = "rex_gnu", "common_sets", "emacs_sets", }, -- N.B. emacs_sets must come last as it globally sets the syntax + gnu = { lib = "rex_gnu", "common_sets", "emacs_sets", "gnu_sets" }, posix = { lib = "rex_posix", "common_sets", "posix_sets", }, spencer = { lib = "rex_spencer", "common_sets", "posix_sets", "spencer_sets" }, posix1 = { lib = "rex_posix1", "common_sets", "posix_sets", "spencer_sets" }, |