Skip to content

Commit

Permalink
Add tests for bounds check elimination.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakejohnson committed Dec 24, 2015
1 parent a6f6519 commit 2793ca7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
61 changes: 61 additions & 0 deletions test/boundscheck.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

module TestBoundsCheck

using Base.Test

# test for boundscheck block eliminated at same level
function A1()
r = 0
@boundscheck r += 1
return r
end

function A1_inbounds()
r = 0
@inbounds begin
@boundscheck r += 1
end
return r
end

@test A1() == 1
@test A1_inbounds() == 0

# test for boundscheck block eliminated one layer deep
function A2()
r = A1()+1
return r
end

function A2_inbounds()
@inbounds r = A1()+1
return r
end

@test A2() == 2
@test A2_inbounds() == 1

# test boundscheck NOT eliminated two layers deep

function A3()
r = A2()+1
return r
end

function A3_inbounds()
@inbounds r = A2()+1
return r
end

@test A3() == 3
@test A3_inbounds() == 3

@inline B() = A1() + 1
function A3_inbounds2()
@inbounds r = B()+1
return r
end

# @test A3_inbounds2() == 3

end
3 changes: 2 additions & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function choosetests(choices = [])
"nullable", "meta", "profile", "libgit2", "docs", "markdown",
"base64", "serialize", "functors", "misc", "threads",
"enums", "cmdlineargs", "i18n", "workspace", "libdl", "int",
"checked", "intset", "floatfuncs", "compile", "parallel", "inline"
"checked", "intset", "floatfuncs", "compile", "parallel", "inline",
"boundscheck"
]

if Base.USE_GPL_LIBS
Expand Down

0 comments on commit 2793ca7

Please sign in to comment.