Skip to content

Commit 2caab61

Browse files
authoredAug 20, 2021
Generalize exception type (#60)
In preparation for JuliaLang/julia#41885
1 parent 4852289 commit 2caab61

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed
 

‎test/chainedvector.jl

+39-39
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
@test x == 1:10
55
@test length(x) == 10
66
@test Base.IndexStyle(x) == Base.IndexLinear()
7-
7+
88
x[1] = 0
99
x[end] = 11
1010
@test x[1] == 0
1111
@test x[end] == 11
12-
12+
1313
@test copy(x) == x
1414
empty!(x)
1515
@test length(x) == 0
1616
@test copy(x) == x
17-
17+
1818
@test_throws ArgumentError resize!(x, -1)
1919
resize!(x, 10)
2020
@test length(x) == 10
@@ -24,136 +24,136 @@
2424
@test length(x) == 15
2525
resize!(x, 5)
2626
@test length(x) == 5
27-
27+
2828
push!(x, 1)
2929
@test x[end] == 1
3030
empty!(x)
3131
push!(x, 1)
3232
@test x[1] == x[end] == 1
33-
33+
3434
pushfirst!(x, 2)
3535
@test x[1] == 2
3636
empty!(x)
3737
pushfirst!(x, 2)
3838
@test x[1] == x[end] == 2
3939
pushfirst!(x, 3)
4040
@test x[1] == 3
41-
41+
4242
@test pop!(x) == 2
4343
@test popfirst!(x) == 3
4444
@test isempty(x)
4545
@test_throws ArgumentError pop!(x)
4646
@test_throws ArgumentError popfirst!(x)
47-
47+
4848
@test_throws BoundsError insert!(x, 0, 1)
4949
@test_throws BoundsError insert!(x, 2, 1)
5050
insert!(x, 1, 1)
5151
@test x[1] == 1
5252
insert!(x, 1, 2)
5353
@test x[1] == 2
54-
54+
5555
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
5656
y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
57-
57+
5858
z = vcat(x, y)
5959
@test length(z) == 20
6060
@test z == 1:20
61-
61+
6262
z = ChainedVector([[21,22,23], [24,25,26], [27,28,29,30]])
6363
a = vcat(x, y, z)
6464
@test length(a) == 30
6565
@test a == 1:30
66-
66+
6767
empty!(x)
6868
z = vcat(x, y)
6969
@test z == y
70-
70+
7171
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
7272
append!(x, y)
7373
@test length(x) == 20
7474
@test x == 1:20
75-
75+
7676
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
7777
append!(x, collect(11:20))
7878
@test length(x) == 20
7979
@test x == 1:20
80-
80+
8181
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
8282
append!(x, 11:20)
8383
@test length(x) == 20
8484
@test x == 1:20
85-
85+
8686
empty!(x)
8787
append!(x, y)
8888
@test x == y
89-
89+
9090
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
9191
y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
92-
92+
9393
prepend!(y, x)
9494
@test length(y) == 20
9595
@test y == 1:20
96-
96+
9797
y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
9898
prepend!(y, collect(1:10))
9999
@test length(y) == 20
100100
@test y == 1:20
101-
101+
102102
y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
103103
prepend!(y, 1:10)
104104
@test length(y) == 20
105105
@test y == 1:20
106-
106+
107107
empty!(y)
108108
prepend!(y, x)
109109
@test y == x
110-
110+
111111
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
112112
deleteat!(x, 1)
113113
@test x[1] == 2
114114
deleteat!(x, 1:4)
115115
@test x == 6:10
116116
deleteat!(x, [2, 4])
117117
@test x == [6, 8, 10]
118-
118+
119119
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
120120
deleteat!(x, 1)
121121
deleteat!(x, 1)
122122
deleteat!(x, 1)
123123
@test length(x.arrays) == 2
124-
124+
125125
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
126126
deleteat!(x, 4)
127127
deleteat!(x, 4)
128128
deleteat!(x, 4)
129129
@test length(x.arrays) == 2
130-
130+
131131
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
132132
y = 0
133133
for i in x
134134
y += i
135135
end
136136
@test y == 55
137-
137+
138138
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
139139
b = [true, false, false, false, false, false, false, false, false, false]
140140
deleteat!(x, b)
141141
@test x[1] == 2
142142
@test length(x) == 9
143-
143+
144144
deleteat!(x, Int[])
145145
@test length(x) == 9
146-
146+
147147
#30
148148
x = ChainedVector([Vector{String}(undef, 3), ["hey", "ho"]])
149149
@test !isassigned(x, 1)
150150
@test isassigned(x, 4)
151-
151+
152152
#36
153153
x = ChainedVector([[1,2,3], [4,5,6], [7,8,9], [10,11,12]])
154154
deleteat!(x, [1, 2, 10, 11])
155155
@test x == [3, 4, 5, 6, 7, 8, 9, 12]
156-
156+
157157
#38
158158
A = ChainedVector([collect(((i - 1) * 153 + 1):(i * 153 + 1)) for i = 1:16])
159159
inds = collect(1:1883)
@@ -286,20 +286,20 @@
286286
@test !any(map(x -> iseven(x), x))
287287
@test all(x -> iseven(x), x)
288288
@test all(map(x -> iseven(x), x))
289-
@test_throws ArgumentError reduce(+, x)
290-
@test_throws ArgumentError foldl(+, x)
291-
@test_throws ArgumentError foldr(+, x)
292-
@test_throws ArgumentError mapreduce(x -> x + 1, +, x)
293-
@test_throws ArgumentError mapfoldl(x -> x + 1, +, x)
294-
@test_throws ArgumentError mapfoldr(x -> x + 1, +, x)
289+
@test_throws Union{ArgumentError,MethodError} reduce(+, x)
290+
@test_throws Union{ArgumentError,MethodError} foldl(+, x)
291+
@test_throws Union{ArgumentError,MethodError} foldr(+, x)
292+
@test_throws Union{ArgumentError,MethodError} mapreduce(x -> x + 1, +, x)
293+
@test_throws Union{ArgumentError,MethodError} mapfoldl(x -> x + 1, +, x)
294+
@test_throws Union{ArgumentError,MethodError} mapfoldr(x -> x + 1, +, x)
295295
@test count(x -> iseven(x), x) == 0
296296
@test count(map(x -> iseven(x), x)) == 0
297297
@test_throws ArgumentError extrema(x)
298298
@test_throws ArgumentError extrema(x -> x + 1, x)
299-
@test_throws ArgumentError minimum(x)
300-
@test_throws ArgumentError minimum(x -> x + 1, x)
301-
@test_throws ArgumentError maximum(x)
302-
@test_throws ArgumentError maximum(x -> x + 1, x)
299+
@test_throws Union{ArgumentError,MethodError} minimum(x)
300+
@test_throws Union{ArgumentError,MethodError} minimum(x -> x + 1, x)
301+
@test_throws Union{ArgumentError,MethodError} maximum(x)
302+
@test_throws Union{ArgumentError,MethodError} maximum(x -> x + 1, x)
303303

304304
@test_throws ArgumentError findmax(x)
305305
@test_throws ArgumentError findmax(x -> x + 1, x)

0 commit comments

Comments
 (0)
Please sign in to comment.