|
475 | 475 | # the following segfaults with LLVM 3.8 on Windows, ref #15417
|
476 | 476 | @test collect(sub(sub(reshape(1:13^3, 13, 13, 13), 3:7, 6, :), 1:2:5, :, 1:2:5)) ==
|
477 | 477 | cat(3,[68,70,72],[406,408,410],[744,746,748])
|
| 478 | + |
| 479 | + |
| 480 | + |
| 481 | +# tests @sub (and replace_ref_end!) |
| 482 | +X = reshape(1:24,2,3,4) |
| 483 | +Y = 4:-1:1 |
| 484 | + |
| 485 | +@test isa(@sub(X[1:3]), SubArray) |
| 486 | + |
| 487 | + |
| 488 | +@test X[1:end] == @sub X[1:end] |
| 489 | +@test X[1:end-3] == @sub X[1:end-3] |
| 490 | +@test X[1:end,2,2] == @sub X[1:end,2,2] |
| 491 | +@test X[1,1:end-2] == @sub X[1,1:end-2] |
| 492 | +@test X[1,2,1:end-2] == @sub X[1,2,1:end-2] |
| 493 | +@test X[1,2,Y[2:end]] == @sub X[1,2,Y[2:end]] |
| 494 | +@test X[1:end,2,Y[2:end]] == @sub X[1:end,2,Y[2:end]] |
| 495 | + |
| 496 | +u = (1,2:3) |
| 497 | +@test X[u...,2:end] == @sub X[u...,2:end] |
| 498 | +@test X[(1,)...,(2,)...,2:end] == @sub X[(1,)...,(2,)...,2:end] |
| 499 | + |
| 500 | +# test macro hygiene |
| 501 | +let size=(x,y)-> error("should not happen") |
| 502 | + @test X[1:end,2,2] == @sub X[1:end,2,2] |
| 503 | +end |
0 commit comments