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

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Saxton <saxton@google.com>2016-02-24 20:54:10 +0300
committerDavid Saxton <saxton@google.com>2016-02-25 19:01:54 +0300
commitd8ff64c5707f716199e7782d630e44e2cf402a54 (patch)
treee3e2bcc1d0872cf7c363b7de12cd91818e3038e3 /TestSuite.lua
parent3bbb49f62f2716c952f43115ea8caa450c8785d4 (diff)
Replace torch.Tester with totem.Tester + extra stuff.
This should bring a lot of benefit to code that uses torch.Tester (totem will eventually become deprecated). Note that torch.Tester and totem.Tester once shared the same code - this change brings it full circle. At a glance, extra functionality includes: - A general equality checker that accepts many different objects. - Deep table comparison with precision checking. - Stricter argument checking in using the test functions. - Better output. - torch.Storage comparison. - Extra features for fine-grained control of testing.
Diffstat (limited to 'TestSuite.lua')
-rw-r--r--TestSuite.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/TestSuite.lua b/TestSuite.lua
new file mode 100644
index 0000000..630c2c9
--- /dev/null
+++ b/TestSuite.lua
@@ -0,0 +1,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