@@ -62,21 +62,25 @@ def test_Complex
6262 Kernel , :Complex , real_untype , exception : false
6363 end
6464
65- with '1' , 1 , 1 r, 1.0 , ( 1 +0 i) , numeric do |real |
66- with '2' , 2 , 2 r, 2.0 , ( 2 +0 i) , numeric do |imag |
65+ numeric_fail = Class . new ( Numeric ) { def to_c = fail } . new
66+
67+ with '1' , 1 , 1 r, 1.0 , ( 1 +0 i) , numeric , numeric_fail do |real |
68+ with '2' , 2 , 2 r, 2.0 , ( 2 +0 i) , numeric , numeric_fail do |imag |
6769 # (Numeric | String real, Numeric | String imag, ?exception: true) -> Complex
68- assert_send_type "(Numeric | String, Numeric | String) -> Complex" ,
69- Kernel , :Complex , real , imag
70- assert_send_type "(Numeric | String, Numeric | String, exception: true) -> Complex" ,
71- Kernel , :Complex , real , imag , exception : true
70+ if real != numeric_fail && imag != numeric_fail
71+ assert_send_type "(Numeric | String, Numeric | String) -> Complex" ,
72+ Kernel , :Complex , real , imag
73+ assert_send_type "(Numeric | String, Numeric | String, exception: true) -> Complex" ,
74+ Kernel , :Complex , real , imag , exception : true
75+ end
7276
7377 # Complex has an awkward edgecase where `exception: false` will unconditionally return `nil`
7478 # if the imaginary argument is not one of the builtin `Numeric`s. Oddly enough, it's not for
7579 # the `real` one...
7680 case imag
7781 when Integer , Float , Rational , Complex
7882 # (Numeric | String real, Integer | Float | Rational | Complex imag, exception: bool) -> Complex
79- assert_send_type "(Numeric | String, Integer | Float | Rational | Complex, exception: bool) -> Complex" ,
83+ assert_send_type "(Numeric | String, Integer | Float | Rational | Complex, exception: bool) -> Complex? " ,
8084 Kernel , :Complex , real , imag , exception : false
8185 end
8286 end
0 commit comments