Skip to content

Commit 604a9ae

Browse files
tpappmateuszbaran
andauthored
Add a two-argument show method for SUnitRange. (#936)
* Add a two-argument show method for SUnitRange. * bump version to 1.2.7 Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
1 parent 884b943 commit 604a9ae

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArrays"
22
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3-
version = "1.2.6"
3+
version = "1.2.7"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/SUnitRange.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ end
2525
return Start + i - 1
2626
end
2727

28-
# Shorten show for REPL use.
29-
function show(io::IO, ::MIME"text/plain", ::SUnitRange{Start, L}) where {Start, L}
28+
function show(io::IO, ::SUnitRange{Start, L}) where {Start, L}
3029
print(io, "SUnitRange($Start,$(Start + L - 1))")
3130
end
31+
32+
# Shorten show for REPL use.
33+
show(io::IO, ::MIME"text/plain", su::SUnitRange) = show(io, su)

test/SUnitRange.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@
1010

1111
@test_throws Exception StaticArrays.SUnitRange{1, -1}()
1212
@test_throws TypeError StaticArrays.SUnitRange{1, 1.5}()
13+
14+
let su = StaticArrays.SUnitRange(1, 2),
15+
str = "SUnitRange(1,2)",
16+
str2 = "($(str), $(str))"
17+
@test repr(su) == str
18+
@test repr("text/plain", su) == str
19+
@test repr((su, su)) == str2
20+
@test repr("text/plain", (su, su)) == str2
21+
end
1322
end

0 commit comments

Comments
 (0)