Boolean.prototype.valueOf.js 530 B

123456789101112131415161718192021
  1. try {
  2. var foo = true;
  3. assert(foo.valueOf() === true);
  4. assert(true.valueOf() === true);
  5. assert(Boolean.prototype.valueOf.call(true) === true);
  6. assert(Boolean.prototype.valueOf.call(false) === false);
  7. try {
  8. Boolean.prototype.valueOf.call("foo");
  9. assertNotReached();
  10. } catch (e) {
  11. assert(e instanceof Error);
  12. assert(e.name === "TypeError");
  13. assert(e.message === "Not a Boolean");
  14. }
  15. console.log("PASS");
  16. } catch (err) {
  17. console.log("FAIL: " + err);
  18. }