text:
/* This is a managed file. Do not delete this comment. */

#include <include/test.h>

void test_rw_target_tc_primitive(
    test_rw_target this)
{
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 10);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_reference(
    test_rw_target this)
{
    test_s_target_reference *o = corto_create(root_o, "o", test_s_target_reference_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_reference_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "actual") == 0);
    test_assert(corto_rw_set_ref(&rw, corto_lang_o) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertref(o->m->actual, corto_lang_o);
    test_assertref(o->m->target, NULL);
    test_assertref(o->m->objective, NULL);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_collection(
    test_rw_target this)
{
    test_s_target_collection *o = corto_create(root_o, "o", test_s_target_collection_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_collection_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "actual") == 0);
    test_assert(corto_rw_push(&rw, true) == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_set_int(&rw, 20) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_set_int(&rw, 30) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assert(o->m->actual != NULL);
    test_assertint(ut_ll_count(o->m->actual), 3);
    test_assertint((uintptr_t)ut_ll_get(o->m->actual, 0), 10);
    test_assertint((uintptr_t)ut_ll_get(o->m->actual, 1), 20);
    test_assertint((uintptr_t)ut_ll_get(o->m->actual, 2), 30);
    test_assert(o->m->target != NULL);
    test_assertint(ut_ll_count(o->m->target), 0);
    test_assert(o->m->objective != NULL);
    test_assertint(ut_ll_count(o->m->objective), 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_composite(
    test_rw_target this)
{
    test_s_target_composite *o = corto_create(root_o, "o", test_s_target_composite_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_composite_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "actual") == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_set_int(&rw, 20) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual.x, 10);
    test_assertint(o->m->actual.y, 20);
    test_assertint(o->m->target.x, 0);
    test_assertint(o->m->target.y, 0);
    test_assertint(o->m->objective.x, 0);
    test_assertint(o->m->objective.y, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_objective_app_from_app(
    test_rw_target this)
{
    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set objective from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 10);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_objective_app_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set objective from local */
    corto_set_source(local);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_objective_app_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set objective from remote (will fail) */
    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 0);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_objective_local_from_app(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    /* Set objective from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_objective_local_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_objective_local_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    /* Set objective from remote */
    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 0);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_objective_remote_from_app(
    test_rw_target this)
{
    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    /* Set objective from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 0);

    corto_set_source(remote);
    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_objective_remote_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    /* Set objective from app */
    corto_set_source(local);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 0);

    corto_set_source(remote);
    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(local) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_objective_remote_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 10);

    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_actual_app_from_app(
    test_rw_target this)
{
    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set actual from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 10);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_actual_app_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set actual from local */
    corto_set_source(local);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_actual_app_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set actual from remote (will fail) */
    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 0);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_actual_local_from_app(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    /* Set actual from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_actual_local_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_actual_local_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    /* Set actual from remote */
    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 0);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_actual_remote_from_app(
    test_rw_target this)
{
    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    /* Set actual from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 0);

    corto_set_source(remote);
    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_actual_remote_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    /* Set actual from app */
    corto_set_source(local);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 0);

    corto_set_source(remote);
    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(local) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_actual_remote_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->actual, 10);

    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_target_app_from_app(
    test_rw_target this)
{
    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set target from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_target_app_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set target from local */
    corto_set_source(local);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_target_app_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from app source */
    corto_set_source(NULL);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Set target from remote (will fail) */
    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_target_local_from_app(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    /* Set target from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_target_local_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
}

void test_rw_target_tc_target_local_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from local source */
    corto_set_source(local);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == local);

    /* Set target from remote */
    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 10);

    /* Reset source */
    corto_set_source(NULL);

    test_assert(corto_delete(o) == 0);
    test_assert(corto_delete(local) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_target_remote_from_app(
    test_rw_target this)
{
    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    /* Set target from app */
    corto_set_source(NULL);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 10);

    corto_set_source(remote);
    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_target_remote_from_local(
    test_rw_target this)
{
    /* Create mount that serves up local objects */
    corto_mount local = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(local != NULL);
    local->ownership = CORTO_LOCAL_SOURCE;
    test_assert(corto_define(local) == 0);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    /* Set target from app */
    corto_set_source(local);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 10);

    corto_set_source(remote);
    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(local) == 0);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_target_remote_from_remote(
    test_rw_target this)
{
    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    /* Create object from remote source */
    corto_set_source(remote);
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == remote);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) != 0);
    test_assert(ut_catch() != 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->objective, 0);
    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);

    test_assert(corto_delete(o) == 0);

    /* Reset source */
    corto_set_source(NULL);
    test_assert(corto_delete(remote) == 0);
}

void test_rw_target_tc_actual_after_push(
    test_rw_target this)
{
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 10);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_objective_after_push(
    test_rw_target this)
{
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "objective") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 10);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_target_after_push(
    test_rw_target this)
{
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "target") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);
    corto_set_source(NULL);

    test_assertint(o->m->actual, 0);
    test_assertint(o->m->target, 10);
    test_assertint(o->m->objective, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_actual_nested(
    test_rw_target this)
{
    test_s_target_composite *o = corto_create(root_o, "o", test_s_target_composite_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_composite_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.actual.x") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_field(&rw, "m.actual.y") == 0);
    test_assert(corto_rw_set_int(&rw, 20) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual.x, 10);
    test_assertint(o->m->actual.y, 20);
    test_assertint(o->m->target.x, 0);
    test_assertint(o->m->target.y, 0);
    test_assertint(o->m->objective.x, 0);
    test_assertint(o->m->objective.y, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_objective_nested(
    test_rw_target this)
{
    test_s_target_composite *o = corto_create(root_o, "o", test_s_target_composite_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_composite_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.objective.x") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_field(&rw, "m.objective.y") == 0);
    test_assert(corto_rw_set_int(&rw, 20) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual.x, 0);
    test_assertint(o->m->actual.y, 0);
    test_assertint(o->m->target.x, 0);
    test_assertint(o->m->target.y, 0);
    test_assertint(o->m->objective.x, 10);
    test_assertint(o->m->objective.y, 20);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_target_nested(
    test_rw_target this)
{
    test_s_target_composite *o = corto_create(root_o, "o", test_s_target_composite_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    /* Create mount that serves up remote objects */
    corto_mount remote = corto_declare(NULL, NULL, corto_mount_o);
    test_assert(remote != NULL);
    remote->ownership = CORTO_REMOTE_SOURCE;
    test_assert(corto_define(remote) == 0);

    corto_set_source(remote);
    corto_rw rw = corto_rw_init(o, test_s_target_composite_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "m.target.x") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_field(&rw, "m.target.y") == 0);
    test_assert(corto_rw_set_int(&rw, 20) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);
    corto_set_source(NULL);

    test_assertint(o->m->actual.x, 0);
    test_assertint(o->m->actual.y, 0);
    test_assertint(o->m->target.x, 10);
    test_assertint(o->m->target.y, 20);
    test_assertint(o->m->objective.x, 0);
    test_assertint(o->m->objective.y, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_actual_no_field_expr(
    test_rw_target this)
{
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 10);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 0);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_set_actual_and_objective(
    test_rw_target this)
{
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_field(&rw, "actual") == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_field(&rw, "objective") == 0);
    test_assert(corto_rw_set_int(&rw, 20) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 10);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 20);

    test_assert(corto_delete(o) == 0);
}

void test_rw_target_tc_set_actual_no_field_expr_and_objective(
    test_rw_target this)
{
    test_s_target_primitive *o = corto_create(root_o, "o", test_s_target_primitive_o);
    test_assert(o != NULL);
    test_assert(corto_check_attr(o, CORTO_ATTR_PERSISTENT));
    test_assert(corto_sourceof(o) == NULL);

    corto_rw rw = corto_rw_init(o, test_s_target_primitive_o);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_next(&rw) == 0);
    test_assert(corto_rw_push(&rw, false) == 0);
    test_assert(corto_rw_set_int(&rw, 10) == 0);
    test_assert(corto_rw_field(&rw, "objective") == 0);
    test_assert(corto_rw_set_int(&rw, 20) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    test_assert(corto_rw_pop(&rw) == 0);
    corto_rw_deinit(&rw);

    test_assertint(o->m->actual, 10);
    test_assertint(o->m->target, 0);
    test_assertint(o->m->objective, 20);

    test_assert(corto_delete(o) == 0);
}


text:
using Akka.Actor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Akka.DI.Core
{
    /// <summary>
    /// ExtensionIdProvider for the DIExt. Used to Create an instance of DIExt which implements IExtension
    /// </summary>
    public class DIExtension : ExtensionIdProvider<DIExt>
    {
        public static DIExtension DIExtensionProvider = new DIExtension();

        public override DIExt CreateExtension(ExtendedActorSystem system)
        {
            var extension = new DIExt();
            return extension;
        }

    }
}

redpajama_set_name: RedPajamaGithub


text:
/* global L, emp, leafLet */

leafLet.internalPrivateClass.EmpKMLIcon = function(){
    var publicInterface = {
        createIcon: function (oldIcon) {
            var oThis = this;
            var img = this._createIcon('icon', oldIcon);
            this.options.oIconImag = img;

            img.onload = function () {
                //this.width = this.naturalWidth;
                //this.height = this.naturalHeight;
                oThis.options.oMarker.update();
            };

            img.onerror = function(){
                var oDefaultIcon = emp.utilities.icon.getDefaultIcon(oThis.options.basePath);

                oThis.options.iconSize = new L.Point(oDefaultIcon.size.width, oDefaultIcon.size.height);
                oThis.options.iconAnchorRef = {x: oDefaultIcon.offset.x, y: oDefaultIcon.offset.y};
                oThis.options.iconAnchorType =	{x: oDefaultIcon.offset.xUnits, y: oDefaultIcon.offset.yUnits};

                img.src = oDefaultIcon.iconUrl;
            };
            return img;
        },
        _getRealScale: function()
        {
            var dKMLScale = 1.0;
            var dScale = 1.0;

            if (!emp.helpers.isEmptyString(this.options.scale))
            {
                dKMLScale = parseFloat(this.options.scale);
            }

            if ((this.options.oIconImag.naturalWidth > this.options.oIconImag.naturalHeight) &&
                    (this.options.oIconImag.naturalWidth > 32))
            {
                dScale = 32 / this.options.oIconImag.naturalWidth;
            }
            else if ((this.options.oIconImag.naturalHeight > this.options.oIconImag.naturalWidth) &&
                    (this.options.oIconImag.naturalHeight > 32))
            {
                dScale = 32 / this.options.oIconImag.naturalHeight;
            }
            else if ((this.options.oIconImag.naturalHeight === this.options.oIconImag.naturalWidth) &&
                    (this.options.oIconImag.naturalHeight > 32))
            {
                dScale = 32 / this.options.oIconImag.naturalHeight;
            }

            return dKMLScale * dScale;
        },
        _calculatXOffset: function(iIconWidth, sOffset, sOffsetType, dScale)
        {
            var iOffset = 0;

            switch (sOffsetType.toLowerCase())
            {
                case 'fraction':
                    var dFraction = parseFloat(sOffset);

                    iOffset = Math.floor(iIconWidth * dFraction * -1.0);
                    break;
                case 'pixels':
                    var iOffsetValue = parseInt(sOffset);

                    iOffset = iOffsetValue * -1;
                    break;
                case 'insetpixels':
                    var iOffsetValue = parseInt(sOffset);

                    iOffset = (iIconWidth - iOffsetValue) * -1;
                    break;
            }

            return Math.floor(iOffset * dScale);
        },
        _calculatYOffset: function(iIconHeight, sOffset, sOffsetType, dScale)
        {
            var iOffset = 0;

            switch (sOffsetType.toLowerCase())
            {
                case 'fraction':
                    var dFraction = parseFloat(sOffset);

                    iOffset = Math.floor(iIconHeight * dFraction) - iIconHeight;
                    break;
                case 'pixels':
                    var iOffsetValue = parseInt(sOffset);

                    iOffset = iOffsetValue - iIconHeight;
                    break;
                case 'insetpixels':
                    var iOffsetValue = parseInt(sOffset);

                    iOffset = iOffsetValue * -1;
                    break;
            }

            return Math.floor(iOffset * dScale);
        },
        _applyAnchorRef: function()
        {
            var oImg = this.options.oIconImag;
            var marginLeft;
            var marginTop;
            var iIconWidth;
            var iIconHeight;
            var dAngle;
            var dTempX;
            var dTempY;
            var fHeading;
            var iCenterX;
            var iCenterY;
            var dScale = this._getRealScale();

            if (this.options.iconAnchorRef)
            {
                var oOffset = this.options.iconAnchorRef;
                var oUnits = this.options.iconAnchorType;
                var sXUnits = 'fraction';
                var sYUnits = 'fraction';

                if (oUnits && (typeof (oUnits.x) === 'string'))
                {
                    sXUnits = oUnits.x;
                }

                if (oUnits && (typeof (oUnits.y) === 'string'))
                {
                    sYUnits = oUnits.y;
                }

                marginLeft = this._calculatXOffset(oImg.naturalWidth, oOffset.x, sXUnits, dScale);
                marginTop = this._calculatYOffset(oImg.naturalHeight, oOffset.y, sYUnits, dScale);

                iIconWidth = Math.floor(oImg.naturalWidth * dScale);
                iIconHeight = Math.floor(oImg.naturalHeight * dScale);
            }
            else
            {
                var oIconUtils = emp.typeLibrary.utils.icon;
                var oDefaultIcon = oIconUtils.getDefaultIcon(this.options.basePath);
                var iXOffset = oIconUtils.calculateXOffset(oDefaultIcon.size.width, oDefaultIcon.offset.x, oDefaultIcon.offset.xUnits);
                var iYOffset = oIconUtils.calculateYOffset(oDefaultIcon.size.height, oDefaultIcon.offset.y, oDefaultIcon.offset.yUnits, emp.utilities.icon.referencePoin.BOTTOM_LEFT);

                marginLeft = iXOffset;
                marginTop = iYOffset;

                iIconWidth = Math.floor(oDefaultIcon.size.width * dScale);
                iIconHeight = Math.floor(oDefaultIcon.size.height * dScale);
            }

            if (!emp.helpers.isEmptyString(this.options.heading))
            {
                fHeading = parseFloat(this.options.heading);
                iCenterX = marginLeft + (iIconWidth / 2);
                iCenterY = marginTop + (iIconHeight / 2);

                dTempX = 0 - iCenterX;
                dTempY = 0 - iCenterY;

                dAngle = fHeading * Math.PI / 180.0;
                var dSin = Math.sin(dAngle);
                var dCos = Math.cos(dAngle);

                var dNewX = Math.round((dTempX * dCos) - (dTempY * dSin));
                var dNewY = Math.round((dTempX * dSin) + (dTempY * dCos));

                dTempX = dNewX + iCenterX;
                dTempY = dNewY + iCenterY;

                marginLeft -= dTempX;
                marginTop -= dTempY;
            }

            oImg.style.marginLeft = Math.ceil(marginLeft) + 'px';
            oImg.style.marginTop = Math.ceil(marginTop) + 'px';

            oImg.style.width = iIconWidth + 'px';
            oImg.style.height = iIconHeight + 'px';

            return Math.floor(dScale * 1000) / 1000;
        }
    };

    return publicInterface;
};

leafLet.typeLibrary.EmpKMLIcon = L.KMLIcon.extend(leafLet.internalPrivateClass.EmpKMLIcon());

leafLet.internalPrivateClass.EmpKMLMarker = function(){
    var publicInterface = {
	initialize: function (latlng, options) {
            options.draggable = false;

            options.icon.options.oMarker = this;
            L.Marker.prototype.initialize.call(this, latlng, options);
	},
        setLatLng: function (latlng) {
            this._latlng = L.latLng(latlng);

            if (this._icon)
            {
                var pos = this._map.latLngToLayerPoint(this._latlng).round();

                this._setPos(pos);
            }

            return this.fire('move', { latlng: this._latlng });
        },
        update: function () {
            if (this._icon) {
                var pos = this._map.latLngToLayerPoint(this._latlng).round();

                this._setPos(pos);
            }

            return this;
        },

	_setPos: function (pos) {
            var oImg;
            var sTemp;
            var dScale = this.options.icon._applyAnchorRef();

            L.Marker.prototype._setPos.call(this, pos);

            oImg = this._icon;

            sTemp = emp.helpers.isEmptyString(oImg.style[L.DomUtil.TRANSFORM])? '': oImg.style[L.DomUtil.TRANSFORM];

            //sTemp += ' scale(' + dScale + ',' + dScale + ')';

            if (!emp.helpers.isEmptyString(this.options.icon.options.heading))
            {
                sTemp += ' rotate(' + this.options.icon.options.heading + 'deg)';
            }

            oImg.style[L.DomUtil.TRANSFORM] = sTemp;
	}
    };

    return publicInterface;
};

leafLet.typeLibrary.EmpKMLMarker = L.Marker.extend(leafLet.internalPrivateClass.EmpKMLMarker());

leafLet.internalPrivateClass.KMLPluginExtension = function(){
    var publicInterface = {
        initialize: function(kml, options) {
            L.Util.setOptions(this, options);
            this._kml = kml;
            this._layers = {};

            if (kml)
            {
                if (typeof (kml) !== 'string')
                {
                    throw new Error('KML or URL must be a string.');
                }

                if (emp.helpers.isUrl(kml))
                {
                    this.addKML(kml, options, this.options.async);
                }
                else
                {
                    this._addKML(emp.$.parseXML(kml), options);
                }
            }
        },
        getIconUrl: function(sKmlUrl)
        {
            var sURL = sKmlUrl;
            if (this.options.oFeatureProperties.hasOwnProperty('iconUrl'))
            {
                sURL = this.options.oFeatureProperties.iconUrl;
            }

            if (emp.util.config.getUseProxySetting())
            {
                sURL = emp.util.config.getProxyUrl() + "?" + "mime=image/*&url=" + escape(sURL);
            }

            return sURL;
        },
        _addKML: function(xml, options)
        {
                this.options.kmlDoc = xml;
                var layers = this.parseKML(xml);
                if (!layers || !layers.length) return;
                for (var i = 0; i < layers.length; i++) {
                    this.fire('addlayer', {
                            layer: layers[i]
                    });
                    this.addLayer(layers[i]);
                }
                this.latLngs = this.getLatLngs(xml);
                this.fire('loaded');
        },
        parseStyle: function (xml) {
            var style = {};
            var sl = xml.getElementsByTagName('Style');

            //for (var i = 0; i < sl.length; i++) {
            var attributes = {color: true, width: true, Icon: true, href: true,
                              hotSpot: true, scale: true, heading:true};

            function _parse(xml) {
                var options = {};
                for (var i = 0; i < xml.childNodes.length; i++) {
                    var e = xml.childNodes[i];
                    var key = e.tagName;
                    if (!attributes[key]) { continue; }
                    if (key === 'hotSpot')
                    {
                        for (var j = 0; j < e.attributes.length; j++) {
                            options[e.attributes[j].name] = e.attributes[j].nodeValue;
                        }
                    } else {
                        var value = e.childNodes[0].nodeValue;
                        if (key === 'color') {
                            options.opacity = parseInt(value.substring(0, 2), 16) / 255.0;
                            options.color = '#' + value.substring(6, 8) + value.substring(4, 6) + value.substring(2, 4);
                        } else if (key === 'width') {
                            options.weight = value;
                        } else if (key === 'Icon') {
                            ioptions = _parse(e);
                            if (ioptions.href) { options.href = ioptions.href; }
                        } else if (key === 'href') {
                            options.href = value;
                        } else if (key === 'scale') {
                            options.scale = value;
                        } else if (key === 'heading') {
                            options.heading = value;
                        }
                    }
                }
                return options;
            }

            for (var i = 0; i < sl.length; i++) {
                var e = sl[i],
                    el;
                var options = {},
                    poptions = {},
                    ioptions = {};

                el = e.getElementsByTagName('LineStyle');
                if (el && el[0]) { options = _parse(el[0]); }

                el = e.getElementsByTagName('PolyStyle');

                if (el && el[0]) { poptions = _parse(el[0]); }

                if (poptions.color) { options.fillColor = poptions.color; }

                if (poptions.opacity) { options.fillOpacity = poptions.opacity; }

                el = e.getElementsByTagName('IconStyle');
                if (el && el[0]) { ioptions = _parse(el[0]); }

                if (ioptions.href) {
                    // save anchor info until the image is loaded

                    var oIconOptions = {
                        iconUrl: this.getIconUrl(ioptions.href),
                        shadowUrl: null,
                        iconAnchorRef: {x: ioptions.x, y: ioptions.y},
                        iconAnchorType:	{x: ioptions.xunits, y: ioptions.yunits}
                    };

                    if (!emp.helpers.isEmptyString(ioptions.scale))
                    {
                        oIconOptions.scale = ioptions.scale;
                    }

                    if (!emp.helpers.isEmptyString(ioptions.heading))
                    {
                        oIconOptions.heading = ioptions.heading;
                    }

                    oIconOptions.basePath = this.options.basePath;

                    options.icon = new leafLet.typeLibrary.EmpKMLIcon(oIconOptions);
                }
                style['#' + e.getAttribute('id')] = options;
            }
            return style;
        },
        parsePlacemark: function (place, xml, style) {
            var h, i, j, el, options = {};

            var multi = ['MultiGeometry', 'gx:MultiTrack'];
            for (h in multi) {
                if (!multi.hasOwnProperty(h)) {
                    continue;
                }
                el = place.getElementsByTagName(multi[h]);
                for (i = 0; i < el.length; i++) {
                    return this.parsePlacemark(el[i], xml, style);
                }
            }

            el = place.getElementsByTagName('Style');

            if (el && (el.length > 0))
            {
                for (i = 0; i < el.length; i++) {
                    var sIndex = '#' + el[i].getAttribute('id');
                    for (var a in style[sIndex]) {
                        if (!style[sIndex].hasOwnProperty(a)) {
                            continue;
                        }
                        options[a] = style[sIndex][a];
                    }
                }
            }
            else
            {
                el = place.getElementsByTagName('styleUrl');

                for (i = 0; i < el.length; i++) {
                    var url = el[i].childNodes[0].nodeValue;
                    for (var a in style[url]) {
                        if (!style[url].hasOwnProperty(a)) {
                            continue;
                        }
                        options[a] = style[url][a];
                    }
                }
            }

            var layers = [];

            var parse = ['LineString', 'Polygon', 'Point', 'gx:Track'];
            for (j in parse) {
                if (!parse.hasOwnProperty(j)) {
                    continue;
                }
                var tag = parse[j];
                el = place.getElementsByTagName(tag);
                for (i = 0; i < el.length; i++) {
                    var l = this['parse' + tag.replace(/gx:/, '')](el[i], xml, options);
                    if (l) { layers.push(l); }
                }
            }

            if (!layers.length) {
                return;
            }
            var layer = layers[0];
            if (layers.length > 1) {
                layer = new L.FeatureGroup(layers);
            }

            var sID, name, descr = '';

            if (place.id) {
                sID = place.id;
            }

            el = place.getElementsByTagName('name');
            if (el.length && el[0].childNodes.length) {
                name = el[0].childNodes[0].nodeValue;
            }
            el = place.getElementsByTagName('description');
            for (i = 0; i < el.length; i++) {
                for (j = 0; j < el[i].childNodes.length; j++) {
                    descr = descr + el[i].childNodes[j].nodeValue;
                }
            }

            if ((typeof (name) === 'string') && (name.length > 0))
            {
                layer.options.kmlName = name;
            }

            if ((typeof (descr) === 'string') && (descr.length > 0))
            {
                layer.options.kmlDescription = descr;
            }

            if ((typeof (sID) === 'string') && (sID.length > 0))
            {
                layer.options.sSubItemID = sID;
            }

            //if (name) {
            //    layer.bindPopup('<h2>' + name + '</h2>' + descr, {
            //        closeButton: false
            //    });
            //}

            return layer;
        },
        _read_coords: function (el) {
            var text = '', coords = [], i;
            for (i = 0; i < el.childNodes.length; i++) {
                text = text + el.childNodes[i].nodeValue;
            }
            text = text.split(/[\s\n]+/);
            for (i = 0; i < text.length; i++) {
                var ll = text[i].split(',');
                if (ll.length < 2) {
                    continue;
                }
                coords.push(new L.LatLng(ll[1], ll[0], ll[2]));
            }
            return coords;
        },
        _read_gxcoords: function (el) {
            var text = '', coords = [];
            text = el.firstChild.nodeValue.split(' ');
            coords.push(new L.LatLng(text[1], text[0], text[2]));
            return coords;
        },
        getOptions: function(sType, oOptions)
        {
            var oColor;
            var oProperties = this.options.oFeatureProperties;

            if (sType === 'point') {
                var sURL;
                var iXOffset,
                    iYOffset,
                    sXUnits,
                    sYUnits;

                if (oProperties.hasOwnProperty('iconUrl'))
                {
                    sURL = this.getIconUrl(oProperties.iconUrl);
                }

                if (oProperties.hasOwnProperty('iconXOffset'))
                {
                    iXOffset = oProperties.iconXOffset;
                    if (oProperties.hasOwnProperty('xUnits'))
                    {
                        sXUnits = oProperties.xUnits;
                    }
                }

                if (oProperties.hasOwnProperty('iconYOffset'))
                {
                    iYOffset = oProperties.iconYOffset;
                    if (oProperties.hasOwnProperty('yUnits'))
                    {
                        sYUnits = oProperties.yUnits;
                    }
                }

                if (!iXOffset)
                {
                    if (oOptions.icon && oOptions.icon.options.iconAnchorRef)
                    {
                        iXOffset = oOptions.icon.options.iconAnchorRef.x;
                    }
                    else
                    {
                        iXOffset = 0;
                    }
                }

                if (!sXUnits)
                {
                    if (oOptions.icon && oOptions.icon.options.iconAnchorType)
                    {
                        sXUnits = oOptions.icon.options.iconAnchorType.x;
                    }
                    else
                    {
                        sXUnits = 'fraction';
                    }
                }

                if (!iYOffset)
                {
                    if (oOptions.icon && oOptions.icon.options.iconAnchorRef)
                    {
                        iYOffset = oOptions.icon.options.iconAnchorRef.y;
                    }
                    else
                    {
                        iYOffset = 0;
                    }
                }

                if (!sYUnits)
                {
                    if (oOptions.icon && oOptions.icon.options.iconAnchorType)
                    {
                        sYUnits = oOptions.icon.options.iconAnchorType.y;
                    }
                    else
                    {
                        sYUnits = 'fraction';
                    }
                }

                if (!oOptions.icon)
                {
                    if (!sURL)
                    {
                        var oDefaultIcon = emp.utilities.icon.getDefaultIcon(this.options.basePath);

                        sURL = oDefaultIcon.iconUrl;
                        iYOffset = oDefaultIcon.offset.y;
                        iXOffset = oDefaultIcon.offset.x;
                        sXUnits = oDefaultIcon.offset.xUnits;
                        sYUnits = oDefaultIcon.offset.yUnits;
                    }

                    if (this.options.oFeature.isSelected())
                    {
                        oOptions.icon = new leafLet.typeLibrary.EmpKMLIcon({
                            iconUrl: sURL,
                            shadowUrl: null,
                            iconAnchorRef: {x: iXOffset, y: iYOffset},
                            iconAnchorType: {x: sXUnits, y: sYUnits},
                            className: 'icon-selected',
                            basePath: this.options.basePath
                        });
                    }
                    else
                    {
                        oOptions.icon = new leafLet.typeLibrary.EmpKMLIcon({
                            iconUrl: sURL,
                            shadowUrl: null,
                            iconAnchorRef: {x: iXOffset, y: iYOffset},
                            iconAnchorType: {x: sXUnits, y: sYUnits},
                            basePath: this.options.basePath
                        });
                    }
                }
                else
                {
                    if ((typeof (sURL) === 'string') && (sURL.length > 0))
                    {
                        oOptions.icon.options.iconUrl = sURL;
                    }
                    oOptions.icon.options.iconAnchorRef = {x: iXOffset, y: iYOffset};
                    oOptions.icon.options.iconAnchorType = {x: sXUnits, y: sYUnits};

                    if (this.options.oFeature.isSelected())
                    {
                        oOptions.icon.options.className = 'icon-selected';
                    }
                    else
                    {
                        oOptions.icon.options.className = '';
                    }
                }
            }

            if (this.options.oFeature.isSelected()) {
                oOptions.color = '#' + this.options.oFeature.options.instanceInterface.selectAttributes.color;
                oOptions.weight = this.options.oFeature.options.instanceInterface.selectAttributes.width;

                if ((sType === 'line') || (sType === 'polygon')) {
                    if (oProperties.hasOwnProperty('lineColor')) {
                        oOptions.tempColor = leafLet.utils.convertColor(oProperties.lineColor).sColor;
                    } else {
                        oOptions.tempColor = L.LEAFLET_DEFAULT_LINE_COLOR;
                    }
                    if (oProperties.hasOwnProperty('lineWidth'))
                    {
                        if (typeof (oProperties.lineWidth) === 'string')
                        {
                            oOptions.tempWeight = parseInt(oProperties.lineWidth);
                        }
                        else
                        {
                            oOptions.tempWeight = oProperties.lineWidth;
                        }
                    } else {
                        oOptions.tempWeight = L.LEAFLET_DEFAULT_LINE_WEIGHT;
                    }
                }
            } else if (oProperties.hasOwnProperty('lineColor') && ((sType === 'line') || (sType === 'polygon'))) {
                oColor = leafLet.utils.convertColor(oProperties.lineColor);

                oOptions.color = oColor.sColor;
                oOptions.opacity = oColor.opacity;

                if (oProperties.hasOwnProperty('lineWidth'))
                {
                    if (typeof (oProperties.lineWidth) === 'string')
                    {
                        oOptions.weight = parseInt(oProperties.lineWidth);
                    }
                    else
                    {
                        oOptions.weight = oProperties.lineWidth;
                    }
                }
            }

            if (oProperties.hasOwnProperty('fillColor') && (sType === 'polygon'))
            {
                oColor = leafLet.utils.convertColor(oProperties.fillColor);

                oOptions.fill = true;
                oOptions.fillColor = oColor.sColor;
                oOptions.fillOpacity = oColor.opacity;
            }

            oOptions.oFeature = this.options.oFeature;

            return oOptions;
        },
        parsePoint: function (line, xml, options) {
            var el = line.getElementsByTagName('coordinates');
            if (!el.length) {
                return;
            }
            var ll = el[0].childNodes[0].nodeValue.split(',');
            return new leafLet.typeLibrary.EmpKMLMarker(new L.LatLng(ll[1], ll[0], ll[2]), this.getOptions('point', options));
        },
	parseLineString: function (line, xml, options) {
            var coords = this.parseCoords(line);
            if (!coords.length) { return; }
            return new L.Polyline(coords, this.getOptions('line', options));
	},
	parseTrack: function (line, xml, options) {
            var el = xml.getElementsByTagName('gx:coord');
            var coords = [];
            for (var j = 0; j < el.length; j++) {
                    coords = coords.concat(this._read_gxcoords(el[j]));
            }
            if (!coords.length) { return; }
            return new L.Polyline(coords, this.getOptions('line', options));
	},
	parsePolygon: function (line, xml, options) {
            var el, polys = [], inner = [], i, coords;

            el = line.getElementsByTagName('outerBoundaryIs');

            for (i = 0; i < el.length; i++) {
                coords = this.parseCoords(el[i]);
                if (coords) {
                    polys.push(coords);
                }
            }
            el = line.getElementsByTagName('innerBoundaryIs');
            for (i = 0; i < el.length; i++) {
                coords = this.parseCoords(el[i]);
                if (coords) {
                    inner.push(coords);
                }
            }
            if (!polys.length) {
                return;
            }
            if (options.fillColor) {
                options.fill = true;
            }
            if (polys.length === 1) {
                return new L.Polygon(polys.concat(inner), this.getOptions('polygon', options));
            }
            return new L.MultiPolygon(polys, this.getOptions('polygon', options));
	}
/*	getBounds: function () {
		var bounds = new L.LatLngBounds();

		this.eachLayer(function (layer) {
			bounds.extend(layer instanceof leafLet.typeLibrary.EmpKMLMarker ? layer.getLatLng() : layer.getBounds());
		});

		return bounds;
	}
*/
    };

    return publicInterface;
};

leafLet.typeLibrary.EmpKmlObject = L.KML.extend(leafLet.internalPrivateClass.KMLPluginExtension());


text:
import os
import re

from pip.req import parse_requirements
from setuptools import setup, find_packages

def requirements_from_file(filename):
    requirements = []
    for r in parse_requirements(filename, session='fake'):
        if r.match_markers():
            requirements.append(str(r.req))
    return requirements

here = os.path.abspath(os.path.dirname(__file__))

with open(os.path.join(here, 'devtools', '__init__.py'), encoding='utf-8') as f:
    try:
        version = re.findall(r"^__version__ = '([^']+)'\r?$", f.read(), re.M)[0]
    except IndexError:
        raise RuntimeError('Unable to determine version')

setup(
    name='devtools-proxy',

    version=version,

    description='DevTools Proxy',
    long_description='DevTools Proxy',

    url='https://github.com/bayandin/devtools-proxy',

    author='Alexander Bayandin',
    author_email='a.bayandin@gmail.com',

    license='MIT',

    classifiers=[
        'Development Status :: 3 - Alpha',
        # 'Development Status :: 4 - Beta',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: MIT License',
        'Operating System :: MacOS :: MacOS X',
        # 'Operating System :: Microsoft :: Windows',
        'Operating System :: POSIX',
        'Programming Language :: Python',
        'Programming Language :: Python :: 3.6',
        'Topic :: Software Development :: Testing',
    ],

    keywords='selenium chrome chromedriver devtools',

    packages=find_packages(exclude=['tests', 'tests.*']),

    install_requires=requirements_from_file('requirements.txt'),

    package_data={
        'devtools': [
            'chrome-wrapper.sh',
        ],
    },

    entry_points={
        'console_scripts': [
            'devtools-proxy=devtools.proxy:main',
        ],
    },
)


text:
htmlSuite('ShadowCss', function() {
  htmlTest('html/pseudo-scoping.html');
  htmlTest('html/pseudo-scoping.html?shadow');
  htmlTest('html/pseudo-scoping-strict.html');
  htmlTest('html/pseudo-scoping-strict.html?shadow');
  htmlTest('html/polyfill-directive.html');
  htmlTest('html/polyfill-rule.html');
  htmlTest('html/colon-host.html');
  htmlTest('html/colon-host.html?shadow');
  htmlTest('html/combinators.html?shadow');
  htmlTest('html/combinators-shadow.html');
  htmlTest('html/combinators-shadow.html?shadow');
  htmlTest('html/compressed.html');
  htmlTest('html/before-content.html');
  htmlTest('html/before-content.html?shadow');
  htmlTest('html/before-content.html');
  htmlTest('html/style-import.html');
  htmlTest('html/css-animation.html');
});


text:
var arr = {};

arr[15] = "Sea, Sex and Sun";

arr[30] = "No photo's please, I'm having private time";
arr[33] = "Trying to fuck around with Rhymes";
arr[34] = "It's cool yo, don't sweat it forget it";
arr[36] = "Just walk away or whatever, be a fucking bitch";
arr[38] = "I'm fucking rich, I'm not sort of rich";
arr[40] = "I get bored of bitches, yeah import a bitch";
arr[41] = "(Is this shit really going down?)";
arr[43] = "Of course it is, about the time to freak the sorcerers";
arr[45] = "What's up baby yo, and away we go";
arr[47] = "We'll get there fast then we take it slow";
arr[49] = "I'm a hard mutha'fucker with a tender soul";
arr[51] = "Don't give a fuck but I've got a heart made of gold";
arr[53] = "I switch off, forget about my enemies";
arr[54] = "You stare at me, like you're not scared of me";
arr[56] = "Just absorb the mutha'fucken energy";
arr[58] = "You and me, we can build a memory";
arr[60] = "And make ya' cum, then I'll make ya' cum some more";
arr[62] = "Harder than ya' ever fucking cum before";
arr[64] = "Then just fuck until you can't, fuck until you";
arr[64] = "Can't fuck no more, then fuck some more";
arr[67] = "And get Raw";

arr[68] = "Sea, Sex and Sun";

arr[98] = "Yolandi live a lekker life of luxury";
arr[100] = "Everybody know not to fuck with me";
arr[102] = "Na na na not the boss of me";
arr[103] = "But if you love me, I'm loving you loving me";
arr[105] = "My style so hot Versace copy me";
arr[107] = "Bitch don't be fucking with my bubbly";
arr[109] = "Do I like breaking rules? Possibly";
arr[111] = "But if you gonna do it then fucking do it properly";
arr[113] = "I rap real cute with an ominous tone";
arr[115] = "LA with the weed and i wanna get stoned";
arr[117] = "Chilling like a motherfucker puffing it slow";
arr[119] = "I pop it so fuck it, I'm shopping at Rome";
arr[120] = "When I get home visiting my ugly boys";
arr[122] = "In the hood yeah they making big fucking noise";
arr[124] = "Have fun with guns and a bum full of cum and love my bum,";
arr[127] = "still with a little bit of";

arr[128] = "Sea, Sex and Sun";

arr[156] = "Hi-Tek,this beat is so sex";

arr[162] = "";
arr[175] = "My style's so hot";

arr[190] = "Absorb... ma' energy";
arr[205] = "energy";

arr[214] = "Sea, Sex and Sun";
arr[260] = "";


text: ActiveRecord::Base.send(:include, FindIds)


text:
/* Explore program module.                                               */
/* This module adds some string utilities not found in the standard      */
/* C library.                                                            */

#include    <stdio.h>
#include    <string.h>

/* This is an extention of the strtok function.   */
/* It replaces the previous delimiter with delim, */
/* preserving the original string.                */
char *
nexttok(delim)
    char           *delim;
{
    char           *new;

    new = strtok(NULL, delim);
    if (new != NULL)
        *(new - 1) = *delim;

    return (new);
}

char *
token_search(string, token, delim)
    char           *string, *token, delim;
{
    char           *ptr, *next_delim;

    ptr = string;
    do
    {
        next_delim = strchr(ptr, delim);

        if (next_delim == NULL)
        {
            if (!strcmp(token, ptr))
                return (ptr);
        }
        else
        {
            if (!strncmp(token, ptr, next_delim - ptr)
                && (strlen(token) == (next_delim - ptr)))
                return (ptr);

            ptr = next_delim + 1;
        }

    } while (next_delim != NULL);

    return (NULL);
}

void shftstr(string, shift)
    char           *string;
    int             shift;
{
    char           *ptr, *start, *end;

    start = string;
    end = string + strlen(string);

    if (shift == 0)
        return;

    if (shift > 0)
        for (ptr = end; ptr >= start; --ptr)
            *(ptr + shift) = *ptr;
    else
        for (ptr = start; ptr <= end; ++ptr)
            *(ptr + shift) = *ptr;
}


text:
package org.apache.hadoop.hbase.errorhandling;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;

/**
 * Test that we propagate errors through an dispatcher exactly once via different failure
 * injection mechanisms.
 */
@Category({MasterTests.class, SmallTests.class})
public class TestForeignExceptionDispatcher {
  private static final Log LOG = LogFactory.getLog(TestForeignExceptionDispatcher.class);

  /**
   * Exception thrown from the test
   */
  final ForeignException EXTEXN = new ForeignException("FORTEST", new IllegalArgumentException("FORTEST"));
  final ForeignException EXTEXN2 = new ForeignException("FORTEST2", new IllegalArgumentException("FORTEST2"));

  /**
   * Tests that a dispatcher only dispatches only the first exception, and does not propagate
   * subsequent exceptions.
   */
  @Test
  public void testErrorPropagation() {
    ForeignExceptionListener listener1 = Mockito.mock(ForeignExceptionListener.class);
    ForeignExceptionListener listener2 = Mockito.mock(ForeignExceptionListener.class);
    ForeignExceptionDispatcher dispatcher = new ForeignExceptionDispatcher();

    // add the listeners
    dispatcher.addListener(listener1);
    dispatcher.addListener(listener2);

    // create an artificial error
    dispatcher.receive(EXTEXN);

    // make sure the listeners got the error
    Mockito.verify(listener1, Mockito.times(1)).receive(EXTEXN);
    Mockito.verify(listener2, Mockito.times(1)).receive(EXTEXN);

    // make sure that we get an exception
    try {
      dispatcher.rethrowException();
      fail("Monitor should have thrown an exception after getting error.");
    } catch (ForeignException ex) {
      assertTrue("Got an unexpected exception:" + ex, ex.getCause() == EXTEXN.getCause());
      LOG.debug("Got the testing exception!");
    }

    // push another error, which should be not be passed to listeners
    dispatcher.receive(EXTEXN2);
    Mockito.verify(listener1, Mockito.never()).receive(EXTEXN2);
    Mockito.verify(listener2, Mockito.never()).receive(EXTEXN2);
  }

  @Test
  public void testSingleDispatcherWithTimer() {
    ForeignExceptionListener listener1 = Mockito.mock(ForeignExceptionListener.class);
    ForeignExceptionListener listener2 = Mockito.mock(ForeignExceptionListener.class);

    ForeignExceptionDispatcher monitor = new ForeignExceptionDispatcher();

    // add the listeners
    monitor.addListener(listener1);
    monitor.addListener(listener2);

    TimeoutExceptionInjector timer = new TimeoutExceptionInjector(monitor, 1000);
    timer.start();
    timer.trigger();

    assertTrue("Monitor didn't get timeout", monitor.hasException());

    // verify that that we propagated the error
    Mockito.verify(listener1).receive(Mockito.any());
    Mockito.verify(listener2).receive(Mockito.any());
  }

  /**
   * Test that the dispatcher can receive an error via the timer mechanism.
   */
  @Test
  public void testAttemptTimer() {
    ForeignExceptionListener listener1 = Mockito.mock(ForeignExceptionListener.class);
    ForeignExceptionListener listener2 = Mockito.mock(ForeignExceptionListener.class);
    ForeignExceptionDispatcher orchestrator = new ForeignExceptionDispatcher();

    // add the listeners
    orchestrator.addListener(listener1);
    orchestrator.addListener(listener2);

    // now create a timer and check for that error
    TimeoutExceptionInjector timer = new TimeoutExceptionInjector(orchestrator, 1000);
    timer.start();
    timer.trigger();
    // make sure that we got the timer error
    Mockito.verify(listener1, Mockito.times(1)).receive(Mockito.any());
    Mockito.verify(listener2, Mockito.times(1)).receive(Mockito.any());
  }
}


text:
<!---
  category: NetworkingAndWebServices
  samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=620626
--->

# Wi-Fi Direct sample

Shows how to use the Wi-Fi Direct API to discover devices and connect to the them over Wi-Fi Direct.

> **Note:** This sample is part of a large collection of UWP feature samples.
> If you are unfamiliar with Git and GitHub, you can download the entire collection as a
> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be
> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file,
> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq).
> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center.

Specifically, this sample demonstrates the following:

- **Advertise a Wi-Fi Direct device:**
A device can advertise its presence so that other Wi-Fi Direct devices
can discover and connect to it. There are optional settings that
an advertiser may specify, such as custom information elements
to share during discovery, and options for how to establish a connection.
An advertiser can also specify advanced optional settings such as
pairing configuration methods (in order of preference)
and the preferred pairing procedure.
The advertiser can also be cofigured in legacy mode wherein legacy
(non-WiFiDirect) clients can connect to it.
The legacy mode also supports specifying a SSID and a passphrase.
- **Discover a Wi-Fi Direct device:** Discover advertising devices over Wi-Fi Direct.
- **Connect to a device/Accept an incoming connection:** After discovering a Wi-Fi Direct device, a device may connect to it. The advertising device may accept or decline the connection.
The connector can also be configured with optional advanced settings
such as the pairing configuration methods (in order of preference)
and the preferred pairing procedure.
- **Send data over Wi-Fi Direct after connecting to a device:** Connected peers may open TCP and UDP sockets and send data. This sample just sends text strings as a sample.

The C++ and JS samples do not demonstrate advanced optional settings yet.
Support for those will come in a future sample.

**Note** This sample requires two or more devices with Wi-Fi chipsets and drivers that support Wi-Fi Direct.

**Note** This sample was created using one of the universal app templates available in Visual Studio. It shows how its solution is structured so it can run on Windows 10. For more info about how to build apps that target Windows and Windows Phone with Visual Studio, see [Build apps that target Windows 10 by using Visual Studio](http://msdn.microsoft.com/library/windows/apps/dn609832).

## Related topics

### Reference

[Wi-Fi Direct](https://msdn.microsoft.com/library/windows/apps/windows.devices.wifidirect.aspx)
[Sockets](https://msdn.microsoft.com/library/windows/apps/windows.networking.sockets.aspx)

## System requirements

**Client:** Windows 10

**Server:** Windows Server 2016 Technical Preview

**Phone:**  Windows 10

## Build the sample

1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
2. Start Microsoft Visual Studio 2017 and select **File** \> **Open** \> **Project/Solution**.
3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio Solution (.sln) file.
4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**.

## Run the sample

The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.

### Deploying the sample

- Select **Build** \> **Deploy Solution**.

### Deploying and running the sample

- To debug the sample and then run it, press F5 or select **Debug** \> **Start Debugging**. To run the sample without debugging, press Ctrl+F5 or select **Debug** \> **Start Without Debugging**.

**Note** You will need to deploy the sample to at least two devices in order to actually discover and connect to devices, unless you are using the sample to interact with other devices that support Wi-Fi Direct.


text:
module Carto
  # A dataset may be comprised of additional tables other than the main table
  # For example, if overviews have been created for the dataset.
  # This is a utility to apply changes (e.g. privilege modifications) to all
  # the tables than comprise the dataset.
  module TableAndFriends
    def self.apply(db_connection, schema, table_name, &block)
      qualified_name = qualified_table_name(schema, table_name)
      block[schema, table_name, qualified_name]
      overviews_service = Carto::OverviewsService.new(db_connection)
      overviews_service.overview_tables(qualified_name).each do |overview_table|
        table, _ = Table.table_and_schema(overview_table)
        block[schema, table, qualified_table_name(schema, table)]
      end
      # TODO: should we apply also to raster overview tables?
      # To do so we could use SupportTables class and modify it to make #tables public.
      # Note that SupportTables handles only raster overviews and provides methods
      # to rename them, delete them and change their schema.
    end

    def self.qualified_table_name(schema, table_name)
      %{"#{schema.gsub('"', '""')}"."#{table_name.gsub('"', '""')}"}
    end
  end
end


text:
package com.mister.app;

import com.fxhelper.loader.SceneLoader;
import javafx.application.Application;
import javafx.stage.Stage;

public class Main extends Application {

    private Stage primaryStage;

    @Override
    public void start(Stage primaryStage) {
        this.primaryStage = primaryStage;
        primaryStage.setTitle("Mister");
        mainWindow();
    }

    private void mainWindow() {
        primaryStage.setScene(SceneLoader.load("MainMenu"));
        primaryStage.setResizable(false);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}


text:
"""Define tests for the Ambient PWS config flow."""
import json

import aioambient
import pytest

from homeassistant import data_entry_flow
from homeassistant.components.ambient_station import (
    CONF_APP_KEY, DOMAIN, config_flow)
from homeassistant.const import CONF_API_KEY

from tests.common import (
    load_fixture, MockConfigEntry, MockDependency, mock_coro)

@pytest.fixture
def get_devices_response():
    """Define a fixture for a successful /devices response."""
    return mock_coro()

@pytest.fixture
def mock_aioambient(get_devices_response):
    """Mock the aioambient library."""
    with MockDependency('aioambient') as mock_aioambient_:
        mock_aioambient_.Client(
        ).api.get_devices.return_value = get_devices_response
        yield mock_aioambient_

async def test_duplicate_error(hass):
    """Test that errors are shown when duplicates are added."""
    conf = {
        CONF_API_KEY: '12345abcde12345abcde',
        CONF_APP_KEY: '67890fghij67890fghij',
    }

    MockConfigEntry(domain=DOMAIN, data=conf).add_to_hass(hass)
    flow = config_flow.AmbientStationFlowHandler()
    flow.hass = hass

    result = await flow.async_step_user(user_input=conf)
    assert result['errors'] == {CONF_APP_KEY: 'identifier_exists'}

@pytest.mark.parametrize(
    'get_devices_response',
    [mock_coro(exception=aioambient.errors.AmbientError)])
async def test_invalid_api_key(hass, mock_aioambient):
    """Test that an invalid API/App Key throws an error."""
    conf = {
        CONF_API_KEY: '12345abcde12345abcde',
        CONF_APP_KEY: '67890fghij67890fghij',
    }

    flow = config_flow.AmbientStationFlowHandler()
    flow.hass = hass

    result = await flow.async_step_user(user_input=conf)
    assert result['errors'] == {'base': 'invalid_key'}

@pytest.mark.parametrize('get_devices_response', [mock_coro(return_value=[])])
async def test_no_devices(hass, mock_aioambient):
    """Test that an account with no associated devices throws an error."""
    conf = {
        CONF_API_KEY: '12345abcde12345abcde',
        CONF_APP_KEY: '67890fghij67890fghij',
    }

    flow = config_flow.AmbientStationFlowHandler()
    flow.hass = hass

    result = await flow.async_step_user(user_input=conf)
    assert result['errors'] == {'base': 'no_devices'}

async def test_show_form(hass):
    """Test that the form is served with no input."""
    flow = config_flow.AmbientStationFlowHandler()
    flow.hass = hass

    result = await flow.async_step_user(user_input=None)

    assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
    assert result['step_id'] == 'user'

@pytest.mark.parametrize(
    'get_devices_response',
    [mock_coro(return_value=json.loads(load_fixture('ambient_devices.json')))])
async def test_step_import(hass, mock_aioambient):
    """Test that the import step works."""
    conf = {
        CONF_API_KEY: '12345abcde12345abcde',
        CONF_APP_KEY: '67890fghij67890fghij',
    }

    flow = config_flow.AmbientStationFlowHandler()
    flow.hass = hass

    result = await flow.async_step_import(import_config=conf)
    assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
    assert result['title'] == '67890fghij67'
    assert result['data'] == {
        CONF_API_KEY: '12345abcde12345abcde',
        CONF_APP_KEY: '67890fghij67890fghij',
    }

@pytest.mark.parametrize(
    'get_devices_response',
    [mock_coro(return_value=json.loads(load_fixture('ambient_devices.json')))])
async def test_step_user(hass, mock_aioambient):
    """Test that the user step works."""
    conf = {
        CONF_API_KEY: '12345abcde12345abcde',
        CONF_APP_KEY: '67890fghij67890fghij',
    }

    flow = config_flow.AmbientStationFlowHandler()
    flow.hass = hass

    result = await flow.async_step_user(user_input=conf)
    assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
    assert result['title'] == '67890fghij67'
    assert result['data'] == {
        CONF_API_KEY: '12345abcde12345abcde',
        CONF_APP_KEY: '67890fghij67890fghij',
    }