@@ -685,6 +685,8 @@ def msum(iterable):
685
685
([], 0.0 ),
686
686
([0.0 ], 0.0 ),
687
687
([1e100 , 1.0 , - 1e100 , 1e-100 , 1e50 , - 1.0 , - 1e50 ], 1e-100 ),
688
+ ([1e100 , 1.0 , - 1e100 , 1e-100 , 1e50 , - 1 , - 1e50 ], 1e-100 ),
689
+ ([1e100 , FloatLike (1.0 ), - 1e100 , 1e-100 , 1e50 , FloatLike (- 1.0 ), - 1e50 ], 1e-100 ),
688
690
([2.0 ** 53 , - 0.5 , - 2.0 ** - 54 ], 2.0 ** 53 - 1.0 ),
689
691
([2.0 ** 53 , 1.0 , 2.0 ** - 100 ], 2.0 ** 53 + 2.0 ),
690
692
([2.0 ** 53 + 10.0 , 1.0 , 2.0 ** - 100 ], 2.0 ** 53 + 12.0 ),
@@ -733,9 +735,18 @@ def msum(iterable):
733
735
self .assertEqual (msum (vals ), math .fsum (vals ))
734
736
735
737
self .assertEqual (math .fsum ([1.0 , math .inf ]), math .inf )
738
+ self .assertTrue (math .isnan (math .fsum ([math .nan , 1.0 ])))
736
739
self .assertRaises (OverflowError , math .fsum , [1e+308 , 1e+308 ])
737
740
self .assertRaises (ValueError , math .fsum , [math .inf , - math .inf ])
738
741
self .assertRaises (TypeError , math .fsum , ['spam' ])
742
+ self .assertRaises (TypeError , math .fsum , 1 )
743
+ self .assertRaises (OverflowError , math .fsum , [10 ** 1000 ])
744
+
745
+ def bad_iter ():
746
+ yield 1.0
747
+ raise ZeroDivisionError
748
+
749
+ self .assertRaises (ZeroDivisionError , math .fsum , bad_iter ())
739
750
740
751
def testGcd (self ):
741
752
gcd = math .gcd
0 commit comments