diff options
author | Reuben Thomas <rrt@sc3d.org> | 2010-07-30 18:20:59 +0100 |
---|---|---|
committer | Reuben Thomas <rrt@sc3d.org> | 2010-07-30 18:20:59 +0100 |
commit | 8af4a80821486b43062b47edcc47336e8712b001 (patch) | |
tree | 782e1c8e0b030c29c10a3764d5b642fb45db8f72 /test | |
parent | 8dfd794540c01ea61b9bd43f7da363d8b1503e7b (diff) | |
download | lrexlib-8af4a80821486b43062b47edcc47336e8712b001.tar.gz |
Add GNU-specific test (of translation tables).
Diffstat (limited to 'test')
-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" }, |