|
|
|
@ -15,6 +15,7 @@ import { derived } from '../../src/internal/client/reactivity/deriveds';
|
|
|
|
|
import { snapshot } from '../../src/internal/shared/clone.js';
|
|
|
|
|
import { SvelteSet } from '../../src/reactivity/set';
|
|
|
|
|
import { DESTROYED } from '../../src/internal/client/constants';
|
|
|
|
|
import { noop } from 'svelte/internal/client';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param runes runes mode
|
|
|
|
@ -469,6 +470,9 @@ describe('signals', () => {
|
|
|
|
|
test('schedules rerun when writing to signal before reading it', (runes) => {
|
|
|
|
|
if (!runes) return () => {};
|
|
|
|
|
|
|
|
|
|
const error = console.error;
|
|
|
|
|
console.error = noop;
|
|
|
|
|
|
|
|
|
|
const value = state({ count: 0 });
|
|
|
|
|
user_effect(() => {
|
|
|
|
|
set(value, { count: 0 });
|
|
|
|
@ -482,14 +486,19 @@ describe('signals', () => {
|
|
|
|
|
} catch (e: any) {
|
|
|
|
|
assert.include(e.message, 'effect_update_depth_exceeded');
|
|
|
|
|
errored = true;
|
|
|
|
|
} finally {
|
|
|
|
|
assert.equal(errored, true);
|
|
|
|
|
console.error = error;
|
|
|
|
|
}
|
|
|
|
|
assert.equal(errored, true);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('schedules rerun when updating deeply nested value', (runes) => {
|
|
|
|
|
if (!runes) return () => {};
|
|
|
|
|
|
|
|
|
|
const error = console.error;
|
|
|
|
|
console.error = noop;
|
|
|
|
|
|
|
|
|
|
const value = proxy({ a: { b: { c: 0 } } });
|
|
|
|
|
user_effect(() => {
|
|
|
|
|
value.a.b.c += 1;
|
|
|
|
@ -502,14 +511,19 @@ describe('signals', () => {
|
|
|
|
|
} catch (e: any) {
|
|
|
|
|
assert.include(e.message, 'effect_update_depth_exceeded');
|
|
|
|
|
errored = true;
|
|
|
|
|
} finally {
|
|
|
|
|
assert.equal(errored, true);
|
|
|
|
|
console.error = error;
|
|
|
|
|
}
|
|
|
|
|
assert.equal(errored, true);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('schedules rerun when writing to signal before reading it', (runes) => {
|
|
|
|
|
if (!runes) return () => {};
|
|
|
|
|
|
|
|
|
|
const error = console.error;
|
|
|
|
|
console.error = noop;
|
|
|
|
|
|
|
|
|
|
const value = proxy({ arr: [] });
|
|
|
|
|
user_effect(() => {
|
|
|
|
|
value.arr = [];
|
|
|
|
@ -523,8 +537,10 @@ describe('signals', () => {
|
|
|
|
|
} catch (e: any) {
|
|
|
|
|
assert.include(e.message, 'effect_update_depth_exceeded');
|
|
|
|
|
errored = true;
|
|
|
|
|
} finally {
|
|
|
|
|
assert.equal(errored, true);
|
|
|
|
|
console.error = error;
|
|
|
|
|
}
|
|
|
|
|
assert.equal(errored, true);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|