Added _trimBegin() and _trimEnd()

This commit is contained in:
2023-02-06 06:11:17 +00:00
parent 0b9051cab2
commit 9a6aa8d15e
2 changed files with 206 additions and 23 deletions

View File

@@ -137,33 +137,38 @@ import compound;
//test trim defaults
{
//test a bunch
fn test(s, pass) {
var result = s.trim();
assert result == pass, "_trim(" + result + ") failed";
{
//test a bunch
fn test(s, pass) {
var result = s.trim();
assert result == pass, "_trim(" + result + ") failed";
}
test("hello world", "hello world");
test(" hello world", "hello world");
test("hello world ", "hello world");
test(" hello world ", "hello world");
test(" hello world", "hello world");
test("hello world ", "hello world");
test(" hello world ", "hello world");
test(" hello world", "hello world");
test("hello world ", "hello world");
test(" hello world ", "hello world");
//one for goot luck
assert " hello world ".trim() == "hello world", "hello world.trim() failed";
}
test("hello world", "hello world");
test(" hello world", "hello world");
test("hello world ", "hello world");
test(" hello world ", "hello world");
test(" hello world", "hello world");
test("hello world ", "hello world");
test(" hello world ", "hello world");
test(" hello world", "hello world");
test("hello world ", "hello world");
test(" hello world ", "hello world");
//test trim custom values
{
var chars = "heilod";
//one for goot luck
assert " hello world ".trim() == "hello world", "hello world.trim() failed";
}
assert "hello world".trim(chars) == " wor", "custom _trim() failed";
}
//test trim custom values
{
var chars = "heilod";
assert "hello world".trim(chars) == " wor", "custom _trim() failed";
//test trimBegin()
assert " foo ".trimBegin() == "foo ", "string.trimBegin() failed";
assert " foo ".trimEnd() == " foo", "string.trimBegin() failed";
}