Boolean.prototype["while"] = function(_this_, cond, body) {
console.log("Boolean.while fallback");
if (!this.valueOf()) { return; }
body.call(_this_);
var cc = cond.call(_this_);
cc["while"](_this_, cond, body);
};
Boolean.prototype["ifElse"] = function(_this_, ifTrue, ifFalse) {
console.log("Boolean.ifElse fallback");
if (!this.valueOf()) {
return ifFalse.call(_this_);
} else {
return ifTrue.call(_this_);
}
};
var i = 0;
var c = function() { return (i < 3); };
var b = function() { console.log(i); i += 1; };
var a1 = function() { console.log("a1"); };
var a2 = function() { console.log("a2"); };
c().ifElse(this, a1, a2);
c()["while"](this, c, b);
c().ifElse(this, a1, a2);
return (i === 3);
});
test[i+=1] = autotest(function() {
function foo(a, b, c) { return a+b+c; }
return foo.length === 3;
});
test[i+=1] = autotest(function() {
function f() {
return Array.prototype.concat.apply([ this ], arguments);
}
function check(_this_, r) {
console.log(r);
return ((r.length === 4) && (r[0] === _this_) &&
(r[1] === 0) && (r[2] === 1) && (r[3] === 2));
}
if (!check(this, f.bind()(0, 1, 2))) { return false; }
var nthis = { _this_: true };
if (!check(nthis, f.bind(nthis)(0, 1, 2))) { return false; }
if (!check(nthis, f.bind(nthis, 0)(1, 2))) { return false; }
if (!check(nthis, f.bind(nthis, 0, 1)(2))) { return false; }
if (!check(nthis, f.bind(nthis, 0, 1, 2)())) { return false; }
return true;
});
test[i+=1] = autotest(function() {
if (" xy z ".trim() !== "xy z") { return false; }
if ("".trim().length !== 0) { return false; }
if (" \t ".trim().length !== 0) { return false; }
return true;
});
test[i+=1] = autotest(function() {
var a = [ 1, 2 ];
a.push(3, 4);
a.pop();
console.log(a);
if (!(a.length === 3 && !a[3])) { return false; }
if (a.join() !== "1,2,3") { return false; }
if (a.join(' ') !== "1 2 3") { return false; }
a.pop(); a.pop(); a.pop(); a.pop();
if (!(a.length === 0 && !a[0])) { return false; }
if (a.join() !== "") { return false; }
return true;
});
test[i+=1] = autotest(function() {