#!/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 Test

class Test inherits QUnit::Test {
    constructor() : QUnit::Test("assignment operator precedence", "1.0", \ARGV) {
        addTestCase("basic case", \basicCase());
        set_return_value(main());
    }

    basicCase() {
        Program p(PO_NEW_STYLE);
        p.parse("int sub test() { int a = 1; int b = 2; a = b += 2; return a; }", "test");
        # this test would fail with Qore < 0.8.12
        testAssertion("prec-1", \p.callFunction(), "test", new TestResultValue(4));
    }
}
