Skip to content

Commit 162c668

Browse files
committed
ensure repeated references are safe
1 parent e1a4c5d commit 162c668

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,24 +382,25 @@ const fixtures = {
382382
}
383383
],
384384

385-
custom: [
385+
custom: ((instance) => [
386386
{
387387
name: 'Custom type',
388-
value: new Custom({ answer: 42 }),
388+
value: [instance, instance],
389389
js: null,
390-
json: '[["Custom",1],{"answer":2},42]',
390+
json: '[[1,1],["Custom",2],{"answer":3},42]',
391391
reducers: {
392-
Custom: (value) => value instanceof Custom && value.value
392+
Custom: (x) => x instanceof Custom && x.value
393393
},
394394
revivers: {
395-
Custom: (value) => new Custom(value)
395+
Custom: (x) => new Custom(x)
396396
},
397-
validate: (obj) => {
398-
assert.ok(obj instanceof Custom);
399-
assert.equal(obj.value.answer, 42);
397+
validate: ([obj1, obj2]) => {
398+
assert.is(obj1, obj2);
399+
assert.ok(obj1 instanceof Custom);
400+
assert.equal(obj1.value.answer, 42);
400401
}
401402
}
402-
]
403+
])(new Custom({ answer: 42 }))
403404
};
404405

405406
for (const [name, tests] of Object.entries(fixtures)) {

0 commit comments

Comments
 (0)