Array.prototype.concat.js 1018 B

12345678910111213141516171819202122232425262728293031323334353637
  1. load("test-common.js");
  2. try {
  3. assert(Array.prototype.concat.length === 1);
  4. var array = ["hello", "friends"];
  5. var array_concat = array.concat();
  6. assert(array_concat.length === array.length);
  7. array_concat = array.concat(1)
  8. assert(array_concat.length === 3);
  9. assert(array_concat[2] === 1);
  10. array_concat = array.concat([1, 2, 3])
  11. assert(array_concat.length === 5);
  12. assert(array_concat[2] === 1);
  13. assert(array_concat[3] === 2);
  14. assert(array_concat[4] === 3);
  15. array_concat = array.concat(false, "serenity");
  16. assert(array_concat.length === 4);
  17. assert(array_concat[2] === false);
  18. assert(array_concat[3] === "serenity");
  19. array_concat = array.concat({ name: "libjs" }, [1, [2, 3]]);
  20. assert(array_concat.length === 5);
  21. assert(array_concat[2].name === "libjs");
  22. assert(array_concat[3] === 1);
  23. assert(array_concat[4][0] === 2);
  24. assert(array_concat[4][1] === 3);
  25. console.log("PASS");
  26. } catch (e) {
  27. console.log("FAIL: " + e);
  28. }