Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

1.2.1: Prevent node.js undefined reference errors.

  • Loading branch information...
commit 7113f69b463adc9dc20418371fad34b7f9bf8627 1 parent e181538
@ryanve authored
Showing with 41 additions and 45 deletions.
  1. +19 −21 aok.js
  2. +2 −2 aok.min.js
  3. +2 −2 package.json
  4. +18 −20 src/aok.js
View
40 aok.js
@@ -1,5 +1,5 @@
/*!
- * aok 1.2.0+201309031941
+ * aok 1.2.1+201309051739
* https://github.com/ryanve/aok
* MIT License 2013 Ryan Van Etten
*/
@@ -8,11 +8,13 @@
typeof module != 'undefined' && module['exports'] ? module['exports'] = make() : root[name] = make();
}(this, 'aok', function() {
- var win = window
- , doc = document
+ var globe = (function() { return this; }())
, plain = {}
, owns = plain.hasOwnProperty
, toString = plain.toString
+ , nativeConsole = typeof console != 'undefined' && console
+ , nativeAlert = typeof alert == 'function' && alert
+ , doc = typeof document != 'undefined' && document
, uid = 0;
/**
@@ -23,13 +25,9 @@
// Own 'test' unless instantiated w/o args,
// or unless `data` is 'object' w/o 'test'.
// Running proceeds only if 'test' is owned.
- if (data && typeof data == 'object') {
- for (var k in data) {
- owns.call(data, k) && (this[k] = data[k]);
- }
- } else if (arguments.length) {
- this['test'] = data;
- }
+ if (data && typeof data == 'object')
+ for (var k in data) owns.call(data, k) && (this[k] = data[k]);
+ else arguments.length && (this['test'] = data);
this['init']();
}
@@ -49,29 +47,29 @@
aok.prototype['fail'] = 'Fail';
// Console abstractions
- (function(target, console, win) {
+ (function(target, console, alert) {
/**
* @param {string} name
* @param {(boolean|number)=} force
* @param {string=} key
*/
function assign(name, force, key) {
- var method = console && typeof console[name] == 'function' ? function() {
+ var method = console ? function() {
console[name].apply(console, arguments);
} : function() {
- method['force'] && win['alert'](name + ': ' + [].join.call(arguments, ' '));
+ method['force'] && alert(name + ': ' + [].join.call(arguments, ' '));
};
method['force'] = !!force;
target[key || name] = method;
}
- assign('info', 1);
- assign('warn', 1);
+ assign('info', 1);
+ assign('warn', 1);
assign('error', 1);
assign('trace');
assign('log');
assign('log', 0, 'express');
- }(aok, win.console, win));
+ }(aok, nativeConsole, nativeAlert));
// Alias the "express" method. `aok.prototype.express` is used in the
// default handler. Override it as needed for customization.
@@ -101,7 +99,7 @@
* @return {Aok}
*/
aok.prototype['init'] = function() {
- if (this === win) { throw new Error('@this'); }
+ if (this === globe) throw new Error('@this');
owns.call(this, 'id') || (this['id'] = ++uid);
owns.call(this, 'test') && this['run']();
return this;
@@ -111,9 +109,9 @@
* @return {Aok}
*/
aok.prototype['run'] = function() {
- if (this === win) { throw new Error('@this'); }
- this['test'] = !!result(this, 'test'); // run the test
- return this['handler'](); // trigger the handler
+ if (this === globe) throw new Error('@this');
+ this['test'] = !!result(this, 'test'); // Run the test.
+ return this['handler'](); // Trigger the handler.
};
/**
@@ -146,6 +144,6 @@
aok['id'] = function(n) {
return doc.getElementById(n) || false;
};
-
+
return aok;
}));
View
4 aok.min.js
@@ -1,6 +1,6 @@
/*!
- * aok 1.2.0+201309031941
+ * aok 1.2.1+201309051739
* https://github.com/ryanve/aok
* MIT License 2013 Ryan Van Etten
*/
-!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c():a[b]=c()}(this,"aok",function(){function a(a){if(a&&"object"==typeof a)for(var b in a)h.call(a,b)&&(this[b]=a[b]);else arguments.length&&(this.test=a);this.init()}function b(b){return arguments.length?new a(b):new a}function c(a){return""+(a===Object(a)?i.call(a):a)}function d(a,b){return 2==arguments.length?d.call(a,a[b]):"function"==typeof a?a.call(this):a}var e=window,f=document,g={},h=g.hasOwnProperty,i=g.toString,j=0;return b.prototype=a.prototype,b.prototype.pass="Pass",b.prototype.fail="Fail",function(a,b,c){function d(d,e,f){var g=b&&"function"==typeof b[d]?function(){b[d].apply(b,arguments)}:function(){g.force&&c.alert(d+": "+[].join.call(arguments," "))};g.force=!!e,a[f||d]=g}d("info",1),d("warn",1),d("error",1),d("trace"),d("log"),d("log",0,"express")}(b,e.console,e),b.prototype.express=b.express,b.explain=c,b.result=d,b.prototype.init=function(){if(this===e)throw new Error("@this");return h.call(this,"id")||(this.id=++j),h.call(this,"test")&&this.run(),this},b.prototype.run=function(){if(this===e)throw new Error("@this");return this.test=!!d(this,"test"),this.handler()},b.prototype.cull=function(a){return this[this[null==a?"test":a]?"pass":"fail"]},b.prototype.handler=function(){var a=this.cull();return"function"==typeof a?a.call(this):(a=c(a),h.call(this,"remark")&&(a+=" ("+c(this.remark)+")"),this.express("#"+this.id+": "+a)),this},b.id=function(a){return f.getElementById(a)||!1},b});
+!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c():a[b]=c()}(this,"aok",function(){function a(a){if(a&&"object"==typeof a)for(var b in a)g.call(a,b)&&(this[b]=a[b]);else arguments.length&&(this.test=a);this.init()}function b(b){return arguments.length?new a(b):new a}function c(a){return""+(a===Object(a)?h.call(a):a)}function d(a,b){return 2==arguments.length?d.call(a,a[b]):"function"==typeof a?a.call(this):a}var e=function(){return this}(),f={},g=f.hasOwnProperty,h=f.toString,i="undefined"!=typeof console&&console,j="function"==typeof alert&&alert,k="undefined"!=typeof document&&document,l=0;return b.prototype=a.prototype,b.prototype.pass="Pass",b.prototype.fail="Fail",function(a,b,c){function d(d,e,f){var g=b?function(){b[d].apply(b,arguments)}:function(){g.force&&c(d+": "+[].join.call(arguments," "))};g.force=!!e,a[f||d]=g}d("info",1),d("warn",1),d("error",1),d("trace"),d("log"),d("log",0,"express")}(b,i,j),b.prototype.express=b.express,b.explain=c,b.result=d,b.prototype.init=function(){if(this===e)throw new Error("@this");return g.call(this,"id")||(this.id=++l),g.call(this,"test")&&this.run(),this},b.prototype.run=function(){if(this===e)throw new Error("@this");return this.test=!!d(this,"test"),this.handler()},b.prototype.cull=function(a){return this[this[null==a?"test":a]?"pass":"fail"]},b.prototype.handler=function(){var a=this.cull();return"function"==typeof a?a.call(this):(a=c(a),g.call(this,"remark")&&(a+=" ("+c(this.remark)+")"),this.express("#"+this.id+": "+a)),this},b.id=function(a){return k.getElementById(a)||!1},b});
View
4 package.json
@@ -1,10 +1,10 @@
{
"name": "aok",
"description": "Extensible test suite API.",
- "version": "1.2.0",
+ "version": "1.2.1",
"homepage": "https://github.com/ryanve/aok",
"author": "Ryan Van Etten",
- "keywords": ["testing", "test suite", "javascript", "ender"],
+ "keywords": ["testing", "test suite", "javascript", "ender", "browser", "server"],
"main": "./aok.js",
"ender": "noop",
"repository": {
View
38 src/aok.js
@@ -2,11 +2,13 @@
typeof module != 'undefined' && module['exports'] ? module['exports'] = make() : root[name] = make();
}(this, 'aok', function() {
- var win = window
- , doc = document
+ var globe = (function() { return this; }())
, plain = {}
, owns = plain.hasOwnProperty
, toString = plain.toString
+ , nativeConsole = typeof console != 'undefined' && console
+ , nativeAlert = typeof alert == 'function' && alert
+ , doc = typeof document != 'undefined' && document
, uid = 0;
/**
@@ -17,13 +19,9 @@
// Own 'test' unless instantiated w/o args,
// or unless `data` is 'object' w/o 'test'.
// Running proceeds only if 'test' is owned.
- if (data && typeof data == 'object') {
- for (var k in data) {
- owns.call(data, k) && (this[k] = data[k]);
- }
- } else if (arguments.length) {
- this['test'] = data;
- }
+ if (data && typeof data == 'object')
+ for (var k in data) owns.call(data, k) && (this[k] = data[k]);
+ else arguments.length && (this['test'] = data);
this['init']();
}
@@ -43,29 +41,29 @@
aok.prototype['fail'] = 'Fail';
// Console abstractions
- (function(target, console, win) {
+ (function(target, console, alert) {
/**
* @param {string} name
* @param {(boolean|number)=} force
* @param {string=} key
*/
function assign(name, force, key) {
- var method = console && typeof console[name] == 'function' ? function() {
+ var method = console ? function() {
console[name].apply(console, arguments);
} : function() {
- method['force'] && win['alert'](name + ': ' + [].join.call(arguments, ' '));
+ method['force'] && alert(name + ': ' + [].join.call(arguments, ' '));
};
method['force'] = !!force;
target[key || name] = method;
}
- assign('info', 1);
- assign('warn', 1);
+ assign('info', 1);
+ assign('warn', 1);
assign('error', 1);
assign('trace');
assign('log');
assign('log', 0, 'express');
- }(aok, win.console, win));
+ }(aok, nativeConsole, nativeAlert));
// Alias the "express" method. `aok.prototype.express` is used in the
// default handler. Override it as needed for customization.
@@ -95,7 +93,7 @@
* @return {Aok}
*/
aok.prototype['init'] = function() {
- if (this === win) { throw new Error('@this'); }
+ if (this === globe) throw new Error('@this');
owns.call(this, 'id') || (this['id'] = ++uid);
owns.call(this, 'test') && this['run']();
return this;
@@ -105,9 +103,9 @@
* @return {Aok}
*/
aok.prototype['run'] = function() {
- if (this === win) { throw new Error('@this'); }
- this['test'] = !!result(this, 'test'); // run the test
- return this['handler'](); // trigger the handler
+ if (this === globe) throw new Error('@this');
+ this['test'] = !!result(this, 'test'); // Run the test.
+ return this['handler'](); // Trigger the handler.
};
/**
@@ -140,6 +138,6 @@
aok['id'] = function(n) {
return doc.getElementById(n) || false;
};
-
+
return aok;
}));

0 comments on commit 7113f69

Please sign in to comment.
Something went wrong with that request. Please try again.