Boolean.prototype.toString.js 543 B

123456789101112131415161718192021
  1. try {
  2. var foo = true;
  3. assert(foo.toString() === "true");
  4. assert(true.toString() === "true");
  5. assert(Boolean.prototype.toString.call(true) === "true");
  6. assert(Boolean.prototype.toString.call(false) === "false");
  7. try {
  8. Boolean.prototype.toString.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. }