Created
July 9, 2015 10:42
-
-
Save lorenzoongithub/d2d19a00747991285307 to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// ========= | |
// yolpo | |
// in action | |
// ========= | |
// | |
// | |
// Load a javascript library to test (e.g. lodash) | |
// | |
load('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.min.js'); | |
a = [1,2,3]; | |
x = _.map(a, function(n) { return n * 3; }); | |
y = _.sum(x); | |
// | |
// By adding some checks we make a regression test for lodash. | |
// | |
if (x.length != 3) throw ''; | |
if (x[0] != 3) throw ''; | |
if (x[1] != 6) throw ''; | |
if (x[2] != 9) throw ''; | |
if (y != 18) throw ''; | |
// | |
// Forcing a failure to see how it works | |
// expecting 2+3 to be 4. :-) | |
// | |
x = 2; | |
y = 3; | |
z = x + y; | |
if (z != 4) throw ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment