Testing addArrayComprehension() - Stable Test Suite for zjrJS

This information lives on a webpage hosted at the following web address: 'https://www.omegajunior.net/code/zjrjs/stable.php'.

Showing whether zjrJS.Doc. addArrayComprehension() actually works.

Used zjrJS Version:

Stable Minified version 20141202t2322 of zjrJS.


 

Preconditions
Javascript must be allowed to run on this page.
The version of zjrJS must be at least 20120504t1629. (Most of the Array Comprehension was added in version 20120411t0914.)

Successful When...
If the used browser natively supports array comprehension (MSIE anything older than the 9 version), the following fail before pressing the "Add Comprehension" button in the form, and succeed afterwards:

Actions
Output

    Test Code:

              var test=({
    	data: []
    	,
    	placeHolder: ({})
    	,
    	addComprehension: function() { "use strict";
    		zjrJS.Doc.addArrayComprehension();
    	}
    	,
    	init: function() { "use strict";
    		test.data = [ "apple", "banana", undefined, "coconut", "dumpling" ];
    		test.placeHolder = zjrJS.Doc.eid("placeholder");
    	}
    	,
    	listAll: function () { "use strict";
    		zjrJS.Doc.rC(test.placeHolder);
    		test.data.forEach(
    			test.lister, test.placeHolder
    		);
    	}
    	,
    	lister: function (itemValue, itemIndex, allItems ) { "use strict";
    		var D = zjrJS.Doc, li = D.cE( "li" );
    		D.aC( D.cT( itemValue ), li );
    		D.aC( li, this );
    		D = null;
    	}
    	,
    	showFruits: function() { "use strict";
    		var filteredData = test.data.filter(
    			test.fruitFilter
    		);
    		zjrJS.Doc.rC(test.placeHolder);
    		filteredData.forEach(
    			test.lister, test.placeHolder
    		);
    	}
    	,
    	fruitFilter: function(itemValue, itemIndex, allItems) { "use strict";
    		var notAFruit = "dumpling";
    		if (!itemValue) {
    			return false;
    		}
    		if (itemValue === notAFruit) {
    			return false;
    		}
    		return true;
    	}
    	,
    	everythingIsFruit: function() { "use strict";
    		var booleanEverythingIsAFruit = test.data.every(
    			test.fruitFilter
    		);
    		zjrJS.Doc.rC(test.placeHolder);
    		if (booleanEverythingIsAFruit) {
    			[ "Yes, everything is a fruit" ].forEach(
    				test.lister, test.placeHolder
    			);
    		} else {
    			[ "No, some aren't a fruit" ].forEach(
    				test.lister, test.placeHolder
    			);
    		}
    	}
    	,
    	whereIsTheCoconut: function() { "use strict";
    		var i = test.data.indexOf( "coconut");
    		[ "The coconut holds position " + i ].forEach(
    			test.lister, test.placeHolder
    		);
    	}
    	,
    	tallyLengths: function() { "use strict";
    		var tallyLength = test.data.reduce(
    			test.lengthTallier, 0
    		);
    		[ "The total length of all items = " + tallyLength ].forEach(
    			test.lister, test.placeHolder
    		);
    	}
    	,
    	lengthTallier: function(accumulator, itemValue) { "use strict";
    		if (!accumulator || isNaN(accumulator)) { accumulator = Number(0); }
    		if (!!itemValue) { if (!!itemValue.length) {
    			accumulator += Number(itemValue.length);
    		} }
    		return accumulator;
    	}
    });
    zjrJS.Doc.aE(window, "load", test.init);
            

    Download:

    Download zjrJS’ latest stable build (20141202t2322) minified (7.1KB).

    Download zjrJS’ latest stable build (20141202t2322) (11.9KB).

    Clicky Analytics