@@ -392,4 +392,54 @@ And data, a 0-dimensional $(Array{Int,0}):
392
392
x = DenseAxisArray (1 : 6 , S)
393
393
@test size (x) == (6 ,)
394
394
end
395
+
396
+ @testset " DenseAxisArray_show_nd" begin
397
+ S = zeros (Int, 2 , 2 , 3 , 3 , 3 )
398
+ for i in 1 : length (S)
399
+ S[i] = i
400
+ end
401
+ x = DenseAxisArray (S, 1 : 2 , 1 : 2 , 1 : 3 , 1 : 3 , 1 : 3 )
402
+ str = sprint ((io, x) -> Base. show_nd (io, x, Base. print_matrix, true ), x)
403
+ @test occursin (" [:, :, 1, 2, 3] =\n 85 87\n 86 88\n " , str)
404
+ str_limit = sprint (x) do io, x
405
+ return Base. show_nd (
406
+ IOContext (io, :limit => true ),
407
+ x,
408
+ Base. print_matrix,
409
+ true ,
410
+ )
411
+ end
412
+ @test occursin (" [:, :, 1, 2, 3] =\n 85 87\n 86 88\n " , str_limit)
413
+ end
414
+
415
+ @testset " DenseAxisArray_show_nd_limit" begin
416
+ S = zeros (Int, 2 , 2 , 3 , 3 , 20 )
417
+ for i in 1 : length (S)
418
+ S[i] = i
419
+ end
420
+ x = DenseAxisArray (S, 1 : 2 , 1 : 2 , 1 : 3 , 1 : 3 , 1 : 20 )
421
+ str = sprint ((io, x) -> Base. show_nd (io, x, Base. print_matrix, true ), x)
422
+ @test occursin (" [:, :, 1, 1, 3]" , str)
423
+ @test occursin (" [:, :, 1, 1, 4]" , str)
424
+ @test occursin (" [:, :, 1, 1, 17]" , str)
425
+ @test occursin (" [:, :, 1, 1, 18]" , str)
426
+ str_limit = sprint (x) do io, x
427
+ return Base. show_nd (
428
+ IOContext (io, :limit => true ),
429
+ x,
430
+ Base. print_matrix,
431
+ true ,
432
+ )
433
+ end
434
+ @test occursin (" [:, :, 1, 1, 3]" , str_limit)
435
+ @test ! occursin (" [:, :, 1, 1, 4]" , str_limit)
436
+ @test ! occursin (" [:, :, 1, 1, 17]" , str_limit)
437
+ @test occursin (" [:, :, 1, 1, 18]" , str_limit)
438
+ end
439
+
440
+ @testset " DenseAxisArray_show_nd_empty" begin
441
+ x = DenseAxisArray (Int[], 1 : 0 )
442
+ str = sprint ((io, x) -> Base. show_nd (io, x, Base. print_matrix, true ), x)
443
+ @test isempty (str)
444
+ end
395
445
end
0 commit comments