File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2
2
3
- show (io:: IO , :: UndefInitializer ) = print (io, " array initializer with undefined values" )
3
+ function show (io:: IO , :: MIME"text/plain" , u:: UndefInitializer )
4
+ print (io, u, " : array initializer with undefined values" )
5
+ end
4
6
5
7
# first a few multiline show functions for types defined before the MIME type:
6
8
Original file line number Diff line number Diff line change @@ -1541,6 +1541,21 @@ end
1541
1541
Z = Array {Float64} (undef,0 ,0 )
1542
1542
@test eval (Meta. parse (repr (Z))) == Z
1543
1543
1544
+ @testset " show undef" begin
1545
+ # issue #33204 - Parseable `repr` for `undef`
1546
+ @test eval (Meta. parse (repr (undef))) == undef == UndefInitializer ()
1547
+ @test showstr (undef) == " UndefInitializer()"
1548
+ @test occursin (repr (undef), replstr (undef))
1549
+ @test occursin (" initializer with undefined values" , replstr (undef))
1550
+
1551
+ vec_undefined = Vector (undef, 2 )
1552
+ vec_initialisers = fill (undef, 2 )
1553
+ @test showstr (vec_undefined) == " Any[#undef, #undef]"
1554
+ @test showstr (vec_initialisers) == " UndefInitializer[$undef , $undef ]"
1555
+ @test replstr (vec_undefined) == " 2-element Array{Any,1}:\n #undef\n #undef"
1556
+ @test replstr (vec_initialisers) == " 2-element Array{UndefInitializer,1}:\n $undef \n $undef "
1557
+ end
1558
+
1544
1559
# issue #31065, do not print parentheses for nested dot expressions
1545
1560
@test sprint (Base. show_unquoted, :(foo. x. x)) == " foo.x.x"
1546
1561
You can’t perform that action at this time.
0 commit comments