Created
August 22, 2017 00:09
-
-
Save psrok1/77cf2aad0920ad4235cfb77d4e8aaf36 to your computer and use it in GitHub Desktop.
box-js test case for member function declaration rewriting
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
"This one is global".global_func(); | |
(function(){ | |
"This one is scoped".scoped_func(); | |
function String.prototype.scoped_func(arg_a, arg_b) { | |
String.nested_func2("This one", " is nested"); | |
function String.prototype.nested_func(arg_a, arg_b) { | |
WScript.echo(this); | |
} | |
this.nested_func(); | |
while(0) | |
{ | |
String.nested_func2("Seems like dead code", "... but is still important"); | |
function String.nested_func2(arg_a, arg_b) { | |
WScript.echo(arg_a + arg_b); | |
} | |
} | |
} | |
})(); | |
function last_func() { | |
WScript.echo("And the last.. here it comes!"); | |
} | |
function String.prototype.global_func(arg_a, arg_b) { | |
WScript.echo(this); | |
} | |
last_func(); | |
String.nested_func2("It works", "?"); | |
/******** | |
Rewritten by box-js to: | |
(function () { | |
String.prototype.scoped_func = function (arg_a, arg_b) { | |
String.nested_func2 = function (arg_a, arg_b) { | |
WScript.echo(arg_a + arg_b); | |
}; | |
String.prototype.nested_func = function (arg_a, arg_b) { | |
WScript.echo(this); | |
}; | |
String.nested_func2('This one', ' is nested'); | |
this.nested_func(); | |
while (0) { | |
String.nested_func2('Seems like dead code', '... but is still important'); | |
} | |
}; | |
'This one is scoped'.scoped_func(); | |
}()); | |
function last_func() { | |
WScript.echo('And the last.. here it comes!'); | |
} | |
last_func(); | |
String.nested_func2('It works', '?'); | |
******/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment