Boolean.prototype.toString.js 496 B

123456789101112131415161718192021
  1. load("test-common.js");
  2. try {
  3. var foo = true;
  4. assert(foo.toString() === "true");
  5. assert(true.toString() === "true");
  6. assert(Boolean.prototype.toString.call(true) === "true");
  7. assert(Boolean.prototype.toString.call(false) === "false");
  8. assertThrowsError(() => {
  9. Boolean.prototype.toString.call("foo");
  10. }, {
  11. error: TypeError,
  12. message: "Not a Boolean object"
  13. });
  14. console.log("PASS");
  15. } catch (err) {
  16. console.log("FAIL: " + err);
  17. }