diff --git a/test/runtests.jl b/test/runtests.jl index ea756ba6c60e9a275de78edaea53d2090262195a..06baee1280ca96cafbeb89a0bde7e29826ad4f47 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,46 +1,69 @@ using LabGUI using Observables +using InteractNext using Base.Test ################################################## -print("Tools:\n") a = Observables.Observable(5.0) b = Observables.Observable(5.0) f(x) = 2*x g(x) = x/2 link!(a,b, f, g) -a[] = 3.0 -@test b[] == 6.0 +@testset "Tools" begin + a[] = 3.0 + @test b[] == 6.0 -b[] = 10.6 -@test a[] == 5.3 + b[] = 10.6 + @test a[] == 5.3 -push!(b.listeners, (x) -> b.val += 1.0) -a[] = 1.0 -@test b[] == 2.0 + push!(b.listeners, (x) -> b.val += 1.0) + a[] = 1.0 + @test b[] == 2.0 -c = Observables.Observable(5.0) -d = Observables.Observable(5.0) -link!(c,d, f, g, true) + c = Observables.Observable(5.0) + d = Observables.Observable(5.0) + link!(c,d, f, g, true) -c[] = 3.0 -@test d[] == 6.0 + c[] = 3.0 + @test d[] == 6.0 -d[] = 10.6 -@test c[] == 5.3 - -push!(d.listeners, (x) -> d.val += 1.0) -c[] = 1.0 -@test d[] == 3.0 + d[] = 10.6 + @test c[] == 5.3 + push!(d.listeners, (x) -> d.val += 1.0) + c[] = 1.0 + @test d[] == 3.0 +end ################################################## -print("Gridmaker:\n") grid = make_grid(3,5) -@test typeof(grid) <: WebIO.Node -@test grid.children.length==3 -@test grid.children[1].children.length==5 +@testset "Gridmaker" begin + @test typeof(grid) <: WebIO.Node + @test grid.children.length==3 + @test grid.children[1].children.length==5 +end + + +################################################## +gui = GUI() +wid1, graphic1 = @construct for dummy in 0:100 + Node(:div, dummy) +end + +wid2, graphic2 = @construct for dummybox in checkbox(false) + Node(:div, dummybox) +end + +set!(gui, wid1) +set!(gui, graphic1) +add!(gui, wid2) +gui[:dummy] = 23 +@testset "GUI" begin + @test typeof(gui()) <: WebIO.Node + @test obs(dummy)[] == 23 + @test gui.widgets[:dummy] == dummy +end ##################################################