Fix String.padStart/padEnd (#1672)

Fixes the following two bugs:

* Pads to incorrect string length
* Does not append full code point
This commit is contained in:
Daniel Chao
2026-06-10 08:34:50 -07:00
committed by GitHub
parent 44f8706616
commit 1a1e1cfea9
3 changed files with 16 additions and 6 deletions
@@ -452,6 +452,9 @@ examples {
str1.padStart(10, " ")
module.catch(() -> str1.padStart(10, ""))
module.catch(() -> str1.padStart(10, "aa"))
"🙃".padStart(5, "h")
"🙃".padStart(5, "🏀")
"hi".padStart(5, "🏀")
}
["padEnd()"] {
@@ -463,6 +466,9 @@ examples {
str1.padEnd(10, " ")
module.catch(() -> str1.padEnd(10, ""))
module.catch(() -> str1.padEnd(10, "aa"))
"🙃".padEnd(5, "h")
"🙃".padEnd(5, "🏀")
"hi".padEnd(5, "🏀")
}
["toBooleanOrNull()"] {
@@ -386,6 +386,9 @@ examples {
" abcdefg"
"Type constraint `length == 1` violated. Value: \"\""
"Type constraint `length == 1` violated. Value: \"aa\""
"hhhh🙃"
"🏀🏀🏀🏀🙃"
"🏀🏀🏀hi"
}
["padEnd()"] {
""
@@ -396,6 +399,9 @@ examples {
"abcdefg "
"Type constraint `length == 1` violated. Value: \"\""
"Type constraint `length == 1` violated. Value: \"aa\""
"🙃hhhh"
"🙃🏀🏀🏀🏀"
"hi🏀🏀🏀"
}
["toBooleanOrNull()"] {
true