Skip to content

Commit

Permalink
Test callbacks from a precompiled module
Browse files Browse the repository at this point in the history
Issue #34
  • Loading branch information
barche committed Feb 10, 2017
1 parent 1db0da0 commit e685287
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/functions.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Base.Test
using QML

include(joinpath("include","functions_module.jl"))
using TestModuleFunction

# Test calling Julia functions

call_results1 = []
Expand Down Expand Up @@ -31,7 +34,8 @@ function test_qvariant_map(m::QVariantMap)
nothing
end

@qmlfunction julia_callback1 julia_callback2 return_callback check_return_callback test_qvariant_map
set_state2 = TestModuleFunction.set_state2
@qmlfunction julia_callback1 julia_callback2 return_callback check_return_callback test_qvariant_map set_state1 set_state2
@qmlapp joinpath(dirname(@__FILE__), "qml", "functions.qml")
exec()

Expand All @@ -48,3 +52,5 @@ stringresult = VERSION < v"0.5-dev" ? ASCIIString : String
@test typeof(call_results2[2]) == Int32
@test typeof(call_results2[3]) == stringresult
@test call_results2 == [3., 6, "ab"]

@test get_state() == 2
27 changes: 27 additions & 0 deletions test/include/functions_module.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
__precompile__()

module TestModuleFunction

export set_state1, get_state

state = 0

function set_state1()
global state
state = 1
return
end

function set_state2()
global state
if(state == 1)
state = 2
end
return
end

function get_state()
return state
end

end
3 changes: 3 additions & 0 deletions test/qml/functions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Item {

Julia.test_qvariant_map({"somekey": "somevalue"})

Julia.set_state1()
Julia.set_state2()

Qt.quit()
}
}
Expand Down

0 comments on commit e685287

Please sign in to comment.