Skip to content

Increase exception-type specificity for a few errors and tests #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/convert.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(::Type{SA})(x::Tuple{Tuple{Tuple{<:Tuple}}}) where {SA <: StaticArray} = error("No precise constructor for $SA found. Length of input was $(length(x[1][1][1])).")
(::Type{SA})(x::Tuple{Tuple{Tuple{<:Tuple}}}) where {SA <: StaticArray} =
throw(DimensionMismatch("No precise constructor for $SA found. Length of input was $(length(x[1][1][1]))."))

@inline (::Type{SA})(x...) where {SA <: StaticArray} = SA(x)
@inline (::Type{SA})(a::StaticArray) where {SA<:StaticArray} = SA(Tuple(a))
Expand Down
2 changes: 1 addition & 1 deletion test/FieldVector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@test [[Point3D(1.0,2.0,3.0)]; [Point3D(4.0,5.0,6.0)]]::Vector{Point3D} == [Point3D(1.0,2.0,3.0), Point3D(4.0,5.0,6.0)]

# Issue 342
@test_throws ErrorException Point3D(1,2,3,4)
@test_throws DimensionMismatch("No precise constructor for Point3D found. Length of input was 4.") Point3D(1,2,3,4)
end

@testset "Mutable Point2D" begin
Expand Down
4 changes: 2 additions & 2 deletions test/SDiagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ using StaticArrays, Test, LinearAlgebra
end
end

@test_throws Exception m[5,5]
@test_throws BoundsError m[5,5]

@test_throws Exception m[1,5]
@test_throws BoundsError m[1,5]


@test size(m) === (4, 4)
Expand Down
4 changes: 2 additions & 2 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@testset "Type parameter errors" begin
# (not sure what type of exception these should be?)
@test_throws Exception SVector{1.0,Int}((1,))
@test_throws Exception SVector{2,Int}((1,))
@test_throws DimensionMismatch("No precise constructor for SArray{Tuple{2},$Int,1,2} found. Length of input was 1.") SVector{2,Int}((1,))
@test_throws Exception SVector{1,3}((1,))

@test_throws Exception SMatrix{1.0,1,Int,1}((1,))
Expand Down Expand Up @@ -134,13 +134,13 @@
@test @inferred(convert(Array{Int}, ma)) == a
@test @inferred(convert(Array{Int,2}, ma)) == a

# broken, see https://github.com/JuliaArrays/StaticArrays.jl/pull/448#discussion_r197977273
try
convert(SVector, [1,2,3])
catch err
@test isa(err, ErrorException)
@test startswith(err.msg, "The size of type")
end
@test_throws DimensionMismatch("expected input array of length 2, got length 3") convert(SVector{2}, [1,2,3])
end
@test_throws Exception Length{2.5}()
@test Length(2) == Length{2}()
Expand Down