js-on-sx: 10 new String.prototype methods (at, codePointAt, lastIndexOf, localeCompare, replaceAll, normalize, ...)
New methods added: - at(i) — negative-index aware - codePointAt(i) — returns char code at index - lastIndexOf — walks right-to-left via js-string-last-index-of helper - localeCompare — simple lexicographic (ignores locale) - replaceAll — works with strings and regex-source - normalize — no-op stub - toLocaleLowerCase / toLocaleUpperCase — delegate to non-locale variants - isWellFormed / toWellFormed — assume always well-formed 10 new unit tests, 489/491 total. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1213,6 +1213,28 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 3709)
|
||||
(eval "(js-eval \"var a=[1,2,3]; a.keys().join(',')\")")
|
||||
|
||||
;; ── Phase 11.strmore: more String.prototype methods ─────────
|
||||
(epoch 3800)
|
||||
(eval "(js-eval \"'hello'.at(0)\")")
|
||||
(epoch 3801)
|
||||
(eval "(js-eval \"'hello'.at(-1)\")")
|
||||
(epoch 3802)
|
||||
(eval "(js-eval \"'hello'.codePointAt(0)\")")
|
||||
(epoch 3803)
|
||||
(eval "(js-eval \"'hello world hello'.lastIndexOf('hello')\")")
|
||||
(epoch 3804)
|
||||
(eval "(js-eval \"'abc'.localeCompare('abd')\")")
|
||||
(epoch 3805)
|
||||
(eval "(js-eval \"'abc'.localeCompare('abc')\")")
|
||||
(epoch 3806)
|
||||
(eval "(js-eval \"'hello hello'.replaceAll('hello', 'bye')\")")
|
||||
(epoch 3807)
|
||||
(eval "(js-eval \"'a,b,c'.replaceAll(',', '-')\")")
|
||||
(epoch 3808)
|
||||
(eval "(js-eval \"'hi'.toLocaleUpperCase()\")")
|
||||
(epoch 3809)
|
||||
(eval "(js-eval \"'HI'.toLocaleLowerCase()\")")
|
||||
|
||||
;; ── Phase 11.arrlike: Array.prototype.* on {length, 0:..., 1:...} ──
|
||||
(epoch 3500)
|
||||
(eval "(js-eval \"var a = {length: 3, 0: 41, 1: 42, 2: 43}; Array.prototype.slice.call(a).length\")")
|
||||
@@ -1887,6 +1909,18 @@ check 3707 "arr.toReversed" '"2,1,3"'
|
||||
check 3708 "arr.toSorted" '"1,1,3,4,5"'
|
||||
check 3709 "arr.keys" '"0,1,2"'
|
||||
|
||||
# ── Phase 11.strmore: more String.prototype methods ───────────
|
||||
check 3800 "'hello'.at(0)" '"h"'
|
||||
check 3801 "'hello'.at(-1)" '"o"'
|
||||
check 3802 "'hello'.codePointAt(0)" '104'
|
||||
check 3803 "lastIndexOf found" '12'
|
||||
check 3804 "localeCompare less" '-1'
|
||||
check 3805 "localeCompare equal" '0'
|
||||
check 3806 "replaceAll multiple" '"bye bye"'
|
||||
check 3807 "replaceAll commas" '"a-b-c"'
|
||||
check 3808 "toLocaleUpperCase" '"HI"'
|
||||
check 3809 "toLocaleLowerCase" '"hi"'
|
||||
|
||||
# ── Phase 11.arrlike: array-like receivers on Array.prototype ─
|
||||
check 3500 "slice.call arrLike length" '3'
|
||||
check 3501 "slice.call arrLike join" '"41,42,43"'
|
||||
|
||||
Reference in New Issue
Block a user