@@ -808,13 +808,20 @@ Base.methodloc_callback[] = nothing
808
808
# test that no spurious visual lines are added when one element spans multiple lines
809
809
v = fill! (Array {Any} (undef, 9 ), 0 )
810
810
v[1 ] = " look I'm wide! --- " ^ 9
811
- @test replstr (v) == " 9-element Vector{Any}:\n \" look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- \"\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0"
812
- @test replstr ([fill (0 , 9 ) v]) == " 9×2 Matrix{Any}:\n 0 … \" look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- \"\n 0 0\n 0 0\n 0 0\n 0 0\n 0 … 0\n 0 0\n 0 0\n 0 0"
811
+ r = replstr (v)
812
+ @test startswith (r, " 9-element Vector{Any}:\n \" look I'm wide! ---" )
813
+ @test endswith (r, " look I'm wide! --- \"\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0" )
814
+
813
815
# test vertical/diagonal ellipsis
814
816
v = fill! (Array {Any} (undef, 50 ), 0 )
815
817
v[1 ] = " look I'm wide! --- " ^ 9
816
- @test replstr (v) == " 50-element Vector{Any}:\n \" look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- \"\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n ⋮\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0"
817
- @test replstr ([fill (0 , 50 ) v]) == " 50×2 Matrix{Any}:\n 0 … \" look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- look I'm wide! --- \"\n 0 0\n 0 0\n 0 0\n 0 0\n 0 … 0\n 0 0\n 0 0\n 0 0\n 0 0\n ⋮ ⋱ \n 0 0\n 0 0\n 0 0\n 0 0\n 0 … 0\n 0 0\n 0 0\n 0 0\n 0 0"
818
+ r = replstr (v)
819
+ @test startswith (r, " 50-element Vector{Any}:\n \" look I'm wide! ---" )
820
+ @test endswith (r, " look I'm wide! --- \"\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n ⋮\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0" )
821
+
822
+ r = replstr ([fill (0 , 50 ) v])
823
+ @test startswith (r, " 50×2 Matrix{Any}:\n 0 … \" look I'm wide! ---" )
824
+ @test endswith (r, " look I'm wide! --- \"\n 0 0\n 0 0\n 0 0\n 0 0\n 0 … 0\n 0 0\n 0 0\n 0 0\n 0 0\n ⋮ ⋱ \n 0 0\n 0 0\n 0 0\n 0 0\n 0 … 0\n 0 0\n 0 0\n 0 0\n 0 0" )
818
825
819
826
# issue #34659
820
827
@test replstr (Int32[]) == " Int32[]"
@@ -825,6 +832,45 @@ Base.methodloc_callback[] = nothing
825
832
@test replstr ([zeros (3 ,0 ),zeros (2 ,0 )]) == " 2-element Vector{Matrix{Float64}}:\n 3×0 Matrix{Float64}\n 2×0 Matrix{Float64}"
826
833
end
827
834
835
+ # string show with elision
836
+ @testset " string show with elision" begin
837
+ @testset " elision logic" begin
838
+ strs = [" A" , " ∀" , " ∀A" , " A∀" , " 😃" ]
839
+ for limit = 0 : 100 , len = 0 : 100 , str in strs
840
+ str = str^ len
841
+ str = str[1 : nextind (str, 0 , len)]
842
+ out = sprint () do io
843
+ show (io, MIME " text/plain" (), str; limit)
844
+ end
845
+ lower = length (" \"\" ⋯ $(ncodeunits (str)) bytes ⋯ \"\" " )
846
+ limit = max (limit, lower)
847
+ if length (str) + 2 ≤ limit
848
+ @test eval (Meta. parse (out)) == str
849
+ else
850
+ @test limit- ! isascii (str) <= length (out) <= limit
851
+ re = r" (\" [^\" ]*\" ) ⋯ (\d +) bytes ⋯ (\" [^\" ]*\" )"
852
+ m = match (re, out)
853
+ head = eval (Meta. parse (m. captures[1 ]))
854
+ tail = eval (Meta. parse (m. captures[3 ]))
855
+ skip = parse (Int, m. captures[2 ])
856
+ @test startswith (str, head)
857
+ @test endswith (str, tail)
858
+ @test ncodeunits (str) ==
859
+ ncodeunits (head) + skip + ncodeunits (tail)
860
+ end
861
+ end
862
+ end
863
+
864
+ @testset " default elision limit" begin
865
+ r = replstr (" x" ^ 1000 )
866
+ @test length (r) == 7 * 80
867
+ @test r == repr (" x" ^ 271 ) * " ⋯ 459 bytes ⋯ " * repr (" x" ^ 270 )
868
+ r = replstr ([" x" ^ 1000 ])
869
+ @test length (r) < 120
870
+ @test r == " 1-element Vector{String}:\n " * repr (" x" ^ 31 ) * " ⋯ 939 bytes ⋯ " * repr (" x" ^ 30 )
871
+ end
872
+ end
873
+
828
874
# Issue 14121
829
875
@test_repr " (A'x)'"
830
876
0 commit comments