Array.prototype.join.js 610 B

12345678910111213141516171819
  1. load("test-common.js");
  2. try {
  3. assert(Array.prototype.join.length === 1);
  4. assert(["hello", "friends"].join() === "hello,friends");
  5. assert(["hello", "friends"].join(" ") === "hello friends");
  6. assert(["hello", "friends", "foo"].join("~", "#") === "hello~friends~foo");
  7. assert([].join() === "");
  8. assert([null].join() === "");
  9. assert([undefined].join() === "");
  10. assert([undefined, null, ""].join() === ",,");
  11. assert([1, null, 2, undefined, 3].join() === "1,,2,,3");
  12. assert(Array(3).join() === ",,");
  13. console.log("PASS");
  14. } catch (e) {
  15. console.log("FAIL: " + e);
  16. }