"use strict";
(function() {
/************************/
/* Polyfills Unit Tests */
/************************/
/* HAPPY PATH TEST SUITES */
function NumberHappyPathTestSuites(polymorph) {
const N = polymorph;
this.integersShouldBeSeenAsIntegers = [
N + ".isInteger(-1) === true;",
N + ".isInteger(-1.0) === true;",
N + ".isInteger(-0) === true;",
N + ".isInteger(0) === true;",
N + ".isInteger(0.0) === true;",
N + ".isInteger(1) === true;",
N + ".isInteger(1.0) === true;"
];
this.nonIntegersShouldNotBeSeenAsIntegers = [
N + ".isInteger(-1.1) === false;",
N + ".isInteger('1') === false;",
N + ".isInteger('a') === false;",
N + ".isInteger([1]) === false;",
N + ".isInteger(undefined) === false;",
N + ".isInteger() === false;",
N + ".isInteger(Infinity) === false;"
]
}
/* TEST EXECUTION */
const tester = new $Z.TestRunner("$Z.Polyfills");
[ new NumberHappyPathTestSuites("Number"),
new NumberHappyPathTestSuites("$Z.Polyfills")
].forEach(function(testSuites) {
tester.runTests(testSuites, tester.verifyHappyPath);
});
tester.summarizeTestResults();
})();
"use strict";
/*********************/
/* BitSet Unit Tests */
/*********************/
/* HAPPY PATH TEST SUITES */
const BitSetHappyPathTestSuites = {
maxSizeOfUShouldBe32: [
"BitSet.maxSizeOfU === 32;"
],
sizeOfUShouldBeBetween0andMaxOf32: [
"new BitSet({sizeOfU: 0}).sizeOfU() === 0;",
"new BitSet({sizeOfU: 32}).sizeOfU() === 32;",
"var r = Math.ceil(Math.random() * 32); " +
"new BitSet({sizeOfU: r}).sizeOfU() === r;"
],
sizeOfUShouldDefaultToMaxOf32: [
"new BitSet().sizeOfU() === BitSet.maxSizeOfU;",
"new BitSet().sizeOfU() === 32"
],
newSetShouldBeEmptyByDefault: [
"new BitSet().valueOf() === 0;",
"new BitSet().sizeOf() === 0;",
]
};
/* EXPECTED ERROR TEST SUITES */
const BitSetExpectedErrorTestSuites = {
sizeOfUOutOfRangeShouldThrowError: [
"new BitSet({sizeOfU: -1}).sizeOfU;",
"new BitSet({sizeOfU: 33}).sizeOfU;"
]
};
/* TEST EXECUTION */
const tester = new TestRunner("BitSet");
tester.runTests(BitSetHappyPathTestSuites, tester.verifyHappyPath);
tester.runTests(BitSetExpectedErrorTestSuites, tester.verifyExpectedError);
tester.summarizeTestResults();
"use strict";
/*******************************/
/* cloneDomElement Unit Tests */
/*******************************/
"use strict";
(function () {
/* GoBots, Go! */
if (!GoBots[0]) {
GoBots[0] = new $Z.GoBots();
}
let GoBots1 = GoBots[0];
GoBots1.clear();
GoBots1.setDelay(50);
while (GoBots1.count() < 6) {
let bit = GoBots1.count() % 2;
GoBots1.fromLeft(1 + 6 * bit);
GoBots1.fromTop(1);
GoBots1.initialRotation(0 + 2 * bit);
GoBots1.addBot("gold", "black");
GoBots1.goBots();
}
if (!GoBots[1]) {
GoBots[1] = new $Z.GoBots();
}
let GoBots2 = GoBots[1];
GoBots2.clear();
GoBots2.setDelay(50);
for (let i = 0; i < 6; i++) {
let bit = GoBots2.count() % 2;
GoBots2.fromLeft(4.5);
GoBots2.fromTop(0 + 8 * bit);
GoBots2.initialRotation(1 + 2 * bit);
GoBots2.addBot("gold", "black");
GoBots2.goBots();
}
GoBots1.replay();
GoBots2.replay();
/** See Also
*
* https://en.wikipedia.org/wiki/Karel_(programming_language)
* https://en.wikipedia.org/wiki/Go,_Dog._Go!
* https://see.stanford.edu/Course/CS106A
* https://en.wikipedia.org/wiki/CodeHS
* etc.
*/
})();