@@ -6,5 +6,53 @@ using Aqua: Aqua
6
6
@testset " Code quality (Aqua.jl)" begin
7
7
Aqua. test_all (ZeroDimensionalArrays)
8
8
end
9
- # Write your tests here.
9
+
10
+ @testset " all array types joined" begin
11
+ for Arr ∈ (
12
+ ZeroDimensionalArrayImmutable,
13
+ ZeroDimensionalArrayMutable,
14
+ ZeroDimensionalArrayMutableConstField,
15
+ )
16
+ @test isstructtype (Arr)
17
+ @test Arr <: AbstractArray{<:Any, 0}
18
+ @test (@inferred Arr (fill (0.3 ))) isa Arr{Float64}
19
+ @test (@inferred convert (Arr, fill (0.3 ))) isa Arr{Float64}
20
+ @test (@inferred Arr {Float32} (fill (0.3 ))) isa Arr{Float32}
21
+ @test (@inferred convert (Arr{Float32}, fill (0.3 ))) isa Arr{Float32}
22
+ @test () === @inferred propertynames (Arr (fill (0.3 )))
23
+ @test only (fill (0.3 )) === @inferred only (Arr (fill (0.3 )))
24
+ @test fill (0.3 )[] === @inferred Arr (fill (0.3 ))[]
25
+ @test fill (0.3 )[1 ] === @inferred Arr (fill (0.3 ))[1 ]
26
+ @test @inferred isassigned (Arr (fill (0.3 )))
27
+ @test @inferred isassigned (Arr (fill (0.3 )), 1 )
28
+ @test ! (isassigned (Arr (fill (0.3 )), 2 ))
29
+ @test (@inferred similar (Arr (fill (0.3 )), Float32)) isa ZeroDimensionalArrayMutable{Float32}
30
+ @test fill (0.3 ) == Arr (fill (0.3 ))
31
+ @test Arr (fill (0.3 )) == Arr (fill (0.3 ))
32
+ @test all (@inferred Arr (fill (0.3 )) .== Arr (fill (0.3 )))
33
+ @test (@inferred Arr (fill (0.3 )) .+ [10 , 20 ]) isa AbstractVector
34
+ end
35
+ end
36
+
37
+ @testset " each array type on its own" begin
38
+ @testset " `ZeroDimensionalArrayImmutable`" begin
39
+ @test @isdefined ZeroDimensionalArrayImmutable
40
+ @test ! ismutabletype (ZeroDimensionalArrayImmutable)
41
+ @test isbitstype (ZeroDimensionalArrayImmutable{Float64})
42
+ end
43
+ @testset " `ZeroDimensionalArrayMutable`" begin
44
+ @test @isdefined ZeroDimensionalArrayMutable
45
+ @test ismutabletype (ZeroDimensionalArrayMutable)
46
+ @test (@inferred ZeroDimensionalArrayMutable {Float32} (undef)) isa ZeroDimensionalArrayMutable{Float32}
47
+ @test (@inferred ZeroDimensionalArrayMutable {Float32} (undef, ())) isa ZeroDimensionalArrayMutable{Float32}
48
+ @test let a = ZeroDimensionalArrayMutable (fill (0.3 ))
49
+ a[] = 0.7
50
+ only (a) === 0.7
51
+ end
52
+ end
53
+ @testset " `ZeroDimensionalArrayMutableConstField`" begin
54
+ @test @isdefined ZeroDimensionalArrayMutableConstField
55
+ @test ismutabletype (ZeroDimensionalArrayMutableConstField)
56
+ end
57
+ end
10
58
end
0 commit comments