This file is indexed.

/usr/share/lua/5.1/luassert/match.lua is in lua-luassert 1.7.9-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
local namespace = require 'luassert.namespaces'
local util = require 'luassert.util'

local matcher_mt = {
  __call = function(self, value)
    return self.callback(value) == self.mod
  end,
}

local state_mt = {
  __call = function(self, ...)
    local keys = util.extract_keys("matcher", self.tokens)
    self.tokens = {}

    local matcher

    for _, key in ipairs(keys) do
      matcher = namespace.matcher[key] or matcher
    end

    if matcher then
      for _, key in ipairs(keys) do
        if namespace.modifier[key] then
          namespace.modifier[key].callback(self)
        end
      end

      local arguments = {...}
      arguments.n = select('#', ...) -- add argument count for trailing nils
      local matches = matcher.callback(self, arguments, util.errorlevel())
      return setmetatable({
        name = matcher.name,
        mod = self.mod,
        callback = matches,
      }, matcher_mt)
    else
      local arguments = {...}
      arguments.n = select('#', ...) -- add argument count for trailing nils

      for _, key in ipairs(keys) do
        if namespace.modifier[key] then
          namespace.modifier[key].callback(self, arguments, util.errorlevel())
        end
      end
    end

    return self
  end,

  __index = function(self, key)
    for token in key:lower():gmatch('[^_]+') do
      table.insert(self.tokens, token)
    end

    return self
  end
}

local match = {
  _ = setmetatable({mod=true, callback=function() return true end}, matcher_mt),

  state = function() return setmetatable({mod=true, tokens={}}, state_mt) end,

  is_matcher = function(object)
    return type(object) == "table" and getmetatable(object) == matcher_mt
  end,

  is_ref_matcher = function(object)
    local ismatcher = (type(object) == "table" and getmetatable(object) == matcher_mt)
    return ismatcher and object.name == "ref"
  end,
}

local mt = {
  __index = function(self, key)
    return rawget(self, key) or self.state()[key]
  end,
}

return setmetatable(match, mt)