Skip to content

Commit

Permalink
Add new correctness tests for arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Apr 30, 2012
1 parent 595204b commit 4a4cdb8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ a = reshape(b, (2, 2, 2, 2, 2))
@assert a[2,1,2,2,1] == b[14]
@assert a[2,2,2,2,2] == b[end]

sz = (5,8,7)
A = reshape(1:prod(sz),sz...)
tmp = A[1:3,2,2:4]
@assert all(tmp == cat(3,46:48,86:88,126:128))
tmp = A[:,7:-3:1,5]
@assert all(tmp == [191 176 161; 192 177 162; 193 178 163; 194 179 164; 195 180 165])
tmp = A[:,3:9]
@assert all(tmp == reshape(11:45,5,7))
rng = (2,2:3,2:2:5)
tmp = zeros(Int,map(max,rng)...)
tmp[rng...] = A[rng...]
@assert all(tmp == cat(3,zeros(Int,2,3),[0 0 0; 0 47 52],zeros(Int,2,3),[0 0 0; 0 127 132]))

## arrays as dequeues
l = {1,2,3}
push(l,8)
Expand Down

0 comments on commit 4a4cdb8

Please sign in to comment.