-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |