Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rebuild @ 1.6.0

  • Loading branch information...
commit 3de6c2659cbede3c9d636bf67e6e77ab7dd50434 1 parent c5070ed
@ryanve authored
Showing with 35 additions and 43 deletions.
  1. +1 −1  README.md
  2. +31 −39 aok.js
  3. +2 −2 aok.min.js
  4. +1 −1  package.json
View
2  README.md
@@ -2,7 +2,7 @@
#### Extensible JavaScript test suite [module](https://npmjs.org/package/aok)
-## API ([1.5](../../releases))
+## API ([1.6](../../releases))
### `aok(testObject)`
View
70 aok.js
@@ -1,5 +1,5 @@
/*!
- * aok 1.5.3+201311020500
+ * aok 1.6.0+201311030705
* https://github.com/ryanve/aok
* MIT License 2013 Ryan Van Etten
*/
@@ -23,6 +23,12 @@
}
, assign = function(to, from) {
for (var k in from) has(from, k) && (to[k] = from[k]);
+ return to;
+ }
+ , clone = function(fn) {
+ return assign(function() {
+ fn.apply(this, arguments);
+ }, fn);
};
/**
@@ -50,38 +56,35 @@
implement = aok.prototype = Aok.prototype;
// Console abstractions
- (function(target, console, hasAlert, win) {
- /**
- * @param {string} name
- * @param {(boolean|number)=} force
- * @param {string=} key
- */
- function assign(name, force, key) {
+ assign(aok, aok['console'] = (function(abstracted, console, hasAlert, win) {
+ function abstracts(name, force, fallback) {
var method = console && typeof console[name] == 'function' ? function() {
console[name].apply(console, arguments);
- } : hasAlert ? function() {
+ } : fallback ? fallback : hasAlert ? function() {
method['force'] && win.alert(name + ': ' + [].join.call(arguments, ' '));
} : function() {};
method['force'] = !!force;
- target[key || name] = method;
+ abstracted[name] = method;
}
-
- assign('info', 1);
- assign('warn', 1);
- assign('error', 1);
- assign('trace');
- assign('log');
- assign('log', 0, 'express');
- }(aok, nativeConsole, hasAlert, win));
+
+ abstracts('log');
+ abstracts('trace');
+ abstracts('info', 1);
+ abstracts('warn', 1);
+ abstracts('error', 1);
+ abstracts('assert', 1, function(exp, msg) {
+ exp || abstracted['warn'](msg);
+ });
+ return abstracted;
+ }({}, nativeConsole, hasAlert, win)));
+
+ // Alias the "express" method to the prototype for usage with tests.
+ implement['express'] = aok['express'] = clone(aok['log']);
// Default messages
implement['pass'] = 'Pass';
implement['fail'] = 'Fail';
- // Alias the "express" method to the prototype for usage from
- // the default handler. Override as needed for customization.
- implement['express'] = aok['express'];
-
/**
* @param {*=} item
* @return {string}
@@ -94,18 +97,14 @@
/**
* @param {*} o
* @param {(string|number|Function)=} k
- * @example result(0) // 0
+ * @param {Object=} guard array methods
* @example result([1], 0) // 1
*/
- function result(o, k) {
- if (2 != arguments.length) k = o, o = this;
- else typeof k == 'function' ? k : k = o[k];
+ function result(o, k, guard) {
+ guard || k === guard ? (k = o, o = this) : (typeof k == 'function' ? k : k = o[k]);
return typeof k == 'function' ? k.call(o) : k;
}
aok['result'] = result;
- implement['result'] = function(k) {
- return result.apply(aok, 2 == arguments.length ? arguments : [this, k]);
- };
/**
* Get a new function that uses try/catch to test if `fn` can run.
@@ -139,9 +138,7 @@
*/
implement['run'] = function() {
if (this === globe) throw new Error('@this');
- var use = this['result'], at = 'test';
- use = typeof use == 'function' ? use.call(this, at) : result(this, at);
- this[at] = !!use;
+ this['test'] = !!result(this, 'test');
return this['handler']();
};
@@ -159,13 +156,8 @@
*/
implement['handler'] = function() {
var msg = this['cull']();
- if (typeof msg == 'function') {
- msg.call(this);
- } else {
- msg = this['explain'](msg);
- has(this, 'remark') && (msg += ' (' + this['explain'](this['remark']) + ')');
- this['express']('#' + this['id'] + ': ' + msg);
- }
+ if (typeof msg == 'function') msg.call(this);
+ else this['express']('#' + this['id'] + ': ' + this['explain'](msg));
return this;
};
View
4 aok.min.js
@@ -1,6 +1,6 @@
/*!
- * aok 1.5.3+201311020500
+ * aok 1.6.0+201311030705
* 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){"object"==typeof a&&a?o(this,a):arguments.length&&(this.test=a),this.init()}function b(b){return arguments.length?new a(b):new a}function c(a,b){return 2!=arguments.length?(b=a,a=this):"function"==typeof b?b:b=a[b],"function"==typeof b?b.call(a):b}var d,e=this,f={},g=f.hasOwnProperty,h=f.toString,i="undefined"!=typeof window&&window,j="undefined"!=typeof document&&document,k="undefined"!=typeof console&&console,l=i&&"alert"in i,m=0,n=function(a,b){return g.call(a,b)},o=function(a,b){for(var c in b)n(b,c)&&(a[c]=b[c])};return d=b.prototype=a.prototype,function(a,b,c,d){function e(e,f,g){var h=b&&"function"==typeof b[e]?function(){b[e].apply(b,arguments)}:c?function(){h.force&&d.alert(e+": "+[].join.call(arguments," "))}:function(){};h.force=!!f,a[g||e]=h}e("info",1),e("warn",1),e("error",1),e("trace"),e("log"),e("log",0,"express")}(b,k,l,i),d.pass="Pass",d.fail="Fail",d.express=b.express,d.explain=b.explain=function(a){return a=arguments.length?a:this,a===Object(a)?h.call(a):""+a},b.result=c,d.result=function(a){return c.apply(b,2==arguments.length?arguments:[this,a])},b.can=function(a){return function(){try{("string"==typeof a?this[a]:a).apply(this,arguments)}catch(b){return!1}return!0}},d.init=function(){if(this===e)throw new Error("@this");return n(this,"id")||(this.id=++m),n(this,"test")&&this.run(),this},d.run=function(){if(this===e)throw new Error("@this");var a=this.result,b="test";return a="function"==typeof a?a.call(this,b):c(this,b),this[b]=!!a,this.handler()},d.cull=function(a){return this[this[null==a?"test":a]?"pass":"fail"]},d.handler=function(){var a=this.cull();return"function"==typeof a?a.call(this):(a=this.explain(a),n(this,"remark")&&(a+=" ("+this.explain(this.remark)+")"),this.express("#"+this.id+": "+a)),this},b.id=function(a){return j.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){"object"==typeof a&&a?o(this,a):arguments.length&&(this.test=a),this.init()}function b(b){return arguments.length?new a(b):new a}function c(a,b,c){return c||b===c?(b=a,a=this):"function"==typeof b?b:b=a[b],"function"==typeof b?b.call(a):b}var d,e=this,f={},g=f.hasOwnProperty,h=f.toString,i="undefined"!=typeof window&&window,j="undefined"!=typeof document&&document,k="undefined"!=typeof console&&console,l=i&&"alert"in i,m=0,n=function(a,b){return g.call(a,b)},o=function(a,b){for(var c in b)n(b,c)&&(a[c]=b[c]);return a},p=function(a){return o(function(){a.apply(this,arguments)},a)};return d=b.prototype=a.prototype,o(b,b.console=function(a,b,c,d){function e(e,f,g){var h=b&&"function"==typeof b[e]?function(){b[e].apply(b,arguments)}:g?g:c?function(){h.force&&d.alert(e+": "+[].join.call(arguments," "))}:function(){};h.force=!!f,a[e]=h}return e("log"),e("trace"),e("info",1),e("warn",1),e("error",1),e("assert",1,function(b,c){b||a.warn(c)}),a}({},k,l,i)),d.express=b.express=p(b.log),d.pass="Pass",d.fail="Fail",d.explain=b.explain=function(a){return a=arguments.length?a:this,a===Object(a)?h.call(a):""+a},b.result=c,b.can=function(a){return function(){try{("string"==typeof a?this[a]:a).apply(this,arguments)}catch(b){return!1}return!0}},d.init=function(){if(this===e)throw new Error("@this");return n(this,"id")||(this.id=++m),n(this,"test")&&this.run(),this},d.run=function(){if(this===e)throw new Error("@this");return this.test=!!c(this,"test"),this.handler()},d.cull=function(a){return this[this[null==a?"test":a]?"pass":"fail"]},d.handler=function(){var a=this.cull();return"function"==typeof a?a.call(this):this.express("#"+this.id+": "+this.explain(a)),this},b.id=function(a){return j.getElementById(a)||!1},b});
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "aok",
"description": "Extensible test suite API.",
- "version": "1.5.3",
+ "version": "1.6.0",
"homepage": "https://github.com/ryanve/aok",
"author": "Ryan Van Etten",
"keywords": ["testing", "test suite", "javascript", "ender", "browser", "server"],
Please sign in to comment.
Something went wrong with that request. Please try again.