diff options
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
10 files changed, 64 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/TypeWithEnum.qml b/tests/auto/qml/qqmllanguage/data/TypeWithEnum.qml index c89a228bef..c6788f787a 100644 --- a/tests/auto/qml/qqmllanguage/data/TypeWithEnum.qml +++ b/tests/auto/qml/qqmllanguage/data/TypeWithEnum.qml @@ -7,8 +7,22 @@ QtObject { EnumValue3 } + enum MyOtherEnum { + OtherEnumValue1 = 24, + OtherEnumValue2, + OtherEnumValue3 = 24, + OtherEnumValue4, + OtherEnumValue5 = 1 + } + property int enumValue: TypeWithEnum.EnumValue2 property int enumValue2 property int scopedEnumValue: TypeWithEnum.MyEnum.EnumValue2 Component.onCompleted: enumValue2 = TypeWithEnum.EnumValue3 + + property int otherEnumValue1: TypeWithEnum.OtherEnumValue1 + property int otherEnumValue2: TypeWithEnum.OtherEnumValue2 + property int otherEnumValue3: TypeWithEnum.OtherEnumValue3 + property int otherEnumValue4: TypeWithEnum.OtherEnumValue4 + property int otherEnumValue5: TypeWithEnum.OtherEnumValue5 } diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.errors.txt new file mode 100644 index 0000000000..a96fe376aa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.errors.txt @@ -0,0 +1 @@ +6:22:Expected token `numeric literal' diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.qml b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.qml new file mode 100644 index 0000000000..fef23ecbef --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + enum MyEnum { + EnumValue1, + EnumValue2 = "hello", + EnumValue3 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.errors.txt new file mode 100644 index 0000000000..a96fe376aa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.errors.txt @@ -0,0 +1 @@ +6:22:Expected token `numeric literal' diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.qml b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.qml new file mode 100644 index 0000000000..9892fcd19c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + enum MyEnum { + EnumValue1, + EnumValue2 = hello, + EnumValue3 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.3.errors.txt new file mode 100644 index 0000000000..43465c60ec --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.3.errors.txt @@ -0,0 +1 @@ +7:22:Enum value out of range diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.3.qml b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.3.qml new file mode 100644 index 0000000000..654bc0e626 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.3.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + enum MyEnum { + EnumValue1, + EnumValue2, + EnumValue3 = 2147483648 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.4.errors.txt new file mode 100644 index 0000000000..12756dc593 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.4.errors.txt @@ -0,0 +1 @@ +7:22:Enum value must be an integer diff --git a/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.4.qml b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.4.qml new file mode 100644 index 0000000000..4a0aafba5e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.4.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + enum MyEnum { + EnumValue1, + EnumValue2, + EnumValue3 = 17.5 + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index c145c6d737..f09c130e38 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -549,6 +549,10 @@ void tst_qqmllanguage::errors_data() QTest::newRow("scopedEnumList") << "scopedEnumList.qml" << "scopedEnumList.errors.txt" << false; QTest::newRow("lowercase enum value") << "lowercaseQmlEnum.1.qml" << "lowercaseQmlEnum.1.errors.txt" << false; QTest::newRow("lowercase enum type") << "lowercaseQmlEnum.2.qml" << "lowercaseQmlEnum.2.errors.txt" << false; + QTest::newRow("string enum value") << "invalidQmlEnumValue.1.qml" << "invalidQmlEnumValue.1.errors.txt" << false; + QTest::newRow("identifier enum type") << "invalidQmlEnumValue.2.qml" << "invalidQmlEnumValue.2.errors.txt" << false; + QTest::newRow("enum value too large") << "invalidQmlEnumValue.3.qml" << "invalidQmlEnumValue.3.errors.txt" << false; + QTest::newRow("non-integer enum value") << "invalidQmlEnumValue.4.qml" << "invalidQmlEnumValue.4.errors.txt" << false; const QString expectedError = isCaseSensitiveFileSystem(dataDirectory()) ? QStringLiteral("incorrectCase.errors.sensitive.txt") : @@ -3730,6 +3734,12 @@ void tst_qqmllanguage::qmlEnums() QCOMPARE(o->property("enumValue").toInt(), 1); QCOMPARE(o->property("enumValue2").toInt(), 2); QCOMPARE(o->property("scopedEnumValue").toInt(), 1); + + QCOMPARE(o->property("otherEnumValue1").toInt(), 24); + QCOMPARE(o->property("otherEnumValue2").toInt(), 25); + QCOMPARE(o->property("otherEnumValue3").toInt(), 24); + QCOMPARE(o->property("otherEnumValue4").toInt(), 25); + QCOMPARE(o->property("otherEnumValue5").toInt(), 1); } { |