Skip to content

Commit

Permalink
Test type inference
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffFessler committed Jan 2, 2023
1 parent 880562e commit 3cca3f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/strang.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ LinearAlgebra.isposdef(s::Strang) = true
@boundscheck checkbounds(A, i, j)
if i == j
return T(2)
elseif i == j + 1 || i == j - 1
elseif abs(i-j) == 1
return -one(T)
else
return zero(T)
Expand Down
8 changes: 7 additions & 1 deletion test/strang.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ using Test: @test, @testset, @test_throws, @inferred
@test A isa Strang{Int16}
@test A == diagm(0 => 2ones(n), 1 => -ones(n-1), -1 => -ones(n-1))

@test (@inferred getindex(A, 1, 2)) == -1
@test A[begin] == 2
@test A[end] == 2
@test A[1,end] == 0

x = rand(n)
@test A * x Matrix(A) * x
y = @inferred *(A, x)
@test y Matrix(A) * x
end

0 comments on commit 3cca3f9

Please sign in to comment.