Skip to content
Snippets Groups Projects
Select Git revision
  • tanklabsim
  • julia1
  • master default protected
3 results

runtests.jl

Blame
  • runtests.jl 1.92 KiB
    using LabGUI
    using Observables
    using InteractNext
    using Base.Test
    
    
    @testset "Tools" begin
        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
    
        b[] = 10.6
        @test a[] == 5.3
    
        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[] = 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
    end
    
    
    @testset "Gridmaker" begin
        grid = make_grid(3,5)
        @test typeof(grid) <: WebIO.Node
        @test grid.children.length==3
        @test grid.children[1].children.length==5
    end
    
    
    @testset "GUI" begin
        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
        @test typeof(gui()) <: WebIO.Node
        @test observe(dummy)[] == 23
        @test gui.widgets[:dummy] == dummy
    end
    
    
    @testset "SVG" begin
        #Circle tests should suffice
        circ = svg_circle(0,50,100)
        @test typeof(circ) <: WebIO.Node
        @test typeof(circ.instanceof) <: WebIO.DOM
        @test circ.props[:attributes]["cx"] == "0"
        @test circ.props[:attributes]["cy"] == "50"
        @test circ.props[:style][:fill] == "rgb(0, 0, 0)"
    end
    
    
    @testset "Dependencies" begin
        #testing vue
        vuenode = Vue.vue(Node(:div))
        @test typeof(vuenode)<:WebIO.Scope
        @test typeof(vuenode.dom)<:WebIO.Node
        @test typeof(vuenode.id)==String
        #testing interactnext
        ui = @manipulate for dummy in 1:100
            WebIO.render(dummy)
        end
        @test typeof(ui) <: WebIO.Node{WebIO.DOM}
        observe(dummy)[] = 80
        @test observe(dummy)[] == 80
    end