Skip to content

Commit f2fcbb1

Browse files
Fix method ambiguity (#65)
* Add Aqua to test deps and to test import. * Added method to avoid method ambiguity. Base.getindex(s::LaTeXString, i::AbstractUnitRange{<:Integer}) * Made version 1.3.1 * Improved coverage --------- Co-authored-by: Keith Myerscough <[email protected]>
1 parent a84e05a commit f2fcbb1

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
name = "LaTeXStrings"
22
uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
3-
version = "1.3"
3+
version = "1.3.1"
44

55
[compat]
66
julia = "1"
77

88
[extras]
9+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
910
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
1011
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1112

1213
[targets]
13-
test = ["Documenter", "Test"]
14+
test = ["Aqua", "Documenter", "Test"]

src/LaTeXStrings.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Base.getindex(s::LaTeXString, i::Integer) = getindex(s.s, i)
117117
Base.getindex(s::LaTeXString, i::Int) = getindex(s.s, i) # for method ambig in Julia 0.6
118118
Base.getindex(s::LaTeXString, i::UnitRange{Int}) = getindex(s.s, i)
119119
Base.getindex(s::LaTeXString, i::UnitRange{<:Integer}) = getindex(s.s, i)
120+
Base.getindex(s::LaTeXString, i::AbstractUnitRange{<:Integer}) = getindex(s.s, i) # for method ambiguity
120121
Base.getindex(s::LaTeXString, i::AbstractVector{<:Integer}) = getindex(s.s, i)
121122
Base.getindex(s::LaTeXString, i::AbstractVector{Bool}) = getindex(s.s, i) # for method ambiguity
122123
Base.codeunit(s::LaTeXString, i::Integer) = codeunit(s.s, i)

test/runtests.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
using LaTeXStrings, Test
2+
import Aqua
3+
using Base: OneTo
4+
5+
Aqua.test_all(LaTeXStrings)
26

37
tst1 = L"an equation: $\alpha^2$"
48
tst1s = String(tst1)
@@ -61,15 +65,23 @@ end
6165
tst1 = L"an equation: $\alpha^2$"
6266
tst1s = String(tst1)
6367

68+
@test firstindex(tst1) == 1
69+
@test lastindex(tst1) == length(tst1)
70+
6471
@test tst1[5] == tst1s[5]
6572
@test tst1[15] == tst1s[15]
6673

6774
idx = [5, 10, 15]
6875
@test tst1[idx] == tst1s[idx]
6976

70-
# issue #61
71-
idx = rand(Bool, length(tst1))
72-
@test_throws ArgumentError tst1[idx]
77+
# to test for ambiguities (#61, #65)
78+
bool_idx = rand(Bool, length(tst1))
79+
@test_throws ArgumentError tst1[bool_idx]
80+
81+
@test tst1[UInt(5)] == tst1[5]
82+
@test tst1[UInt.(idx)] == tst1[idx]
83+
84+
@test tst1[OneTo(5)] == tst1[1:5]
7385
end
7486

7587
using Documenter

0 commit comments

Comments
 (0)