#include "test_helper.h" #include <qmlbind.h> TEST_CASE("engine") { auto engine = qmlbind_engine_new(); SECTION("eval") { SECTION("evaluates javascript") { auto result = qmlbind_engine_eval(engine, "1 + 2 + 3", "", 1); REQUIRE(qmlbind_value_get_number(result) == 6); qmlbind_value_release(result); } } SECTION("get_global_object") { SECTION("returns global object") { auto global = qmlbind_engine_get_global_object(engine); auto arrayClass = qmlbind_value_get_property(global, "Array"); REQUIRE(qmlbind_value_is_function(arrayClass)); qmlbind_value_release(arrayClass); qmlbind_value_release(global); } }
static VALUE engine_initialize(VALUE self) { engine_t *data; TypedData_Get_Struct(self, engine_t, &data_type, data); data->engine = qmlbind_engine_new(); return self; }