Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Mar 2, 2018
1 parent 88f6bda commit a107a2d
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
using Traceur
using Traceur: warnings
using Base.Test

# write your own tests here
@test 1 == 2
warns_for(ws, x) = any(w -> contains(w.message, x), ws)
warns_for(ws, x, xs...) = warns_for(ws, x) && warns_for(ws, xs...)

y = 1

@testset "Traceur" begin

naive_relu(x) = x < 0 ? 0 : x

ws = warnings(() -> naive_relu(1))
@test isempty(ws)

ws = warnings(() -> naive_relu(1.0))
@test warns_for(ws, "returns")

function naive_sum(xs)
s = 0
for x in xs
s += x
end
return s
end

ws = warnings(() -> naive_sum(1))
@test isempty(ws)

ws = warnings(() -> naive_sum(1.0))
@test warns_for(ws, "assigned", "dispatch", "returns")

f(x) = x+y

ws = warnings(() -> f(1))
@test warns_for(ws, "global", "dispatch", "returns")

end

0 comments on commit a107a2d

Please sign in to comment.