File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -1042,6 +1042,19 @@ describe("computed()", () => {
1042
1042
expect ( b . peek ( ) ) . to . equal ( 2 ) ;
1043
1043
} ) ;
1044
1044
1045
+ it ( "should detect simple dependency cycles" , ( ) => {
1046
+ const a : Signal = computed ( ( ) => a . peek ( ) ) ;
1047
+ expect ( ( ) => a . peek ( ) ) . to . throw ( / C y c l e d e t e c t e d / ) ;
1048
+ } ) ;
1049
+
1050
+ it ( "should detect deep dependency cycles" , ( ) => {
1051
+ const a : Signal = computed ( ( ) => b . value ) ;
1052
+ const b : Signal = computed ( ( ) => c . value ) ;
1053
+ const c : Signal = computed ( ( ) => d . value ) ;
1054
+ const d : Signal = computed ( ( ) => a . peek ( ) ) ;
1055
+ expect ( ( ) => a . peek ( ) ) . to . throw ( / C y c l e d e t e c t e d / ) ;
1056
+ } ) ;
1057
+
1045
1058
it ( "should not make surrounding effect depend on the computed" , ( ) => {
1046
1059
const s = signal ( 1 ) ;
1047
1060
const c = computed ( ( ) => s . value ) ;
You can’t perform that action at this time.
0 commit comments