Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wru

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wru - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

build/template.html

3

builder/build.js

@@ -154,3 +154,6 @@ var

},
function () {
require('child_process').exec('cp src/program.js node/program.js', JSBuilder.next);
},
"done"
]);

2

node/wru.console.js
/*!
(C) Andrea Giammarchi, @WebReflection - Mit Style License
*/
if(typeof global!="undefined"){var setTimeout=global.setTimeout,setInterval=global.setInterval,clearInterval=global.clearInterval,clearTimeout=global.clearTimeout;setTimeout||(function(h,c,g,a){setInterval=global.setInterval=function b(j,i){return e(j,i,g.call(arguments,2),1)};setTimeout=global.setTimeout=function d(j,i){return e(j,i,g.call(arguments,2))};clearInterval=global.clearInterval=clearTimeout=global.clearTimeout=function f(i){c[i].cancel();h.purge();delete c[i]};function e(l,k,j,i){var m=++a;c[m]=new JavaAdapter(java.util.TimerTask,{run:function(){l.apply(null,j)}});i?h.schedule(c[m],k,k):h.schedule(c[m],k);return m}})(new java.util.Timer(),{},[].slice,0)}else{!function(c,b,a,e){function d(f,g){var h=new Date;while(new Date-h<g){}f.apply(null,e.call(arguments,2))}e=a.slice;c.setTimeout=c.setInterval=d;c.clearInterval=c.clearTimeout=function(){}}(this,0,[])}var wru=function(U){function h(){w=F.call(j);if(w){if(typeof w=="function"){w={name:w[O]||"anonymous",test:w}}l(Z);l((ad(w,O)&&w[O])||(ad(w,e)&&w[e])||L);a=[];q=[];P=[];X={};b("setup");P[ae]||b("test");I||n()}else{p()}}function l(ah,ag){ah=ah+(ag?"":"\n");try{require("util").print(ah)}catch(af){try{require("sys").print(ah)}catch(af){try{java.lang.System.out.print(ah)}catch(af){try{console.log(ah)}catch(af){print(ah)}}}}}function p(){l(g);l(Z);switch(true){case !!aa:l(N+" "+aa+" Errors");case !!z:l(J+g+z+" Failures");default:l(y+" "+o+" Passes")}l(Z);l(g);try{process.exit()}catch(af){quit()}}function c(af){for(var ag=0,ah=af[ae];ag<ah;l(" "+(++ag)+". "+af[ag-1])){}}function n(){f();o+=a[ae];z+=q[ae];aa+=P[ae];if(P[ae]){S=N;c(P)}else{if(q[ae]){S=J;c(q)}else{S=y}}l(S+" passes: "+a[ae]+", fails: "+q[ae]+", errors: "+P[ae]);H=0;S=g;h()}function b(af){if(ad(w,af)){try{w[af](X)}catch(ag){W.call(P,g+ag)}}}function ad(ag,af){return m.call(ag,af)}function s(){return B()<0.5?-1:1}function f(){if(M){C(M);M=0}b("teardown")}var V={assert:function Q(ag,af){if(arguments[ae]==1){af=ag;ag=L}v=D;W.call(af?a:q,S+ag);return af},async:function R(ag,aj,ah,ai){ai=++I;if(typeof ag=="function"){ah=aj;aj=ag;ag="asynchronous test #"+ai}ah=T(function(){ai=0;W.call(q,ag);--I||(M=T(n,0))},G(ah||u)||u);return function af(){if(!ai){return}v=ab;S=ag+": ";try{aj.apply(this,arguments)}catch(ak){v=D;W.call(P,S+ak)}S=g;if(v){C(ah);--I||(M=T(n,0))}}},test:function k(af){j=E.apply(j,[af]);V.random&&ac.call(j,s);I||h()}},D=true,ab=!D,u=100,g=" ",L="unknown",ae="length",O="name",e="description",A="<li>",d="</li>",i="\\|/-",m=V.hasOwnProperty,S=g,Y=S.charAt,t=S.slice,j=[],E=j.concat,r=j.join,W=j.push,F=j.shift,ac=j.sort,I=0,H=0,o=0,z=0,aa=0,M=0,N="\033[1;31mERROR\033[0m",J="\033[0;31mFAILURE\033[0m",y="\033[0;32mOK\033[0m",Z="------------------------------",x,G,B,T,C,w,K,a,q,P,X,v;V.log=function(ah,ag){try{if(ag){throw new Error}console.log(ah)}catch(af){l(ah,0)}};if(typeof __dirname!="undefined"){U.wru=V;U.assert=V.assert;U.async=V.async;U.test=V.test;U.log=V.log;U.random=false;U=global}x=U.Math;G=x.abs;B=x.random;T=U.setTimeout;C=U.clearTimeout;U.setInterval(function(){I&&l(g+Y.call(i,H++%4)+"\b\b",true)},u);undefined;u*=u;V.random=ab;return V}(this);
if(typeof global!="undefined"){var setTimeout=global.setTimeout,setInterval=global.setInterval,clearInterval=global.clearInterval,clearTimeout=global.clearTimeout;setTimeout||(function(h,c,g,a){setInterval=global.setInterval=function b(j,i){return e(j,i,g.call(arguments,2),1)};setTimeout=global.setTimeout=function d(j,i){return e(j,i,g.call(arguments,2))};clearInterval=global.clearInterval=clearTimeout=global.clearTimeout=function f(i){c[i].cancel();h.purge();delete c[i]};function e(l,k,j,i){var m=++a;c[m]=new JavaAdapter(java.util.TimerTask,{run:function(){l.apply(null,j)}});i?h.schedule(c[m],k,k):h.schedule(c[m],k);return m}})(new java.util.Timer(),{},[].slice,0)}else{!function(c,b,a,e){function d(f,g){var h=new Date;while(new Date-h<g){}f.apply(null,e.call(arguments,2))}e=a.slice;c.setTimeout=c.setInterval=d;c.clearInterval=c.clearTimeout=function(){}}(this,0,[])}var wru=function(U){function h(){w=F.call(j);if(w){if(typeof w=="function"){w={name:w[O]||"anonymous",test:w}}l(Z);l((ad(w,O)&&w[O])||(ad(w,e)&&w[e])||L);a=[];q=[];P=[];X={};b("setup");P[ae]||b("test");I||n()}else{p()}}function l(ah,ag){ah=ah+(ag?"":"\n");try{require("util").print(ah)}catch(af){try{require("sys").print(ah)}catch(af){try{java.lang.System.out.print(ah)}catch(af){try{console.log(ah)}catch(af){print(ah)}}}}}function p(){var ag;l(g);l(Z);switch(true){case !!aa:ag="error";l(N+" "+aa+" Errors");case !!z:ag="fail";l(J+g+z+" Failures");default:ag="pass";l(y+" "+o+" Passes")}V.status=ag;l(Z);l(g);V.after();try{process.exit()}catch(af){quit()}}function c(af){for(var ag=0,ah=af[ae];ag<ah;l(" "+(++ag)+". "+af[ag-1])){}}function n(){f();o+=a[ae];z+=q[ae];aa+=P[ae];if(P[ae]){S=N;c(P)}else{if(q[ae]){S=J;c(q)}else{S=y}}l(S+" passes: "+a[ae]+", fails: "+q[ae]+", errors: "+P[ae]);H=0;S=g;h()}function b(af){if(ad(w,af)){try{w[af](X)}catch(ag){W.call(P,g+ag)}}}function ad(ag,af){return m.call(ag,af)}function s(){return B()<0.5?-1:1}function f(){if(M){C(M);M=0}b("teardown")}var V={assert:function Q(ag,af){if(arguments[ae]==1){af=ag;ag=L}v=D;W.call(af?a:q,S+ag);return af},async:function R(ag,aj,ah,ai){ai=++I;if(typeof ag=="function"){ah=aj;aj=ag;ag="asynchronous test #"+ai}ah=T(function(){ai=0;W.call(q,ag);--I||(M=T(n,0))},G(ah||u)||u);return function af(){if(!ai){return}v=ab;S=ag+": ";try{aj.apply(this,arguments)}catch(ak){v=D;W.call(P,S+ak)}S=g;if(v){C(ah);--I||(M=T(n,0))}}},test:function k(af,ag){V.after=ag||function(){};j=E.apply(j,[af]);V.random&&ac.call(j,s);I||h()}},D=true,ab=!D,u=100,g=" ",L="unknown",ae="length",O="name",e="description",A="<li>",d="</li>",i="\\|/-",m=V.hasOwnProperty,S=g,Y=S.charAt,t=S.slice,j=[],E=j.concat,r=j.join,W=j.push,F=j.shift,ac=j.sort,I=0,H=0,o=0,z=0,aa=0,M=0,N="\x1B[1;31mERROR\x1B[0m",J="\x1B[0;31mFAILURE\x1B[0m",y="\x1B[0;32mOK\x1B[0m",Z="------------------------------",x,G,B,T,C,w,K,a,q,P,X,v;V.log=function(ah,ag){try{if(ag){throw new Error}console.log(ah)}catch(af){l(ah,0)}};if(typeof __dirname!="undefined"){U.wru=V;U.assert=V.assert;U.async=V.async;U.test=V.test;U.log=V.log;U.random=false;Object.defineProperty(U,"status",{get:function(){return V.status}});U=global}x=U.Math;G=x.abs;B=x.random;T=U.setTimeout;C=U.clearTimeout;U.setInterval(function(){I&&l(g+Y.call(i,H++%4)+"\b\b",true)},u);undefined;u*=u;V.random=ab;return V}(this);
{
"name": "wru"
, "version": "0.1.8"
, "version": "0.1.9"
, "description": "sync and async JavaScript tests have never been that easy"
, "homepage": "https://github.com/WebReflection/wru"
, "keywords": ["test", "general", "purpose", "async", "sync", "asynchronous", "phantom", "rhino", "browser"]
, "author": "Andrea Giammarchi"
, "author": {
"name": "Andrea Giammarchi",
"web": "http://webreflection.blogspot.com/"
}
, "repository":{

@@ -14,2 +17,5 @@ "type": "git"

, "engines": { "node": ">= 0.4.0" }
, "bin": {
"wru": "./node/program.js"
}
}

@@ -27,3 +27,3 @@ // console specific version

}
function log(info, avoidNewLine) {

@@ -55,4 +55,5 @@ info = info + (avoidNewLine ? "" : "\n");

}
function showSummary() {
var status;
log(EMPTY);

@@ -62,10 +63,15 @@ log(OUTPUT_SEPARATOR);

case !!overallFatal:
status = "error";
log(ERROR + " " + overallFatal + " Errors");
case !!overallFail:
status = "fail";
log(FAILURE + EMPTY + overallFail + " Failures");
default:
status = "pass";
log(OK + " " + overallPass + " Passes");
}
wru.status = status;
log(OUTPUT_SEPARATOR);
log(EMPTY);
wru.after();
try {

@@ -79,3 +85,3 @@ // node.js

}
function writeItOrdered(fail) {

@@ -88,3 +94,3 @@ for (var

}
function Dary() {

@@ -109,2 +115,1 @@ clearDaryTimeou();

}

@@ -1,6 +0,6 @@

// these variables are used on console version only
ERROR = "\033[1;31mERROR\033[0m",
FAILURE = "\033[0;31mFAILURE\033[0m",
OK = "\033[0;32mOK\033[0m",
ERROR = "\x1B[1;31mERROR\x1B[0m",
FAILURE = "\x1B[0;31mFAILURE\x1B[0m",
OK = "\x1B[0;32mOK\x1B[0m",
OUTPUT_SEPARATOR = "------------------------------",

@@ -29,3 +29,3 @@ // DOM specific version

}
function create(nodeName) {

@@ -39,11 +39,11 @@ try {

}
function putItThereAndGimmeBack(node, nodeName) {
return node.appendChild(create(nodeName));
}
function passTheInfo(info) {
node[INNERHTML] = slice.call(node[INNERHTML], 0, -2) + EMPTY + info;
}
function showSummary() {

@@ -56,18 +56,20 @@ var

innerHTML,
className
className,
status
;
if (overallFatal) {
className = "error";
status = className = "error";
innerHTML = "There Are Errors: " + overallFatal;
} else if(overallFail) {
className = "fail";
status = className = "fail";
innerHTML = overallFail + " Tests Failed";
} else {
className = "pass";
status = className = "pass";
innerHTML = "Passed " + overallPass + " Tests";
}
wru.status = status;
node[INNERHTML] = "<strong>" + innerHTML + "</strong>";
node.className = className;
}
function showTheProblem() {

@@ -77,3 +79,3 @@ var style = this.lastChild.style;

}
function writeItOrdered(fail) {

@@ -83,3 +85,3 @@ node[INNERHTML] += "<ul>" + LISTART + join.call(fail, LIEND + LISTART) + LIEND + "</ul>";

}
function Dary() {

@@ -110,2 +112,1 @@ clearDaryTimeou();

}

@@ -10,2 +10,5 @@ // node.js exports

window.random = false;
Object.defineProperty(window, "status", {get: function () {
return wru.status;
}});

@@ -15,2 +18,1 @@ // re-assign window to make it global

}

@@ -1,6 +0,6 @@

var // wru library core
wru = {
assert: function assert(description, result) {
// if no description provided, variables are shifted

@@ -14,10 +14,10 @@ // these are both valid wru.assert calls indeed

}
// flag used in wru.async to verify at least
// one assertion was performed
called = TRUE;
// store the result in the right collection
push.call(result ? pass : fail, prefix + description);
// just to add a bit of sugar

@@ -27,3 +27,3 @@ return result;

async: function async(description, callback, timeout, p) {
// p is used as sentinel

@@ -33,3 +33,3 @@ // it defines the anonymous name

p = ++waitForIt;
// if no description provided, variables are shifted

@@ -46,12 +46,12 @@ // these are all valid wru.async calls indeed, timeout is optional

}
// if in *TIMEOUT* time nothing happens ...
timeout = setTimeout(function () {
// p is flagged as 0
p = 0;
// timeout is handled as failure, not error (could be the server)
push.call(fail, description);
// if there is no reason to waitForIt then is time to call Dary()

@@ -65,10 +65,10 @@ --waitForIt || (daryTimeout = setTimeout(Dary, 0));

);
// the async function is a wrap of the passed callback
return function async() {
// if it's executed after the timeout nothing happens
// since the failure has been already notified
if (!p) return;
// called is always set as *TRUE* during any assertion

@@ -79,3 +79,3 @@ // this indicates if the callback made at least one assertion

// there is the assertion we are interested about, e.g.
//
//
// xhr.onreadystatechange = wru.async(function (){

@@ -86,11 +86,11 @@ // if (this.readyState == 4)

// });
//
//
// in above example called will be flagged as true
// only during last readyState call
called = FALSE;
// simply recycled "string" variable
// prefix will be internally used by assert during function execution
prefix = description + ": ";
// the original callback is called with proper *this* if specified

@@ -108,12 +108,12 @@ try {

}
// prefix can be *EMPTY* string again now
prefix = EMPTY;
// a failure or at least an assertion
if (called) {
// timeout not necessary anymore
clearTimeout(timeout);
// if there is no reason to waitForIt then is time to call Dary()

@@ -124,3 +124,3 @@ --waitForIt || (daryTimeout = setTimeout(Dary, 0));

},
// wru.test({...test...})

@@ -130,12 +130,15 @@ // wru.test([{...test...}, {...test...}, ...])

// optionally a function setup and a function teardown too
test: function test(list) {
test: function test(list, after) {
// in case you need to do something after
wru.after = after || function () {};
// test may be called multiple times
// queue should simply concatenate other calls
queue = concat.apply(queue, [list]);
// if wru.random is true, the queue is ranodomized
// this is to make tests indipendent from each others
wru.random && sort.call(queue, messItUp);
// if there is no test to waitForIt

@@ -148,2 +151,1 @@ // Dary() has been called already

},

@@ -9,3 +9,6 @@

// node and phantom js
var wru = this.wru || require("./../build/wru.console");
var wru = this.wru.assert ?
this.wru :
require("./../build/wru.console")
;
} catch(wru) {

@@ -15,3 +18,3 @@ // rhino

load(
new java.io.File(".").getCanonicalPath() +
new java.io.File(".").getCanonicalPath() +
"/build/wru.console.js"

@@ -83,2 +86,1 @@ );

}]);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc