fix(js): deepFreeze recurses below already-frozen parents
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
22c221a042
commit
e9c41fed03
@@ -45,3 +45,13 @@ test('m01 deepFreeze returns the same object it was given', () => {
|
||||
const o = {}
|
||||
assert.equal(deepFreeze(o), o)
|
||||
})
|
||||
test('m01 deepFreeze reaches unfrozen children of an already-frozen parent', () => {
|
||||
const o = deepFreeze({ a: Object.freeze({ b: { c: 1 } }) })
|
||||
assert.ok(Object.isFrozen(o.a.b))
|
||||
})
|
||||
test('m01 deepFreeze handles cyclic objects', () => {
|
||||
const o = { child: {} }
|
||||
o.child.parent = o
|
||||
deepFreeze(o)
|
||||
assert.ok(Object.isFrozen(o) && Object.isFrozen(o.child))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user