Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TestSuite.lua - github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 630c2c9480e2af2e0abb94c5ce559c10227201e9 (plain)
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
function torch.TestSuite()
   local obj = {
      __tests = {},
      __isTestSuite = true
   }

   local metatable = {}

   function metatable:__index(key)
      return self.__tests[key]
   end

   function metatable:__newindex(key, value)
      if self.__tests[key] ~= nil then
         error("Test " .. tostring(key) .. " is already defined.")
      end
      if type(value) ~= "function" then
         if type(value) == "table" then
            error("Nested tables of tests are not supported")
         else
            error("Only functions are supported as members of a TestSuite")
         end
      end
      self.__tests[key] = value
   end

   setmetatable(obj, metatable)

   return obj
end