js-on-sx: 10 new Object.* globals (getPrototypeOf, create, is, hasOwn, defineProperty, ...)
Extends the Object global dict with: - getPrototypeOf / setPrototypeOf — read/write __proto__ chain - create(proto, props?) — builds new obj with proto and optional descriptors - defineProperty / defineProperties — descriptor.value only (no getters/setters) - getOwnPropertyNames / getOwnPropertyDescriptor(s) — simple shapes - isExtensible / isFrozen / isSealed (permissive stubs) - seal / preventExtensions (no-ops) - is — SameValue (NaN is NaN, -0 vs +0 distinguished via inspect string) - fromEntries — inverse of entries - hasOwn — explicit owner check for string keys 9 new unit tests, 506/508 total. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1213,6 +1213,26 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 3709)
|
||||
(eval "(js-eval \"var a=[1,2,3]; a.keys().join(',')\")")
|
||||
|
||||
;; ── Phase 11.objglobal: Object.getPrototypeOf, .create, .is, .hasOwn etc. ──
|
||||
(epoch 3900)
|
||||
(eval "(js-eval \"var o = Object.create(null); o.x=5; o.x\")")
|
||||
(epoch 3901)
|
||||
(eval "(js-eval \"Object.is(NaN, NaN)\")")
|
||||
(epoch 3902)
|
||||
(eval "(js-eval \"Object.is(0, 0)\")")
|
||||
(epoch 3903)
|
||||
(eval "(js-eval \"Object.hasOwn({a:1}, 'a')\")")
|
||||
(epoch 3904)
|
||||
(eval "(js-eval \"Object.hasOwn({a:1}, 'b')\")")
|
||||
(epoch 3905)
|
||||
(eval "(js-eval \"Object.fromEntries([['a',1],['b',2]]).a\")")
|
||||
(epoch 3906)
|
||||
(eval "(js-eval \"var o = {a:1}; Object.defineProperty(o,'b',{value:42}); o.b\")")
|
||||
(epoch 3907)
|
||||
(eval "(js-eval \"var o = {a:1}; Object.getOwnPropertyNames(o).length\")")
|
||||
(epoch 3908)
|
||||
(eval "(js-eval \"Object.isExtensible({})\")")
|
||||
|
||||
;; ── Phase 11.globals: NaN / Infinity / strict-eq ─────────────
|
||||
(epoch 3750)
|
||||
(eval "(js-eval \"typeof NaN\")")
|
||||
@@ -1927,6 +1947,17 @@ 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.objglobal: Object.getPrototypeOf, .create, .is, .hasOwn ──
|
||||
check 3900 "Object.create(null)" '5'
|
||||
check 3901 "Object.is(NaN,NaN)" 'true'
|
||||
check 3902 "Object.is(0,0)" 'true'
|
||||
check 3903 "Object.hasOwn a" 'true'
|
||||
check 3904 "Object.hasOwn missing" 'false'
|
||||
check 3905 "Object.fromEntries" '1'
|
||||
check 3906 "Object.defineProperty" '42'
|
||||
check 3907 "Object.getOwnPropertyNames" '1'
|
||||
check 3908 "Object.isExtensible" 'true'
|
||||
|
||||
# ── Phase 11.globals: NaN / Infinity / strict-eq ─────────────
|
||||
check 3750 "typeof NaN" '"number"'
|
||||
check 3751 "isNaN(NaN)" 'true'
|
||||
|
||||
Reference in New Issue
Block a user