String.prototype.substring.js 766 B

12345678910111213141516171819
  1. load("test-common.js");
  2. try {
  3. assert(String.prototype.substring.length === 2);
  4. assert("hello friends".substring() === "hello friends");
  5. assert("hello friends".substring(1) === "ello friends");
  6. assert("hello friends".substring(0, 5) === "hello");
  7. assert("hello friends".substring(13, 6) === "friends");
  8. assert("hello friends".substring('', 5) === "hello");
  9. assert("hello friends".substring(3, 3) === "");
  10. assert("hello friends".substring(-1, 13) === "hello friends");
  11. assert("hello friends".substring(0, 50) === "hello friends");
  12. assert("hello friends".substring(0, "5") === "hello");
  13. assert("hello friends".substring("6", "13") === "friends");
  14. console.log("PASS");
  15. } catch (err) {
  16. console.log("FAIL: " + err);
  17. }