File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
packages/svelte/tests/signals Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -963,6 +963,36 @@ describe('signals', () => {
963963 } ;
964964 } ) ;
965965
966+ test ( 'deriveds do not depend on state they own' , ( ) => {
967+ return ( ) => {
968+ let s ;
969+
970+ const d = derived ( ( ) => {
971+ s = state ( 0 ) ;
972+ return $ . get ( s ) ;
973+ } ) ;
974+
975+ assert . equal ( $ . get ( d ) , 0 ) ;
976+
977+ set ( s ! , 1 ) ;
978+ assert . equal ( $ . get ( d ) , 0 ) ;
979+ } ;
980+ } ) ;
981+
982+ test ( 'effects do not depend on state they own' , ( ) => {
983+ return ( ) => {
984+ const destroy = effect_root ( ( ) => {
985+ user_effect ( ( ) => {
986+ const s = state ( 0 ) ;
987+ set ( s , $ . get ( s ) + 1 ) ;
988+ } ) ;
989+ } ) ;
990+
991+ assert . ok ( true ) ;
992+ destroy ( ) ;
993+ } ;
994+ } ) ;
995+
966996 test ( 'proxy version state does not trigger self-dependency guard' , ( ) => {
967997 return ( ) => {
968998 const s = proxy ( { a : { b : 1 } } ) ;
You can’t perform that action at this time.
0 commit comments