Skip to content

Instantly share code, notes, and snippets.

@donli1210
Last active December 2, 2017 12:39
Show Gist options
  • Save donli1210/881a2ecebe55b677f10cc37eeffd948d to your computer and use it in GitHub Desktop.
Save donli1210/881a2ecebe55b677f10cc37eeffd948d to your computer and use it in GitHub Desktop.
Improving runWithDebugger
function runWithDebugger(callback, argsArray) {
debugger;
return callback.apply(null, argsArray);
}
<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