Commit b4fa46fa authored by Jamie A. Jennings's avatar Jamie A. Jennings

Did more refactoring. Code is looking better, but still obfuscated in places....

Did more refactoring.  Code is looking better, but still obfuscated in places.  All tests pass.  TEST OUTPUT HAS CHANGED THOUGH, so cli-test.lua has been modified to reflect this.
parent 407b8da2
......@@ -625,12 +625,25 @@ end
local create_rplx
local function shallow_copy(tbl)
local new = {}; for k,v in pairs(tbl) do new[k] = v; end; return new;
end
-- NOTE: This is not exactly "lookup" because if it finds an alias, it wraps it
-- in a capture with the anonymous name "*". But, what is a better name for this?
local function lookup_rplx(self, localname, pkgname, is_local)
local pkgenv = pkgname and self.env:lookup(pkgname)
if not pkgenv then return nil; end
local pkgenv = self.env -- top level
if pkgname then
pkgenv = self.env:lookup(pkgname)
if not pkgenv then return nil; end
end
local pat = pkgenv:lookup(localname)
if not pat then return nil; end
if bool(pat.exported) == not bool(is_local) then
if pat.alias then
pat = shallow_copy(pat)
pat.peg = common.match_node_wrap(pat.peg, "*")
end
return create_rplx(self, pat)
end
return nil
......
This diff is collapsed.
......@@ -680,20 +680,21 @@ check(code == 252, "exit status differs from expected")
results_txt = table.concat(results, '\n')
check_lua_error(results_txt)
check(#results == 12, "wrong number of output lines (did not check each one)")
if #results == 12 then
check(#results == 13, "wrong number of output lines (did not check each one)")
if #results == 13 then
check(results[1]:find("local%-unit%-test.rpl"), "missing filename?")
check(results[2]:find("ERROR: pattern is exported"), "cannot use 'test local' on global")
check(results[3]:find("ERROR: pattern did not compile"), "pattern should not be defined")
check(results[4]:find("ERROR: pattern is local"))
check(results[5]:find("ERROR: pattern is local"))
check(results[6]:find("BLOCKED: "))
check(results[7]:find("ERROR: pattern is local"))
check(results[8]:find("BLOCKED: "))
check(results[9]:find("ERROR: pattern did not compile"))
check(results[3]:find("BLOCKED: 1 test of bar_is_global"))
check(results[4]:find("ERROR: pattern did not compile"), "pattern should not be defined")
check(results[5]:find("BLOCKED: 1 test of baz"))
check(results[6]:find("ERROR: pattern is local"))
check(results[7]:find("BLOCKED: 1 test of foo"))
check(results[8]:find("ERROR: pattern is local"))
check(results[9]:find("BLOCKED: 2 tests of foo"))
check(results[10]:find("ERROR: pattern did not compile"))
check(results[11]:find("FAILED: foo did not accept"))
check(results[12]:find("Tests: 13 Errors: 5 Failures: 1 Blocked: 2 Passed: 5"))
check(results[11]:find("BLOCKED: 2 tests of baz"))
check(results[12]:find("FAILED: foo did not accept"))
check(results[13]:find("Tests: 13 Errors: 5 Failures: 1 Blocked: 7 Passed: 5"))
end
----------------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment