aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpromise/data/promise-resolve-with-promise.qml
blob: 62b70828fd3e58e729cb9ddceca2e5f203279b4b (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
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.0

QtObject {
    property int resolveValue: 5
    property var originalPromise: Promise.resolve(resolveValue)

    property var castPromise: Promise.resolve(originalPromise)
    property bool wasTestSuccessful: false

    Component.onCompleted: {
        if (castPromise !== originalPromise) {
            console.log("resolve did not return original promise")
            return;
        }

        castPromise.then(function(value) {
            if (value !== resolveValue) {
                console.log("resolved values are not the same")
                return;
            }

            wasTestSuccessful = true
        }, function() {
            throw new Error("Should never be called")
        })
    }
}