Last active
December 2, 2017 12:39
-
-
Save donli1210/881a2ecebe55b677f10cc37eeffd948d to your computer and use it in GitHub Desktop.
Improving runWithDebugger
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
function runWithDebugger(callback, argsArray) { | |
debugger; | |
return callback.apply(null, argsArray); | |
} |
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
<script src="tinytest.js"></script> | |
<script src="script.js"></script> | |
<script> | |
tests({ | |
'no argument': function() { | |
function sayHi() { | |
return ('hi!'); | |
} | |
eq("hi!", runWithDebugger(sayHi)); | |
eq("hi!", runWithDebugger(sayHi, [])); | |
}, | |
'one argument': function() { | |
function sayHiTo(name) { | |
return ('hi ' + name); | |
} | |
eq("hi Don", runWithDebugger(sayHiTo, ["Don"])); | |
}, | |
'multiple arguments': function() { | |
function sayFullName(first, last) { | |
return (first + ' ' + last); | |
} | |
eq("Don Li", runWithDebugger(sayFullName, ["Don", "Li"])); | |
}, | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment