Skip to content

Commit b722d45

Browse files
committed
added typecheck for complex
1 parent 8a1ed2b commit b722d45

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

test/typecheck/complex/Steepfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
D = Steep::Diagnostic
2+
3+
target :test do
4+
signature "."
5+
check "."
6+
configure_code_diagnostics(D::Ruby.all_error)
7+
end

test/typecheck/complex/test.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

test/typecheck/complex/test.rbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Raises
2+
def to_c: () -> bot
3+
end
4+
5+
class RaisesNumeric < Numeric
6+
def to_c: () -> bot
7+
end

0 commit comments

Comments
 (0)