Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Aug 10, 2017
1 parent df348fa commit 07e9c43
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using DataFlow, DataFlow.Fuzz
using MacroTools, Lazy, Base.Test

import DataFlow: graphm, syntax, cse, dvertex, constant, prewalk
import DataFlow: graphm, syntax, dvertex, constant, prewalk

@testset "DataFlow" begin

Expand Down Expand Up @@ -32,29 +32,21 @@ end
σ( Wxy*x + Why*hidden + by )
end

@test @capture syntax(recurrent.output) begin
h_Symbol = σ( Wxh*xs + Whh*h_Symbol + bh )
@test @capture syntax(recurrent) begin
h_Symbol = σ( Wxh*xs_ + Whh*h_Symbol + bh )
σ( Wxy*x + Why*h_Symbol + by )
end

@flow function var(xs)
mean = sum(xs)/length(xs)
meansqr = sumabs2(xs)/length(xs)
mean = sum(xs_)/length(xs_)
meansqr = sumabs2(xs_)/length(xs_)
meansqr - mean^2
end

@test @capture syntax(var.output) begin
sumabs2(xs)/length(xs) - (sum(xs) / length(xs)) ^ 2
@test @capture syntax(var) begin
sumabs2(xs_)/length(xs_) - (sum(xs_) / length(xs_)) ^ 2
end

@test contains(sprint(show, var),
string(:(sumabs2(xs)/length(xs) - (sum(xs) / length(xs)) ^ 2)))

@test cse(var.output) == convert(IVertex, @flow begin
n = length(xs)
sumabs2(xs)/n - (sum(xs) / n) ^ 2
end)

let x = :(2+2)
@test @flow(foo($x)) == dvertex(:foo, constant(x))
end
Expand Down

0 comments on commit 07e9c43

Please sign in to comment.