diff options
author | jbarbero <jbarbero@gmail.com> | 2016-05-11 01:28:19 +0300 |
---|---|---|
committer | jbarbero <jbarbero@gmail.com> | 2016-05-11 01:28:19 +0300 |
commit | 4ef9eab2f4b8cf0881ee654d1864adbd0febb64d (patch) | |
tree | 85cec92da254fa8d775a029d684b06b2e88bdb44 | |
parent | 9e879ae03fe8f593ef3d73bd73375f72c17c17e7 (diff) |
fix argcheck function to encapsulate its local variables
-rw-r--r-- | graph.lua | 2 | ||||
-rw-r--r-- | test/test.lua | 10 |
2 files changed, 11 insertions, 1 deletions
@@ -365,8 +365,8 @@ end function ACN:generate(upvalues) assert(upvalues, 'upvalues table missing') local code = {} - table.insert(code, 'local usage = require "argcheck.usage"') table.insert(code, 'return function(...)') + table.insert(code, ' local usage = require "argcheck.usage"') table.insert(code, ' local narg = select("#", ...)') self:generate_ordered_or_named(code, upvalues, 'O') diff --git a/test/test.lua b/test/test.lua index b3778bc..1a5e9e2 100644 --- a/test/test.lua +++ b/test/test.lua @@ -333,6 +333,16 @@ if pcall(require, 'torch') then assert(env.istype(t, '.*Long') == true) assert(env.istype(t, 'torch.IntTensor') == false) assert(env.istype(t, 'torch.Long') == false) + + -- test argcheck function serialization + local f = argcheck{ + {name='arg', type='string'}, + call = function(arg) + print(arg) + end + } + local m = torch.MemoryFile() + m:writeObject(f) end print('PASSED') |