function-length.js 608 B

123456789101112131415161718192021222324252627
  1. load("test-common.js");
  2. try {
  3. function foo() { }
  4. assert(foo.length === 0);
  5. assert((foo.length = 5) === 5);
  6. assert(foo.length === 0);
  7. function bar(a, b, c) {}
  8. assert(bar.length === 3);
  9. assert((bar.length = 5) === 5);
  10. assert(bar.length === 3);
  11. function baz(a, b = 1, c) {}
  12. assert(baz.length === 1);
  13. assert((baz.length = 5) === 5);
  14. assert(baz.length === 1);
  15. function qux(a, b, ...c) {}
  16. assert(qux.length === 2);
  17. assert((qux.length = 5) === 5);
  18. assert(qux.length === 2);
  19. console.log("PASS");
  20. } catch (e) {
  21. console.log("FAIL: " + e);
  22. }