Skip to content

Instantly share code, notes, and snippets.

@lorenzoongithub
Created July 9, 2015 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzoongithub/d2d19a00747991285307 to your computer and use it in GitHub Desktop.
Save lorenzoongithub/d2d19a00747991285307 to your computer and use it in GitHub Desktop.
//
// =========
// 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