|
| 1 | +class Raises |
| 2 | + def to_c = fail |
| 3 | +end |
| 4 | + |
| 5 | +class RaisesNumeric < Numeric |
| 6 | + def to_c = fail |
| 7 | +end |
| 8 | + |
| 9 | +Complex(1) #: Complex |
| 10 | +Complex(1.23) #: Complex |
| 11 | +Complex(1r) #: Complex |
| 12 | +Complex(1i) #: Complex |
| 13 | +Complex(1ri) #: Complex |
| 14 | +Complex(Numeric.new) #: Complex |
| 15 | +Complex('1+2i') #: Complex |
| 16 | + |
| 17 | +Complex(1, exception: true) #: Complex |
| 18 | +Complex(1.23, exception: true) #: Complex |
| 19 | +Complex(1r, exception: true) #: Complex |
| 20 | +Complex(1i, exception: true) #: Complex |
| 21 | +Complex(1ri, exception: true) #: Complex |
| 22 | +Complex(Numeric.new, exception: true) #: Complex |
| 23 | +Complex("1+2i", exception: true) #: Complex |
| 24 | + |
| 25 | +Complex(Raises.new, exception: false) #: nil |
| 26 | +Complex(RaisesNumeric.new, exception: false) #: nil |
| 27 | +Complex('a', exception: false) #: nil |
| 28 | + |
| 29 | +Complex(1, 1) #: Complex |
| 30 | +Complex(1.23, 1.23) #: Complex |
| 31 | +Complex(1r, 1r) #: Complex |
| 32 | +Complex(1i, 1i) #: Complex |
| 33 | +Complex(1ri, 1ri) #: Complex |
| 34 | +Complex(Numeric.new, Numeric.new) #: Complex |
| 35 | +Complex('1+2i', '1+2i') #: Complex |
| 36 | +Complex(2, '1+2i') #: Complex |
| 37 | + |
| 38 | +Complex(1, Raises.new, exception: false) #: nil |
| 39 | +Complex(RaisesNumeric.new, 2, exception: false) #: nil |
| 40 | +Complex('a', 3, exception: false) #: nil |
| 41 | +Complex(2, :untyped, exception: false) #: nil |
0 commit comments