diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-04-16 16:51:23 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-24 00:32:45 +0200 |
commit | a36f220e1554c15c4a5808479a4af90b39075e6a (patch) | |
tree | 9fce48af39873c608157158932c2e4979a6773ed /tests | |
parent | 6a815193c7515dc8282aae08b3b78203d5cfbc1f (diff) |
Add support for var properties in V4
Support initialization of var properties in V4. Var properties, which
can only be manipulated by V8, are constructed directly into the form
in which they will be stored.
Task-number: QTBUG-25022
Change-Id: I27c6af9f8a310e7baec91bef2593c8518ec1e462
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/v4/data/varHandling.qml | 67 | ||||
-rw-r--r-- | tests/auto/qml/v4/tst_v4.cpp | 9 |
2 files changed, 76 insertions, 0 deletions
diff --git a/tests/auto/qml/v4/data/varHandling.qml b/tests/auto/qml/v4/data/varHandling.qml new file mode 100644 index 0000000000..c19e6a256f --- /dev/null +++ b/tests/auto/qml/v4/data/varHandling.qml @@ -0,0 +1,67 @@ +import QtQuick 2.0 + +QtObject { + property bool pBool: true + property int pInt: 666 + property real pReal: 3.1415927 + property string pString: 'foo' + property url pUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' + property color pColor: Qt.rgba(1, 0, 0, 0.5) + property QtObject pObject: QtObject { property string foo: 'bar' } + + // Test assignment to var + property var pBoolVar: pBool + property var pIntVar: pInt + property var pRealVar: pReal + property var pStringVar: pString + property var pUrlVar: pUrl + property var pColorVar: pColor + property var pObjectVar: pObject + property var pNullVar: null + property var pVarVar: pUrlVar + + // Test equivalence + property bool boolConversionSuccess: (pBoolVar == true) + property bool intConversionSuccess: (pIntVar == 666) + property bool realConversionSuccess: (pRealVar == 3.1415927) + property bool stringConversionSuccess: (pStringVar == 'foo') + + property url comparisonUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' + property bool urlConversionSuccess: (pUrlVar == comparisonUrl) + + property color comparisonColor: Qt.rgba(1, 0, 0, 0.5) + property bool colorConversionSuccess: (pColorVar == comparisonColor) + + property bool objectConversionSuccess: (pObjectVar == pObject) + property bool nullConversionSuccess: (pNullVar == null) + + property bool varConversionSuccess: (pVarVar == comparisonUrl) + + // Operations are not handled by V4 - they should pass through correctly + property var pVarNot: !pBoolVar + property var pVarComplement: ~pIntVar + property var pVarEqual: (pBoolVar == pBoolVar) + property var pVarLiteralEqual: (pBoolVar == true) + property var pVarUnequal: (pUrlVar == pColorVar) + property var pVarComparison: (pIntVar <= pIntVar) + property var pVarShift: (pIntVar >> 1) + + Component.onCompleted: { + if (!boolConversionSuccess) console.warn('QV4: bool conversion failed'); + if (!intConversionSuccess) console.warn('QV4: int conversion failed'); + if (!realConversionSuccess) console.warn('QV4: real conversion failed'); + if (!stringConversionSuccess) console.warn('QV4: string conversion failed'); + if (!urlConversionSuccess) console.warn('QV4: url conversion failed'); + if (!colorConversionSuccess) console.warn('QV4: color conversion failed'); + if (!objectConversionSuccess) console.warn('QV4: object conversion failed'); + if (!nullConversionSuccess) console.warn('QV4: null conversion failed'); + if (!varConversionSuccess) console.warn('QV4: var conversion failed'); + if (pVarNot != false) console.warn('QV4: var negation impeded'); + if (pVarComplement != ~666) console.warn('QV4: var complement impeded'); + if (pVarEqual != true) console.warn('QV4: var equality impeded'); + if (pVarLiteralEqual != true) console.warn('QV4: var/literal equality impeded'); + if (pVarUnequal != false) console.warn('QV4: var unequality impeded'); + if (pVarComparison != true) console.warn('QV4: var comparison impeded'); + if (pVarShift != 333) console.warn('QV4: var shift impeded'); + } +} diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp index 99a4405afa..57dec5a884 100644 --- a/tests/auto/qml/v4/tst_v4.cpp +++ b/tests/auto/qml/v4/tst_v4.cpp @@ -151,6 +151,7 @@ void tst_v4::qtscript_data() QTest::newRow("conversion from url") << "conversions.7.qml"; // QTBUG-24706 QTest::newRow("conversion from vec3") << "conversions.8.qml"; QTest::newRow("variantHandling") << "variantHandling.qml"; + QTest::newRow("varHandling") << "varHandling.qml"; } void tst_v4::unnecessaryReeval() @@ -858,30 +859,38 @@ void tst_v4::debuggingDumpInstructions() expectedPreAddress << "\t\tConvertBoolToNumber\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertBoolToString\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertBoolToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertBoolToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertIntToBool\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertIntToNumber\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertIntToString\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertIntToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertIntToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertNumberToBool\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertNumberToInt\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertNumberToString\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertNumberToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertNumberToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertStringToBool\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertStringToInt\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertStringToNumber\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertStringToUrl\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertStringToColor\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertStringToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertStringToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertUrlToBool\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertUrlToString\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertUrlToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertUrlToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertColorToBool\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertColorToString\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertColorToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertColorToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertObjectToBool\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertObjectToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertObjectToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertNullToObject\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tConvertNullToVariant\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertNullToVar\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tResolveUrl\t\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tMathSinNumber\t\tInput_Reg(0) -> Output_Reg(0)"; expectedPreAddress << "\t\tMathCosNumber\t\tInput_Reg(0) -> Output_Reg(0)"; |