#!/usr/bin/env qore
# -*- mode: qore; indent-tabs-mode: nil -*-

%new-style
%enable-all-warnings
%require-types
%strict-args
%no-child-restrictions

%requires ../../../../qlib/QUnit.qm

%exec-class IncludeModuleTest

class IncludeModuleTest inherits QUnit::Test {
    constructor() : QUnit::Test("IncludeModule test", "1.0") {
        addTestCase("Include whole separated module test", \testIncludeWholeModule());
        set_return_value(main());
    }

    testIncludeWholeModule() {
        Program p(PO_NEW_STYLE|PO_REQUIRE_TYPES);
        p.parse(
            "#!/usr/bin/env /home/tpetr/devel_release/bin/qore\n"
            "# -*- mode: qore; indent-tabs-mode: nil -*-\n"

            "# examples path is for Jenkins; '.' is for manual runs\n"
            "%append-module-path examples/test/qore/requires:.\n"
            "%requires MyModule\n"

            "MyModule::mfunc(\"\");\n"
        , "");

        assertEq(
            "MyModule::mfunc::EXAMPLE_C::SomeClass::cfunc\n"
            "MyModule::mfunc::EXAMPLE_C::func\n"
            "MyModule::mfunc::EXAMPLE_F::func\n"
        , p.callFunctionArgs("mfunc", ""));
    }
}
