@@ -865,7 +865,7 @@ describe("computed()", () => {
865
865
expect ( ( ) => effect ( ( ) => a . value ) ) . to . not . throw ( ) ;
866
866
} ) ;
867
867
868
- it ( "should store failures and recompute only after a dependency changes" , ( ) => {
868
+ it ( "should store thrown errors and recompute only after a dependency changes" , ( ) => {
869
869
const a = signal ( 0 ) ;
870
870
const spy = sinon . spy ( ( ) => {
871
871
a . value ;
@@ -880,6 +880,39 @@ describe("computed()", () => {
880
880
expect ( spy ) . to . be . calledTwice ;
881
881
} ) ;
882
882
883
+ it ( "should store thrown non-errors and recompute only after a dependency changes" , ( ) => {
884
+ const a = signal ( 0 ) ;
885
+ const spy = sinon . spy ( ) ;
886
+ const c = computed ( ( ) => {
887
+ a . value ;
888
+ spy ( ) ;
889
+ throw undefined ;
890
+ } ) ;
891
+
892
+ try {
893
+ c . value ;
894
+ expect . fail ( ) ;
895
+ } catch ( err ) {
896
+ expect ( err ) . to . be . undefined ;
897
+ }
898
+ try {
899
+ c . value ;
900
+ expect . fail ( ) ;
901
+ } catch ( err ) {
902
+ expect ( err ) . to . be . undefined ;
903
+ }
904
+ expect ( spy ) . to . be . calledOnce ;
905
+
906
+ a . value = 1 ;
907
+ try {
908
+ c . value ;
909
+ expect . fail ( ) ;
910
+ } catch ( err ) {
911
+ expect ( err ) . to . be . undefined ;
912
+ }
913
+ expect ( spy ) . to . be . calledTwice ;
914
+ } ) ;
915
+
883
916
it ( "should conditionally unsubscribe from signals" , ( ) => {
884
917
const a = signal ( "a" ) ;
885
918
const b = signal ( "b" ) ;
@@ -1529,14 +1562,25 @@ describe("batch/transaction", () => {
1529
1562
expect ( batch ( ( ) => 1 ) ) . to . equal ( 1 ) ;
1530
1563
} ) ;
1531
1564
1532
- it ( "should throw the error raised from the callback" , ( ) => {
1565
+ it ( "should throw errors throws from the callback" , ( ) => {
1533
1566
expect ( ( ) =>
1534
1567
batch ( ( ) => {
1535
1568
throw Error ( "hello" ) ;
1536
1569
} )
1537
1570
) . to . throw ( "hello" ) ;
1538
1571
} ) ;
1539
1572
1573
+ it ( "should throw non-errors thrown from the callback" , ( ) => {
1574
+ try {
1575
+ batch ( ( ) => {
1576
+ throw undefined ;
1577
+ } ) ;
1578
+ expect . fail ( ) ;
1579
+ } catch ( err ) {
1580
+ expect ( err ) . to . be . undefined ;
1581
+ }
1582
+ } ) ;
1583
+
1540
1584
it ( "should delay writes" , ( ) => {
1541
1585
const a = signal ( "a" ) ;
1542
1586
const b = signal ( "b" ) ;
0 commit comments