dbj+cond
dbj.cond() qUnit's
by dbjdbj
HTML
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<script src="http://dbj.org/4/cond/dbj.kernel.js"></script>
<script src="http://dbj.org/4/cond/dbj.cond.js"></script>
<title>dbj+cond+qUnit</title>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
JavaScript
var print = function (x) { console.log(x); return print; }
module("dbj.cond() tests");
test("singulars", function () {
ok( !! dbj, "dbj is defined");
ok( !! dbj.cond, "dbj.cond is defined");
function testera(call, exp, msg) {
strictEqual(
eval(call), exp,
msg || ('PASSED :: ' + call + " // => " + exp));
}
var x = 1;
switch (true) {
case (print("1"), x > 0):
equal(x, x > 0, "x > 0");
break;
case (print("2"), x < 0):
equal(x, x < 0, "x > 0");
break;
case (print("3"), x == 0):
equal(x, x == 0, "x > 0");
break;
case (print("4"), x != 0):
equal(x, x != 0, "x > 0");
break;
default:
ok(false, "unwanted switch() propagation");
};
});