Created
January 30, 2013 03:57
-
-
Save nornagon/4670491 to your computer and use it in GitHub Desktop.
disintegrate
This file contains hidden or 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
disintegrate = (fn) -> | |
tests = [] | |
ret_fn = (args...) -> | |
args_saved = JSON.stringify(args) | |
res = fn.apply(this, args) | |
res_saved = JSON.stringify(res) | |
tests.push {args:args_saved,res:res_saved} | |
return res | |
ret_fn.tests = tests | |
ret_fn | |
b = disintegrate (x) -> | |
x*x | |
a = (x) -> | |
b(x + 3) | |
a() | |
a(4) | |
console.log b.tests | |
# [ { args: '[null]', res: 'null' }, { args: '[7]', res: '49' } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment