aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/data/importLexicalVariables.mjs
blob: 19c012d19bf5b2026c8076cd96d2b5c379693999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export function runTest(libraryUnderTest) {
    let state1 = state(libraryUnderTest);
    try { modifyFromOutside(libraryUnderTest); } catch (e) {}
    let state2 = state(libraryUnderTest);
    try { modifyFromInside(libraryUnderTest); } catch (e) {}
    let state3 = state(libraryUnderTest);
    return state1 + " " + state2 + " " + state3;
}

function stringify(value) {
    let s = "?";
    if (value !== undefined)
        s = value.toString();
    return s;
}

function state(libraryUnderTest) {
    return (stringify(libraryUnderTest.varValue) +
            stringify(libraryUnderTest.letValue) +
            stringify(libraryUnderTest.constValue));
}

function modifyFromOutside(libraryUnderTest) {
    ++libraryUnderTest.varValue;
    ++libraryUnderTest.letValue;
    ++libraryUnderTest.constValue;
}

function modifyFromInside(libraryUnderTest) {
    libraryUnderTest.incrementAll();
}