@@ -447,39 +447,82 @@ same_value_and_type(x::T, y::T) where {T} = (x === y) || (x == y)
447447
448448 @testset " as_eltype()" begin
449449 let A = rand (Float64, 3 , 4 , 5 ), B = @inferred as_eltype (Float32, A)
450- @test B == Float32 .( A)
450+ @test A === @inferred as_eltype ( eltype (A), A)
451451 @test eltype (B) === Float32
452452 @test length (B) === length (A)
453453 @test size (B) === size (A)
454454 @test axes (B) === axes (A)
455455 @test IndexStyle (B) === IndexStyle (A)
456456 @test parent (B) === A
457+ @test B == Float32 .(A)
457458 A[1 ,2 ,3 ] = - 7
458459 @test B[1 ,2 ,3 ] === Float32 (- 7 )
459460 B[1 ,2 ,3 ] = 19
460461 @test A[1 ,2 ,3 ] == 19
462+ C = copyto! (@inferred (similar (B)), B)
463+ @test C == B
464+ C = copyto! (@inferred (similar (B, eltype (B))), B)
465+ @test C == B
466+ C = copyto! (@inferred (similar (B, eltype (B), size (B))), B)
467+ @test C == B
468+ C = copyto! (@inferred (similar (B, eltype (B), axes (B))), B)
469+ @test C == B
461470 end
462471 let A = view (rand (Float64, 3 , 4 , 5 ), :, 2 , :), B = @inferred as_eltype (Float32, A)
463472 @test A === @inferred as_eltype (eltype (A), A)
464- @test B == Float32 .(A)
465- @test eltype (B) === Float32
473+ @test eltype (B) == Float32
466474 @test length (B) === length (A)
467475 @test size (B) === size (A)
468476 @test axes (B) === axes (A)
469477 @test IndexStyle (B) === IndexStyle (A)
470478 @test parent (B) === A
479+ @test B == Float32 .(A)
471480 A[2 ,3 ] = - 7
472481 @test B[2 ,3 ] === Float32 (- 7 )
473482 B[2 ,3 ] = 19
474483 @test A[2 ,3 ] == 19
484+ C = copyto! (@inferred (similar (B)), B)
485+ @test C == B
486+ C = copyto! (@inferred (similar (B, eltype (B))), B)
487+ @test C == B
488+ C = copyto! (@inferred (similar (B, eltype (B), size (B))), B)
489+ @test C == B
490+ C = copyto! (@inferred (similar (B, eltype (B), axes (B))), B)
491+ @test C == B
475492 end
476- let A = 1 : 5
493+ let A = 1 : 5 , B = @inferred as_eltype (Float32, A)
477494 @test A === @inferred as_eltype (eltype (A), A)
478- @test as_eltype (Float32, A) == Float32 .(A)
495+ @test length (B) === length (A)
496+ @test size (B) === size (A)
497+ @test axes (B) === axes (A)
498+ @test IndexStyle (B) === IndexStyle (A)
499+ @test parent (B) === A
500+ @test B == Float32 .(A)
501+ C = copyto! (@inferred (similar (B)), B)
502+ @test C == B
503+ C = copyto! (@inferred (similar (B, eltype (B))), B)
504+ @test C == B
505+ C = copyto! (@inferred (similar (B, eltype (B), size (B))), B)
506+ @test C == B
507+ C = copyto! (@inferred (similar (B, eltype (B), axes (B))), B)
508+ @test C == B
479509 end
480- let A = 2.0 : 3.0 : 11.0
510+ let A = 2.0 : 3.0 : 11.0 , B = @inferred as_eltype (Float32, A)
481511 @test A === @inferred as_eltype (eltype (A), A)
482- @test as_eltype (Float32, A) == Float32 .(A)
512+ @test length (B) === length (A)
513+ @test size (B) === size (A)
514+ @test axes (B) === axes (A)
515+ @test IndexStyle (B) === IndexStyle (A)
516+ @test parent (B) === A
517+ @test B == Float32 .(A)
518+ C = copyto! (@inferred (similar (B)), B)
519+ @test C == B
520+ C = copyto! (@inferred (similar (B, eltype (B))), B)
521+ @test C == B
522+ C = copyto! (@inferred (similar (B, eltype (B), size (B))), B)
523+ @test C == B
524+ C = copyto! (@inferred (similar (B, eltype (B), axes (B))), B)
525+ @test C == B
483526 end
484527 end
485528
0 commit comments