Skip to content

Commit c1e073e

Browse files
committed
More tests
1 parent f9545da commit c1e073e

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

test/test_fillarrays.jl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ using TestExtras: @constinferred
4848
@test arg1(permutedims!(b, a, (2, 1))) Eye(2)
4949
@test arg2(permutedims!(b, a, (2, 1))) == permutedims(arg2(a), (2, 1))
5050

51+
a = randn(3, 3) Eye(2)
52+
@test size(a) == (6, 6)
53+
@test a + a == (2 * arg1(a)) Eye(2)
54+
@test 2a == (2 * arg1(a)) Eye(2)
55+
@test a * a == (arg1(a) * arg1(a)) Eye(2)
56+
@test arg2(a[(:) × (:), (:) × (:)]) Eye(2)
57+
@test arg2(view(a, (:) × (:), (:) × (:))) Eye(2)
58+
@test arg2(a[Base.Slice(Base.OneTo(2)) × (:), (:) × (:)]) Eye(2)
59+
@test arg2(view(a, Base.Slice(Base.OneTo(2)) × (:), (:) × (:))) Eye(2)
60+
@test arg2(a[(:) × (:), Base.Slice(Base.OneTo(2)) × (:)]) Eye(2)
61+
@test arg2(view(a, (:) × (:), Base.Slice(Base.OneTo(2)) × (:))) Eye(2)
62+
@test arg2(a[Base.Slice(Base.OneTo(2)) × (:), Base.Slice(Base.OneTo(2)) × (:)]) Eye(2)
63+
@test arg2(view(a, Base.Slice(Base.OneTo(2)) × (:), Base.Slice(Base.OneTo(2)) × (:)))
64+
Eye(2)
65+
@test arg2(adapt(JLArray, a)) Eye(2)
66+
@test arg1(adapt(JLArray, a)) == jl(arg1(a))
67+
@test arg1(adapt(JLArray, a)) isa JLArray
68+
@test arg2(similar(a, (cartesianrange(2 × 3), cartesianrange(2 × 3)))) Eye(3)
69+
@test arg2(similar(typeof(a), (cartesianrange(2 × 3), cartesianrange(2 × 3)))) Eye(3)
70+
@test arg2(similar(a, Float32, (cartesianrange(2 × 3), cartesianrange(2 × 3))))
71+
Eye{Float32}(3)
72+
@test arg2(copy(a)) Eye(2)
73+
@test arg2(copy(a)) == arg2(a)
74+
b = similar(a)
75+
@test arg2(copyto!(b, a)) Eye(2)
76+
@test arg2(copyto!(b, a)) == arg2(a)
77+
@test arg2(permutedims(a, (2, 1))) Eye(2)
78+
@test arg1(permutedims(a, (2, 1))) == permutedims(arg1(a), (2, 1))
79+
b = similar(a)
80+
@test arg2(permutedims!(b, a, (2, 1))) Eye(2)
81+
@test arg1(permutedims!(b, a, (2, 1))) == permutedims(arg1(a), (2, 1))
82+
5183
a = δ(2, 2) randn(3, 3)
5284
@test size(a) == (6, 6)
5385
@test a + a == δ(2, 2) (2 * arg2(a))
@@ -79,6 +111,38 @@ using TestExtras: @constinferred
79111
@test arg1(permutedims!(b, a, (2, 1))) δ(2, 2)
80112
@test arg2(permutedims!(b, a, (2, 1))) == permutedims(arg2(a), (2, 1))
81113

114+
a = randn(3, 3) δ(2, 2)
115+
@test size(a) == (6, 6)
116+
@test a + a == (2 * arg1(a)) δ(2, 2)
117+
@test 2a == (2 * arg1(a)) δ(2, 2)
118+
@test a * a == (arg1(a) * arg1(a)) δ(2, 2)
119+
@test arg2(a[(:) × (:), (:) × (:)]) δ(2, 2)
120+
@test arg2(view(a, (:) × (:), (:) × (:))) δ(2, 2)
121+
@test arg2(a[Base.Slice(Base.OneTo(2)) × (:), (:) × (:)]) δ(2, 2)
122+
@test arg2(view(a, Base.Slice(Base.OneTo(2)) × (:), (:) × (:))) δ(2, 2)
123+
@test arg2(a[(:) × (:), Base.Slice(Base.OneTo(2)) × (:)]) δ(2, 2)
124+
@test arg2(view(a, (:) × (:), Base.Slice(Base.OneTo(2)) × (:))) δ(2, 2)
125+
@test arg2(a[Base.Slice(Base.OneTo(2)) × (:), Base.Slice(Base.OneTo(2)) × (:)]) δ(2, 2)
126+
@test arg2(view(a, Base.Slice(Base.OneTo(2)) × (:), Base.Slice(Base.OneTo(2)) × (:)))
127+
δ(2, 2)
128+
@test arg2(adapt(JLArray, a)) δ(2, 2)
129+
@test arg1(adapt(JLArray, a)) == jl(arg1(a))
130+
@test arg1(adapt(JLArray, a)) isa JLArray
131+
@test arg2(similar(a, (cartesianrange(2 × 3), cartesianrange(2 × 3)))) δ(3, 3)
132+
@test arg2(similar(typeof(a), (cartesianrange(2 × 3), cartesianrange(2 × 3)))) δ(3, 3)
133+
@test arg2(similar(a, Float32, (cartesianrange(2 × 3), cartesianrange(2 × 3))))
134+
δ(Float32, (3, 3))
135+
@test arg2(copy(a)) δ(2, 2)
136+
@test arg2(copy(a)) == arg2(a)
137+
b = similar(a)
138+
@test arg2(copyto!(b, a)) δ(2, 2)
139+
@test arg2(copyto!(b, a)) == arg2(a)
140+
@test arg2(permutedims(a, (2, 1))) δ(2, 2)
141+
@test arg1(permutedims(a, (2, 1))) == permutedims(arg1(a), (2, 1))
142+
b = similar(a)
143+
@test arg2(permutedims!(b, a, (2, 1))) δ(2, 2)
144+
@test arg1(permutedims!(b, a, (2, 1))) == permutedims(arg1(a), (2, 1))
145+
82146
# Views
83147
a = @constinferred(Eye(2) randn(3, 3))
84148
b = @constinferred(view(a, (:) × (2:3), (:) × (2:3)))

0 commit comments

Comments
 (0)