Skip to content

Commit f0f77b3

Browse files
committed
lambertw tests: check correct type inference
1 parent fa424fe commit f0f77b3

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/lambertw.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@
33
@test_throws DomainError lambertw(-2.0, 0)
44
@test_throws DomainError lambertw(-2.0, -1)
55
@test_throws DomainError lambertw(-2.0, 1)
6-
@test isnan(lambertw(NaN))
6+
@test isnan(@inferred(lambertw(NaN)))
77

88
## math constant e
99
@test_throws DomainError lambertw(MathConstants.e, 1)
1010
@test_throws DomainError lambertw(MathConstants.e, -1)
1111

1212
## integer arguments return floating point types
13-
@test lambertw(0) isa AbstractFloat
14-
@test lambertw(0) == 0
13+
@test @inferred(lambertw(0)) isa AbstractFloat
14+
@test @inferred(lambertw(0)) == 0
1515

1616
### math constant, MathConstants.e e
1717

1818
# could return math const e, but this would break type stability
19-
@test lambertw(1) isa AbstractFloat
20-
@test lambertw(MathConstants.e, 0) == 1
19+
@test @inferred(lambertw(1)) isa AbstractFloat
20+
@test @inferred(lambertw(MathConstants.e, 0)) == 1
2121

2222
## value at branch point where real branches meet
2323
@test lambertw(-inv(MathConstants.e), 0) == lambertw(-inv(MathConstants.e), -1) == -1
2424
@test typeof(lambertw(-inv(MathConstants.e), 0)) == typeof(lambertw(-inv(MathConstants.e), -1)) <: AbstractFloat
2525

2626
## convert irrationals to float
2727

28-
@test isapprox(lambertw(pi), 1.0736581947961492)
29-
@test isapprox(lambertw(pi, 0), 1.0736581947961492)
28+
@test isapprox(@inferred(lambertw(pi)), 1.0736581947961492)
29+
@test isapprox(@inferred(lambertw(pi, 0)), 1.0736581947961492)
3030

3131
### infinite args or return values
3232

3333
@test lambertw(0, -1) == lambertw(0.0, -1) == -Inf
3434
@test lambertw(Inf, 0) == Inf
35-
@test lambertw(complex(Inf, 1), 0) == complex(Inf, 1)
35+
@test @inferred(lambertw(complex(Inf, 1), 0)) == complex(Inf, 1)
3636
@test lambertw(complex(Inf, 0), 1) == complex(Inf, 2pi)
3737
@test lambertw(complex(-Inf, 0), 1) == complex(Inf, 3pi)
38-
@test lambertw(complex(0.0, 0.0), -1) == complex(-Inf, 0.0)
38+
@test @inferred(lambertw(complex(0.0, 0.0), -1)) == complex(-Inf, 0.0)
3939

4040
## default branch is k = 0
4141
@test lambertw(1.0) == lambertw(1.0, 0)
4242

4343
## BigInt args return BigFloats
44-
@test typeof(lambertw(BigInt(0))) == BigFloat
45-
@test typeof(lambertw(BigInt(3))) == BigFloat
44+
@test @inferred(lambertw(BigInt(0))) isa BigFloat
45+
@test @inferred(lambertw(BigInt(3))) isa BigFloat
4646

4747
## Any Integer type allowed for second argument
4848
@test lambertw(-0.2, -1) == lambertw(-0.2, BigInt(-1))
@@ -145,8 +145,8 @@ end
145145

146146
# test the expansion about branch point for k=-1,
147147
# by comparing to exact BigFloat calculation.
148-
@test lambertwbp(1e-20, -1) - 1 - lambertw(-inv(big(MathConstants.e)) + BigFloat(10)^BigFloat(-20), -1) < 1e-16
148+
@test @inferred(lambertwbp(1e-20, -1)) - 1 - lambertw(-inv(big(MathConstants.e)) + BigFloat(10)^BigFloat(-20), -1) < 1e-16
149149

150-
@test abs(lambertwbp(Complex(.01, .01), -1) - Complex(-0.2755038208041206, -0.1277888928494641)) < 1e-14
150+
@test abs(@inferred(lambertwbp(Complex(.01, .01), -1)) - Complex(-0.2755038208041206, -0.1277888928494641)) < 1e-14
151151

152152
end # if Int != Int32

0 commit comments

Comments
 (0)