|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import { describe, assert, it } from 'vitest';
|
|
|
|
|
import * as $ from '../../src/internal/client/runtime';
|
|
|
|
|
import type { ComputationSignal } from '../../src/internal/client/types';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param runes runes mode
|
|
|
|
|
@ -199,6 +200,38 @@ describe('signals', () => {
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('correctly cleanup onowned nested derived values', () => {
|
|
|
|
|
return () => {
|
|
|
|
|
const nested: ComputationSignal<string>[] = [];
|
|
|
|
|
|
|
|
|
|
const a = $.source(0);
|
|
|
|
|
const b = $.source(0);
|
|
|
|
|
const c = $.derived(() => {
|
|
|
|
|
const a_2 = $.derived(() => $.get(a) + '!');
|
|
|
|
|
const b_2 = $.derived(() => $.get(b) + '?');
|
|
|
|
|
nested.push(a_2, b_2);
|
|
|
|
|
|
|
|
|
|
return { a: $.get(a_2), b: $.get(b_2) };
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$.get(c);
|
|
|
|
|
|
|
|
|
|
$.flushSync(() => $.set(a, 1));
|
|
|
|
|
|
|
|
|
|
$.get(c);
|
|
|
|
|
|
|
|
|
|
$.flushSync(() => $.set(b, 1));
|
|
|
|
|
|
|
|
|
|
$.get(c);
|
|
|
|
|
|
|
|
|
|
// Ensure we're not leaking dependencies
|
|
|
|
|
assert.deepEqual(
|
|
|
|
|
nested.slice(0, -2).map((s) => s.d),
|
|
|
|
|
[null, null, null, null]
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// outside of test function so that they are unowned signals
|
|
|
|
|
let count = $.source(0);
|
|
|
|
|
let calc = $.derived(() => {
|
|
|
|
|
|