Mercurial > repos > public > sbplib_julia
comparison LazyTensors/test/runtests.jl @ 201:6b7019f2cd41 boundary_conditions
Add/fix test checking that no size assertion is performed when lazy operations and operations on lazy arrays are decorated using @inbounds
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Sun, 23 Jun 2019 21:27:03 +0200 |
| parents | c19bfad0e836 |
| children | 19e579a5031f |
comparison
equal
deleted
inserted
replaced
| 200:c19bfad0e836 | 201:6b7019f2cd41 |
|---|---|
| 80 @test (v1 -̃ v2)[i] == r_sub[i] | 80 @test (v1 -̃ v2)[i] == r_sub[i] |
| 81 @test (v1 *̃ v2)[i] == r_times[i] | 81 @test (v1 *̃ v2)[i] == r_times[i] |
| 82 @test (v1 /̃ v2)[i] == r_div[i] | 82 @test (v1 /̃ v2)[i] == r_div[i] |
| 83 end | 83 end |
| 84 @test_throws BoundsError (v1 +̃ v2)[4] | 84 @test_throws BoundsError (v1 +̃ v2)[4] |
| 85 v2 = [1., 2, 3, 4] | |
| 86 # Test that size of arrays is asserted when not specified inbounds | |
| 87 @test_throws AssertionError v1 +̃ v2 | |
| 88 # Test that no error checking is performed when specified inbounds | |
| 89 res = (v1,v2) -> (@inbounds (v1 +̃ v2)[1] == 2) | |
| 90 @test res(v1,v2) | |
| 85 | 91 |
| 86 # Test operations on LazyArray | 92 # Test operations on LazyArray |
| 87 v1 = DummyArray([1, 2.3, 4]) | 93 v1 = DummyArray([1, 2.3, 4]) |
| 94 v2 = [1., 2, 3] | |
| 88 @test isa(v1 + v2, LazyArray) | 95 @test isa(v1 + v2, LazyArray) |
| 89 @test isa(v2 + v1, LazyArray) | 96 @test isa(v2 + v1, LazyArray) |
| 90 @test isa(v1 - v2, LazyArray) | 97 @test isa(v1 - v2, LazyArray) |
| 91 @test isa(v2 - v1, LazyArray) | 98 @test isa(v2 - v1, LazyArray) |
| 92 @test isa(v1 * v2, LazyArray) | 99 @test isa(v1 * v2, LazyArray) |
| 102 @test_throws BoundsError (v1 + v2)[4] | 109 @test_throws BoundsError (v1 + v2)[4] |
| 103 v2 = [1., 2, 3, 4] | 110 v2 = [1., 2, 3, 4] |
| 104 # Test that size of arrays is asserted when not specified inbounds | 111 # Test that size of arrays is asserted when not specified inbounds |
| 105 @test_throws AssertionError v1 + v2 | 112 @test_throws AssertionError v1 + v2 |
| 106 # Test that no error checking is performed when specified inbounds | 113 # Test that no error checking is performed when specified inbounds |
| 107 @test_broken @inbounds((v1 + v2)[1] == 2) | 114 res = (v1,v2) -> (@inbounds (v1 + v2)[1] == 2) |
| 115 @test res(v1,v2) | |
| 108 end | 116 end |
