forked from torch/torch7
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
3bbb49f
commit d8ff64c
Showing
12 changed files
with
1,775 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.