@@ -37,6 +37,16 @@ function test(text: string, fn: (runes: boolean) => any) {
37
37
it ( `${ text } (runes mode)` , run_test ( true , fn ) ) ;
38
38
}
39
39
40
+ test . only = ( text : string , fn : ( runes : boolean ) => any ) => {
41
+ it . only ( `${ text } (legacy mode)` , run_test ( false , fn ) ) ;
42
+ it . only ( `${ text } (runes mode)` , run_test ( true , fn ) ) ;
43
+ } ;
44
+
45
+ test . skip = ( text : string , fn : ( runes : boolean ) => any ) => {
46
+ it . skip ( `${ text } (legacy mode)` , run_test ( false , fn ) ) ;
47
+ it . skip ( `${ text } (runes mode)` , run_test ( true , fn ) ) ;
48
+ } ;
49
+
40
50
describe ( 'signals' , ( ) => {
41
51
test ( 'effect with state and derived in it' , ( ) => {
42
52
const log : string [ ] = [ ] ;
@@ -537,4 +547,29 @@ describe('signals', () => {
537
547
assert . deepEqual ( branch , 'if' ) ;
538
548
} ;
539
549
} ) ;
550
+
551
+ test ( 'unowned deriveds are not added as reactions' , ( ) => {
552
+ var count = source ( 0 ) ;
553
+
554
+ function create_derived ( ) {
555
+ return derived ( ( ) => $ . get ( count ) * 2 ) ;
556
+ }
557
+
558
+ return ( ) => {
559
+ let d = create_derived ( ) ;
560
+ assert . equal ( $ . get ( d ) , 0 ) ;
561
+ assert . equal ( count . reactions , null ) ;
562
+ assert . equal ( d . deps ?. length , 1 ) ;
563
+
564
+ set ( count , 1 ) ;
565
+ assert . equal ( $ . get ( d ) , 2 ) ;
566
+ assert . equal ( count . reactions , null ) ;
567
+ assert . equal ( d . deps ?. length , 1 ) ;
568
+
569
+ d = create_derived ( ) ;
570
+ assert . equal ( $ . get ( d ) , 2 ) ;
571
+ assert . equal ( count . reactions , null ) ;
572
+ assert . equal ( d . deps ?. length , 1 ) ;
573
+ } ;
574
+ } ) ;
540
575
} ) ;
0 commit comments