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

%new-style
%enable-all-warnings
%require-types
%strict-args

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

%exec-class RecursiveDependencyTest

class RecursiveDependencyTest inherits QUnit::Test {
    private {
        const Scripts = ("recursive-load.q", "recursive-load-dir.q");
    }

    constructor() : Test("Recursive dependency test", "1.0") {
        addTestCase("RD Test", \test());

        set_return_value(main());
    }

    test() {
        assertThrows('LOAD-MODULE-ERROR', sub() {load_module("./R1.qm");});

        string dir = get_script_dir();
        foreach string script in (Scripts) {
            string loc = dir + DirSep + script;
            assertRegex("LOAD-MODULE-ERROR", backquote("qore " + loc + " 2>&1"), script);
        }
    }
}

