|
4 | 4 | @test x == 1:10
|
5 | 5 | @test length(x) == 10
|
6 | 6 | @test Base.IndexStyle(x) == Base.IndexLinear()
|
7 |
| - |
| 7 | + |
8 | 8 | x[1] = 0
|
9 | 9 | x[end] = 11
|
10 | 10 | @test x[1] == 0
|
11 | 11 | @test x[end] == 11
|
12 |
| - |
| 12 | + |
13 | 13 | @test copy(x) == x
|
14 | 14 | empty!(x)
|
15 | 15 | @test length(x) == 0
|
16 | 16 | @test copy(x) == x
|
17 |
| - |
| 17 | + |
18 | 18 | @test_throws ArgumentError resize!(x, -1)
|
19 | 19 | resize!(x, 10)
|
20 | 20 | @test length(x) == 10
|
|
24 | 24 | @test length(x) == 15
|
25 | 25 | resize!(x, 5)
|
26 | 26 | @test length(x) == 5
|
27 |
| - |
| 27 | + |
28 | 28 | push!(x, 1)
|
29 | 29 | @test x[end] == 1
|
30 | 30 | empty!(x)
|
31 | 31 | push!(x, 1)
|
32 | 32 | @test x[1] == x[end] == 1
|
33 |
| - |
| 33 | + |
34 | 34 | pushfirst!(x, 2)
|
35 | 35 | @test x[1] == 2
|
36 | 36 | empty!(x)
|
37 | 37 | pushfirst!(x, 2)
|
38 | 38 | @test x[1] == x[end] == 2
|
39 | 39 | pushfirst!(x, 3)
|
40 | 40 | @test x[1] == 3
|
41 |
| - |
| 41 | + |
42 | 42 | @test pop!(x) == 2
|
43 | 43 | @test popfirst!(x) == 3
|
44 | 44 | @test isempty(x)
|
45 | 45 | @test_throws ArgumentError pop!(x)
|
46 | 46 | @test_throws ArgumentError popfirst!(x)
|
47 |
| - |
| 47 | + |
48 | 48 | @test_throws BoundsError insert!(x, 0, 1)
|
49 | 49 | @test_throws BoundsError insert!(x, 2, 1)
|
50 | 50 | insert!(x, 1, 1)
|
51 | 51 | @test x[1] == 1
|
52 | 52 | insert!(x, 1, 2)
|
53 | 53 | @test x[1] == 2
|
54 |
| - |
| 54 | + |
55 | 55 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
56 | 56 | y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
|
57 |
| - |
| 57 | + |
58 | 58 | z = vcat(x, y)
|
59 | 59 | @test length(z) == 20
|
60 | 60 | @test z == 1:20
|
61 |
| - |
| 61 | + |
62 | 62 | z = ChainedVector([[21,22,23], [24,25,26], [27,28,29,30]])
|
63 | 63 | a = vcat(x, y, z)
|
64 | 64 | @test length(a) == 30
|
65 | 65 | @test a == 1:30
|
66 |
| - |
| 66 | + |
67 | 67 | empty!(x)
|
68 | 68 | z = vcat(x, y)
|
69 | 69 | @test z == y
|
70 |
| - |
| 70 | + |
71 | 71 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
72 | 72 | append!(x, y)
|
73 | 73 | @test length(x) == 20
|
74 | 74 | @test x == 1:20
|
75 |
| - |
| 75 | + |
76 | 76 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
77 | 77 | append!(x, collect(11:20))
|
78 | 78 | @test length(x) == 20
|
79 | 79 | @test x == 1:20
|
80 |
| - |
| 80 | + |
81 | 81 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
82 | 82 | append!(x, 11:20)
|
83 | 83 | @test length(x) == 20
|
84 | 84 | @test x == 1:20
|
85 |
| - |
| 85 | + |
86 | 86 | empty!(x)
|
87 | 87 | append!(x, y)
|
88 | 88 | @test x == y
|
89 |
| - |
| 89 | + |
90 | 90 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
91 | 91 | y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
|
92 |
| - |
| 92 | + |
93 | 93 | prepend!(y, x)
|
94 | 94 | @test length(y) == 20
|
95 | 95 | @test y == 1:20
|
96 |
| - |
| 96 | + |
97 | 97 | y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
|
98 | 98 | prepend!(y, collect(1:10))
|
99 | 99 | @test length(y) == 20
|
100 | 100 | @test y == 1:20
|
101 |
| - |
| 101 | + |
102 | 102 | y = ChainedVector([[11,12,13], [14,15,16], [17,18,19,20]])
|
103 | 103 | prepend!(y, 1:10)
|
104 | 104 | @test length(y) == 20
|
105 | 105 | @test y == 1:20
|
106 |
| - |
| 106 | + |
107 | 107 | empty!(y)
|
108 | 108 | prepend!(y, x)
|
109 | 109 | @test y == x
|
110 |
| - |
| 110 | + |
111 | 111 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
112 | 112 | deleteat!(x, 1)
|
113 | 113 | @test x[1] == 2
|
114 | 114 | deleteat!(x, 1:4)
|
115 | 115 | @test x == 6:10
|
116 | 116 | deleteat!(x, [2, 4])
|
117 | 117 | @test x == [6, 8, 10]
|
118 |
| - |
| 118 | + |
119 | 119 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
120 | 120 | deleteat!(x, 1)
|
121 | 121 | deleteat!(x, 1)
|
122 | 122 | deleteat!(x, 1)
|
123 | 123 | @test length(x.arrays) == 2
|
124 |
| - |
| 124 | + |
125 | 125 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
126 | 126 | deleteat!(x, 4)
|
127 | 127 | deleteat!(x, 4)
|
128 | 128 | deleteat!(x, 4)
|
129 | 129 | @test length(x.arrays) == 2
|
130 |
| - |
| 130 | + |
131 | 131 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
132 | 132 | y = 0
|
133 | 133 | for i in x
|
134 | 134 | y += i
|
135 | 135 | end
|
136 | 136 | @test y == 55
|
137 |
| - |
| 137 | + |
138 | 138 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]])
|
139 | 139 | b = [true, false, false, false, false, false, false, false, false, false]
|
140 | 140 | deleteat!(x, b)
|
141 | 141 | @test x[1] == 2
|
142 | 142 | @test length(x) == 9
|
143 |
| - |
| 143 | + |
144 | 144 | deleteat!(x, Int[])
|
145 | 145 | @test length(x) == 9
|
146 |
| - |
| 146 | + |
147 | 147 | #30
|
148 | 148 | x = ChainedVector([Vector{String}(undef, 3), ["hey", "ho"]])
|
149 | 149 | @test !isassigned(x, 1)
|
150 | 150 | @test isassigned(x, 4)
|
151 |
| - |
| 151 | + |
152 | 152 | #36
|
153 | 153 | x = ChainedVector([[1,2,3], [4,5,6], [7,8,9], [10,11,12]])
|
154 | 154 | deleteat!(x, [1, 2, 10, 11])
|
155 | 155 | @test x == [3, 4, 5, 6, 7, 8, 9, 12]
|
156 |
| - |
| 156 | + |
157 | 157 | #38
|
158 | 158 | A = ChainedVector([collect(((i - 1) * 153 + 1):(i * 153 + 1)) for i = 1:16])
|
159 | 159 | inds = collect(1:1883)
|
|
286 | 286 | @test !any(map(x -> iseven(x), x))
|
287 | 287 | @test all(x -> iseven(x), x)
|
288 | 288 | @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) |
295 | 295 | @test count(x -> iseven(x), x) == 0
|
296 | 296 | @test count(map(x -> iseven(x), x)) == 0
|
297 | 297 | @test_throws ArgumentError extrema(x)
|
298 | 298 | @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) |
303 | 303 |
|
304 | 304 | @test_throws ArgumentError findmax(x)
|
305 | 305 | @test_throws ArgumentError findmax(x -> x + 1, x)
|
|
0 commit comments