diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-07 11:22:52 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2013-05-07 12:28:58 +0200 |
commit | 5963aead75991ea8b0fded251e18ef75f099ab8f (patch) | |
tree | 17d6fdcb52fc1d59fa2ab3037121c679b9dd20aa /tests/auto | |
parent | 40d2e435cfa29ba7465adc0486e6dabcdfc49773 (diff) |
More steps towards eliminating the v8 layer
* Changed the return type of the InvocationCallback from a v8 handle to a QV4::Value
* Removed v4 auto tests and fixed build of other tests
Change-Id: Ic927b925923ca8785170689a5c260969fd1cb794
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
59 files changed, 35 insertions, 2571 deletions
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index b973d44012..f52c9b0352 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -52,7 +52,6 @@ PRIVATETESTS += \ qquickworkerscript \ qqmlbundle \ qrcqml \ - v4 \ qqmltimer \ qqmlinstantiator diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 51ecb0481a..364359f1b8 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -50,7 +50,6 @@ #include <QtCore/qnumeric.h> #include <private/qqmlengine_p.h> #include <private/qqmlvmemetaobject_p.h> -#include <private/qv4compiler_p.h> #include "testtypes.h" #include "testhttpserver.h" #include "../../shared/util.h" @@ -2170,7 +2169,7 @@ static inline bool evaluate_error(QV8Engine *engine, v8::Handle<v8::Object> o, c QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); v8::TryCatch tc; - v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); + v8::Handle<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); if (tc.HasCaught()) return false; v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); @@ -2187,7 +2186,7 @@ static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o, QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); v8::TryCatch tc; - v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); + v8::Handle<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); if (tc.HasCaught()) return false; v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); @@ -2209,7 +2208,7 @@ static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::O QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); v8::TryCatch tc; - v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); + v8::Handle<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); if (tc.HasCaught()) return v8::Handle<v8::Value>(); v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); @@ -2239,10 +2238,7 @@ void tst_qqmlecmascript::callQtInvokables() QV8Engine *engine = ep->v8engine(); - v8::HandleScope handle_scope; - v8::Context::Scope scope(engine->context()); - - v8::Local<v8::Object> object = engine->newQObject(o)->ToObject(); + v8::Handle<v8::Object> object = engine->newQObject(o); // Non-existent methods o->reset(); @@ -2309,7 +2305,7 @@ void tst_qqmlecmascript::callQtInvokables() { v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QPointF()"); QVERIFY(!ret.IsEmpty()); - QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5))); + QCOMPARE(engine->toVariant(ret->v4Value(), -1), QVariant(QPointF(123, 4.5))); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 3); QCOMPARE(o->actuals().count(), 0); @@ -2318,7 +2314,7 @@ void tst_qqmlecmascript::callQtInvokables() o->reset(); { v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QObject()"); - QCOMPARE(engine->toQObject(ret), (QObject *)o); + QCOMPARE(engine->toQObject(ret->v4Value()), (QObject *)o); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 4); QCOMPARE(o->actuals().count(), 0); @@ -2334,7 +2330,7 @@ void tst_qqmlecmascript::callQtInvokables() { v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QScriptValue()"); QVERIFY(ret->IsString()); - QCOMPARE(engine->toString(ret), QString("Hello world")); + QCOMPARE(ret->v4Value().toQString(), QString("Hello world")); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 6); QCOMPARE(o->actuals().count(), 0); @@ -3785,16 +3781,11 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { scriptContext = engine->contextWrapper()->context(qmlglobal); { - v8::HandleScope handle_scope; - v8::Persistent<v8::Context> context = v8::Context::New(); - v8::Context::Scope context_scope(context); - v8::Local<v8::Object> temporaryScope = engine->qmlScope(scriptContext, NULL); + v8::Handle<v8::Object> temporaryScope = engine->qmlScope(scriptContext, NULL); Q_UNUSED(temporaryScope) - - context.Dispose(); } - QV8Engine::gc(); + engine->gc(); newContext = engine->contextWrapper()->context(qmlglobal); QVERIFY(scriptContext == newContext); } @@ -4875,7 +4866,6 @@ void tst_qqmlecmascript::propertyVarInheritance() v8::Persistent<v8::Value> icoCanaryHandle; v8::Persistent<v8::Value> ccoCanaryHandle; { - v8::HandleScope hs; // XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only // public function which can return us a handle to something in the varProperties array. icoCanaryHandle = qPersistentNew(icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ"))); @@ -4919,7 +4909,6 @@ void tst_qqmlecmascript::propertyVarInheritance2() QCOMPARE(childObject->property("textCanary").toInt(), 10); v8::Persistent<v8::Value> childObjectVarArrayValueHandle; { - v8::HandleScope hs; propertyVarWeakRefCallbackCount = 0; // reset callback count. childObjectVarArrayValueHandle = qPersistentNew(QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp"))); childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback); @@ -6672,9 +6661,7 @@ void tst_qqmlecmascript::doubleEvaluate() void tst_qqmlecmascript::nonNotifyable() { - QV4Compiler::enableV4(false); QQmlComponent component(&engine, testFileUrl("nonNotifyable.qml")); - QV4Compiler::enableV4(true); QQmlTestMessageHandler messageHandler; diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index 8d8b913df7..7a59a7f243 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -323,15 +323,6 @@ void tst_qqmlinstruction::dump() } { - QQmlCompiledData::Instruction::StoreV4Binding i; - i.property = 27; - i.value = 2; - i.context = 4; - i.owner = 0; - data->addInstruction(i); - } - - { QQmlCompiledData::Instruction::StoreValueSource i; i.property.coreIndex = 29; i.castValue = 4; @@ -531,32 +522,31 @@ void tst_qqmlinstruction::dump() << "29\t\tASSIGN_SIGNAL_OBJECT\t4" << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9" << "31\t\tSTORE_BINDING\t26\t3\t2" - << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4" - << "33\t\tSTORE_VALUE_SOURCE\t29\t4" - << "34\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4" - << "35\t\tBEGIN\t\t\t4" - << "36\t\tSTORE_OBJECT_QLIST" - << "37\t\tASSIGN_OBJECT_LIST" - << "38\t\tFETCH_ATTACHED\t\t23" - << "39\t\tFETCH_QLIST\t\t32" - << "40\t\tFETCH\t\t\t33" - << "41\t\tFETCH_VALUE\t\t34\t6\t7" - << "42\t\tPOP" - << "43\t\tPOP_QLIST" - << "44\t\tPOP_VALUE\t\t35\t8" + << "32\t\tSTORE_VALUE_SOURCE\t29\t4" + << "33\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4" + << "34\t\tBEGIN\t\t\t4" + << "35\t\tSTORE_OBJECT_QLIST" + << "36\t\tASSIGN_OBJECT_LIST" + << "37\t\tFETCH_ATTACHED\t\t23" + << "38\t\tFETCH_QLIST\t\t32" + << "39\t\tFETCH\t\t\t33" + << "40\t\tFETCH_VALUE\t\t34\t6\t7" + << "41\t\tPOP" + << "42\t\tPOP_QLIST" + << "43\t\tPOP_VALUE\t\t35\t8" + << "44\t\tDEFER\t\t\t7" << "45\t\tDEFER\t\t\t7" - << "46\t\tDEFER\t\t\t7" - << "47\t\tSTORE_IMPORTED_SCRIPT\t2" - << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11" - << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7" - << "50\t\tDONE" - << "51\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2" - << "52\t\tSTORE_TRID_STRING\t78\t7\t-1" - << "53\t\tSTORE_VAR\t\t79\t5\t\t\"color(1, 1, 1, 1)\"" - << "54\t\tSTORE_VAR_OBJECT\t80" - << "55\t\tSTORE_VAR_INTEGER\t81\t23" - << "56\t\tSTORE_VAR_DOUBLE\t82\t66.3" - << "57\t\tSTORE_VAR_BOOL\t\t83\ttrue" + << "46\t\tSTORE_IMPORTED_SCRIPT\t2" + << "47\t\tSTORE_VARIANT_INTEGER\t\t32\t11" + << "48\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7" + << "49\t\tDONE" + << "50\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2" + << "51\t\tSTORE_TRID_STRING\t78\t7\t-1" + << "52\t\tSTORE_VAR\t\t79\t5\t\t\"color(1, 1, 1, 1)\"" + << "53\t\tSTORE_VAR_OBJECT\t80" + << "54\t\tSTORE_VAR_INTEGER\t81\t23" + << "55\t\tSTORE_VAR_DOUBLE\t82\t66.3" + << "56\t\tSTORE_VAR_BOOL\t\t83\ttrue" << "-------------------------------------------------------------------------------"; QQmlTestMessageHandler messageHandler; diff --git a/tests/auto/qml/v4/data/colorType.qml b/tests/auto/qml/v4/data/colorType.qml deleted file mode 100644 index f6a98a4a3e..0000000000 --- a/tests/auto/qml/v4/data/colorType.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property bool useMyColor: true - property color myColor: "red" - property color myOtherColor: "green" - - property color test1: useMyColor ? myColor : myOtherColor - property color test2: useMyColor ? "red" : "green" - property color test3: useMyColor ? myColor : "green" - - property bool test4: !myColor ? false : true - - property bool test5: myColor != "red" - property bool test6: myColor == "#ff0000" - property bool test7: myColor != "#00ff00" -} - diff --git a/tests/auto/qml/v4/data/conditionalExpr.qml b/tests/auto/qml/v4/data/conditionalExpr.qml deleted file mode 100644 index 704f7c6c5a..0000000000 --- a/tests/auto/qml/v4/data/conditionalExpr.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int n: 2 - property int a: n ? 1 : 0 - property int b: if (n) { 1 } else { 0 } - result: (a && b) ? 0 : 1 -} diff --git a/tests/auto/qml/v4/data/conversions.1.qml b/tests/auto/qml/v4/data/conversions.1.qml deleted file mode 100644 index b3abde770a..0000000000 --- a/tests/auto/qml/v4/data/conversions.1.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning bool prop to other proptypes. - boolProp: true - intProp: boolProp - floatProp: boolProp - doubleProp: boolProp - qrealProp: boolProp - qstringProp: boolProp - qurlProp: boolProp - vec3Prop: Qt.vector3d(boolProp, boolProp, boolProp) -} diff --git a/tests/auto/qml/v4/data/conversions.2.qml b/tests/auto/qml/v4/data/conversions.2.qml deleted file mode 100644 index 2fd0453ac2..0000000000 --- a/tests/auto/qml/v4/data/conversions.2.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning int prop to other proptypes. - boolProp: intProp - intProp: 4 - floatProp: intProp - doubleProp: intProp - qrealProp: intProp - qstringProp: intProp - qurlProp: intProp - vec3Prop: Qt.vector3d(intProp, intProp, intProp) -} diff --git a/tests/auto/qml/v4/data/conversions.3.qml b/tests/auto/qml/v4/data/conversions.3.qml deleted file mode 100644 index 66f0761a25..0000000000 --- a/tests/auto/qml/v4/data/conversions.3.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning float prop to other proptypes. - boolProp: floatProp - intProp: floatProp - floatProp: 4.4 - doubleProp: floatProp - qrealProp: floatProp - qstringProp: floatProp - qurlProp: floatProp - vec3Prop: Qt.vector3d(floatProp, floatProp, floatProp) -} diff --git a/tests/auto/qml/v4/data/conversions.4.qml b/tests/auto/qml/v4/data/conversions.4.qml deleted file mode 100644 index ccf0035313..0000000000 --- a/tests/auto/qml/v4/data/conversions.4.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning double prop to other prop types - boolProp: doubleProp - intProp: doubleProp - floatProp: doubleProp - doubleProp: 4.444444444 - qrealProp: doubleProp - qstringProp: doubleProp - qurlProp: doubleProp - vec3Prop: Qt.vector3d(doubleProp, doubleProp, doubleProp) -} diff --git a/tests/auto/qml/v4/data/conversions.5.qml b/tests/auto/qml/v4/data/conversions.5.qml deleted file mode 100644 index 26dc3b7195..0000000000 --- a/tests/auto/qml/v4/data/conversions.5.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning qreal prop to other prop types - boolProp: qrealProp - intProp: qrealProp - floatProp: qrealProp - doubleProp: qrealProp - qrealProp: 4.44 - qstringProp: qrealProp - qurlProp: qrealProp - vec3Prop: Qt.vector3d(qrealProp, qrealProp, qrealProp) -} diff --git a/tests/auto/qml/v4/data/conversions.6.qml b/tests/auto/qml/v4/data/conversions.6.qml deleted file mode 100644 index 573b227ada..0000000000 --- a/tests/auto/qml/v4/data/conversions.6.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning string prop to other proptypes. - boolProp: qstringProp - intProp: qstringProp - floatProp: qstringProp - doubleProp: qstringProp - qrealProp: qstringProp - qstringProp: "4" - qurlProp: qstringProp - vec3Prop: Qt.vector3d(qstringProp, qstringProp, qstringProp) -} diff --git a/tests/auto/qml/v4/data/conversions.7.qml b/tests/auto/qml/v4/data/conversions.7.qml deleted file mode 100644 index 5112b06b1e..0000000000 --- a/tests/auto/qml/v4/data/conversions.7.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning url prop to other proptypes. - boolProp: qurlProp - intProp: qurlProp - floatProp: qurlProp - doubleProp: qurlProp - qrealProp: qurlProp - qstringProp: qurlProp - qurlProp: "4" - vec3Prop: Qt.vector3d(qurlProp, qurlProp, qurlProp) -} diff --git a/tests/auto/qml/v4/data/conversions.8.qml b/tests/auto/qml/v4/data/conversions.8.qml deleted file mode 100644 index 18bf160e7e..0000000000 --- a/tests/auto/qml/v4/data/conversions.8.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning vector prop to other proptypes. - boolProp: vec3Prop - intProp: vec3Prop - floatProp: vec3Prop - doubleProp: vec3Prop - qrealProp: vec3Prop - qstringProp: vec3Prop - qurlProp: vec3Prop - vec3Prop: Qt.vector3d(4, 4, 4) -} diff --git a/tests/auto/qml/v4/data/doubleBoolJump.qml b/tests/auto/qml/v4/data/doubleBoolJump.qml deleted file mode 100644 index 2eea73b573..0000000000 --- a/tests/auto/qml/v4/data/doubleBoolJump.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - QtObject { - property real output: i1.p1 || i2.p2 == "text" ? 0.7 : 0 - } - - QtObject { - id: i2 - property string p2 - } - - QtObject { - id: i1 - property bool p1: false - } -} - diff --git a/tests/auto/qml/v4/data/equals.qml b/tests/auto/qml/v4/data/equals.qml deleted file mode 100644 index 2862bb7ac9..0000000000 --- a/tests/auto/qml/v4/data/equals.qml +++ /dev/null @@ -1,51 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property QtObject myprop1: null - property QtObject myprop2: QtObject {} - property real zero: 0 - property bool falseProp: false - - property bool test1: myprop1 == false - property bool test2: myprop1 == null - property bool test3: 5 == myprop1 - property bool test4: null == myprop1 - property bool test5: myprop1 != false - property bool test6: myprop1 != null - property bool test7: 5 != myprop1 - property bool test8: null != myprop1 - - property bool test9: myprop2 == false - property bool test10: myprop2 == null - property bool test11: 5 == myprop2 - property bool test12: null == myprop2 - property bool test13: myprop2 != false - property bool test14: myprop2 != null - property bool test15: 5 != myprop2 - property bool test16: null != myprop2 - - property bool test17: myprop1 == myprop1 - property bool test18: myprop1 != myprop1 - property bool test19: myprop1 == myprop2 - property bool test20: myprop1 != myprop2 - property bool test21: myprop2 == myprop2 - property bool test22: myprop2 != myprop2 - - property bool test23: myprop1 == "hello" - property bool test24: myprop1 != "hello" - property bool test25: myprop2 == "hello" - property bool test26: myprop2 != "hello" - - property bool test27: falseProp == zero - property bool test28: falseProp != zero - property bool test29: falseProp == 1 - property bool test30: falseProp != 1 - property bool test31: true == zero - property bool test32: true != zero - property bool test33: true == 1 - property bool test34: true != 1 - - property bool test35: "a\ -b" === "ab" -} - diff --git a/tests/auto/qml/v4/data/fetchException.qml b/tests/auto/qml/v4/data/fetchException.qml deleted file mode 100644 index 6431fcfae8..0000000000 --- a/tests/auto/qml/v4/data/fetchException.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Item { - property Item data - property int a: data.x, 1 -} diff --git a/tests/auto/qml/v4/data/integerOperations.qml b/tests/auto/qml/v4/data/integerOperations.qml deleted file mode 100644 index 805f4566fb..0000000000 --- a/tests/auto/qml/v4/data/integerOperations.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 2.0 - -Item { - property int testa1: i1.p1 - property int testa2: -testa1 - i1.p1 - - property int testb1: i1.p1 & 2 - property int testb2: i1.p2 & 2 - property int testb3: 2 & i1.p1 - property int testb4: 2 & i1.p2 - property int testb5: i1.p1 & i1.p3 - property int testb6: i1.p2 & i1.p3 - property int testb7: i1.p3 & i1.p1 - property int testb8: i1.p3 & i1.p2 - - property int testc1: i1.p1 | 2 - property int testc2: i1.p2 | 2 - property int testc3: 2 | i1.p1 - property int testc4: 2 | i1.p2 - property int testc5: i1.p1 | i1.p3 - property int testc6: i1.p2 | i1.p3 - property int testc7: i1.p3 | i1.p1 - property int testc8: i1.p3 | i1.p2 - - property int testd1: i1.p1 ^ 7 - property int testd2: 7 ^ i1.p1 - property int testd3: i1.p1 ^ i1.p4 - property int testd4: i1.p4 ^ i1.p1 - - property int teste1: i1.p4 << 2 - property int teste2: i1.p5 << 2 - property int teste3: 2 << i1.p4 - property int teste4: i1.p4 << i1.p3 - property int teste5: i1.p5 << i1.p3 - property int teste6: i1.p3 << i1.p4 - - property int testf1: i1.p4 >> 2 - property int testf2: i1.p5 >> 2 - property int testf3: 2 >> i1.p4 - property int testf4: i1.p4 >> i1.p3 - property int testf5: i1.p5 >> i1.p3 - property int testf6: i1.p3 >> i1.p4 - - property int testg1: i1.p4 >>> 2 - property int testg2: i1.p5 >>> 2 - property int testg3: 2 >>> i1.p4 - property int testg4: i1.p4 >>> i1.p3 - property int testg5: i1.p5 >>> i1.p3 - property int testg6: i1.p3 >>> i1.p4 - - QtObject { - id: i1 - property int p1: 333 - property int p2: -666 - property int p3: 2 - property int p4: 7 - property int p5: -7 - } - } diff --git a/tests/auto/qml/v4/data/jsvalueHandling.qml b/tests/auto/qml/v4/data/jsvalueHandling.qml deleted file mode 100644 index d15e878a52..0000000000 --- a/tests/auto/qml/v4/data/jsvalueHandling.qml +++ /dev/null @@ -1,69 +0,0 @@ -import QtQuick 2.0 -import Qt.v4 1.0 - -JSValueTest { - 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' } - property var pVar: pUrl - - // Test assignment to QJSValue - boolVar: pBool - intVar: pInt - realVar: pReal - stringVar: pString - urlVar: pUrl - colorVar: pColor - objectVar: pObject - nullVar: null - varVar: pVar - - // Test equivalence - property bool boolConversionSuccess: (boolVar == true) - property bool intConversionSuccess: (intVar == 666) - property bool realConversionSuccess: (realVar == 3.1415927) - property bool stringConversionSuccess: (stringVar == 'foo') - - property url comparisonUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' - property bool urlConversionSuccess: (urlVar == comparisonUrl) - - property color comparisonColor: Qt.rgba(1, 0, 0, 0.5) - property bool colorConversionSuccess: (colorVar == comparisonColor) - - property bool objectConversionSuccess: (objectVar == pObject) - property bool nullConversionSuccess: (nullVar == null) - - property bool varConversionSuccess: (varVar == comparisonUrl) - - // Operations are not handled by V4 - they should pass through correctly - property var pVarNot: !boolVar - property var pVarComplement: ~intVar - property var pVarEqual: (boolVar == pBool) - property var pVarLiteralEqual: (boolVar == true) - property var pVarUnequal: (urlVar == colorVar) - property var pVarComparison: (intVar <= intVar) - property var pVarShift: (intVar >> 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/data/logicalAnd.2.qml b/tests/auto/qml/v4/data/logicalAnd.2.qml deleted file mode 100644 index cc3d75bd90..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.2.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "foo" && "bar" - result: s == "bar" -} diff --git a/tests/auto/qml/v4/data/logicalAnd.3.qml b/tests/auto/qml/v4/data/logicalAnd.3.qml deleted file mode 100644 index 6527f05d07..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.3.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "" - property bool flag: true - - result: (s && flag) == "" -} diff --git a/tests/auto/qml/v4/data/logicalAnd.4.qml b/tests/auto/qml/v4/data/logicalAnd.4.qml deleted file mode 100644 index fbcee91699..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.4.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "foo" - property bool flag: true - - result: (!flag && s) == false -} diff --git a/tests/auto/qml/v4/data/logicalAnd.5.qml b/tests/auto/qml/v4/data/logicalAnd.5.qml deleted file mode 100644 index f0698463fe..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.5.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt.v4 1.0 - -Result { - property bool flag: true - - result: (null && flag) == null -} diff --git a/tests/auto/qml/v4/data/logicalAnd.6.qml b/tests/auto/qml/v4/data/logicalAnd.6.qml deleted file mode 100644 index e98b5c99cd..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.6.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "" - property bool flag: true - property string subresult: s && flag - - result: subresult === "" -} diff --git a/tests/auto/qml/v4/data/logicalAnd.7.qml b/tests/auto/qml/v4/data/logicalAnd.7.qml deleted file mode 100644 index 0f19d3fb40..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.7.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt.v4 1.0 - -Result { - property real nan: Number.NaN - property bool flag: true - property real subresult: nan && flag - - result: isNaN(subresult) -} diff --git a/tests/auto/qml/v4/data/logicalAnd.qml b/tests/auto/qml/v4/data/logicalAnd.qml deleted file mode 100644 index 40fc3616c2..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 10 - result: a == 10 && a == 2 -} diff --git a/tests/auto/qml/v4/data/logicalOr.2.qml b/tests/auto/qml/v4/data/logicalOr.2.qml deleted file mode 100644 index 54fb78b127..0000000000 --- a/tests/auto/qml/v4/data/logicalOr.2.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "foo" || "bar" - result: s == "foo" -} diff --git a/tests/auto/qml/v4/data/logicalOr.qml b/tests/auto/qml/v4/data/logicalOr.qml deleted file mode 100644 index 406a7d83eb..0000000000 --- a/tests/auto/qml/v4/data/logicalOr.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 10 - result: a == 1 || a == 2 -} diff --git a/tests/auto/qml/v4/data/mathAbs.qml b/tests/auto/qml/v4/data/mathAbs.qml deleted file mode 100644 index eb504ae4d8..0000000000 --- a/tests/auto/qml/v4/data/mathAbs.qml +++ /dev/null @@ -1,42 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.abs(i1.p1) - property real test2: Math.abs(i1.p2) - - property int test3: Math.abs(i1.p3) - property int test4: Math.abs(i1.p4) - - property real subtest5: Math.abs() - property real subtest6: Math.abs(i1.p6) - property bool test5: isNaN(subtest5) - property bool test6: isNaN(subtest6) - - property real subtest7: Math.abs(i1.p7) - property bool test7: isNaN(subtest7) - property int test8: Math.abs(i1.p8) - - property real subtest9: Math.abs(i1.p9) - property real subtest10: Math.abs(i1.p10) - property bool test9: subtest9 === Number.POSITIVE_INFINITY - property bool test10: subtest10 === Number.POSITIVE_INFINITY - - property int test11: Math.abs(i1.p11) - property real subtest12: Math.abs(i1.p12) - property bool test12: subtest12 === 0 && (1/subtest12) === Infinity - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.5 - property int p3: 18 - property int p4: -72 - property real p6: Number.NaN - property string p7: "hello world" - property string p8: "82" - property real p9: Number.NEGATIVE_INFINITY - property real p10: Number.POSITIVE_INFINITY - property real p11: 0 - property real p12: -0 - } - } diff --git a/tests/auto/qml/v4/data/mathCeil.qml b/tests/auto/qml/v4/data/mathCeil.qml deleted file mode 100644 index 1f65066233..0000000000 --- a/tests/auto/qml/v4/data/mathCeil.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.ceil(i1.p1) - property real test2: Math.ceil(i1.p2) - - property real subtest3: Math.ceil() - property real subtest4: Math.ceil(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.ceil(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.ceil(i1.p6) - - property real subtest7: Math.ceil(i1.p7) - property real subtest8: Math.ceil(i1.p8) - property bool test7: subtest7 === Number.NEGATIVE_INFINITY - property bool test8: subtest8 === Number.POSITIVE_INFINITY - - property real test9: Math.ceil(i1.p9) - property real subtest10: Math.ceil(i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - property real subtest11: Math.ceil(i1.p11) - property bool test11: subtest11 === 0 && (1/subtest11) === -Infinity - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - property real p11: -0.5 - } - } diff --git a/tests/auto/qml/v4/data/mathCos.qml b/tests/auto/qml/v4/data/mathCos.qml deleted file mode 100644 index 44c47e9f15..0000000000 --- a/tests/auto/qml/v4/data/mathCos.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.cos(i1.p1) - property real test2: Math.cos(i1.p2) - - property real subtest3: Math.cos() - property real subtest4: Math.cos(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.cos(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.cos(i1.p6) - - property real subtest7: Math.cos(i1.p7) - property real subtest8: Math.cos(i1.p8) - property bool test7: isNaN(subtest7) - property bool test8: isNaN(subtest8) - - property real subtest9: Math.cos(i1.p9) - property bool test9: subtest9 === 1 - property real subtest10: Math.cos(i1.p10) - property bool test10: subtest10 === 1 - - property real subtest11: Math.PI / 6.66 - property real test11: Math.cos(subtest11) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - } - } diff --git a/tests/auto/qml/v4/data/mathFloor.qml b/tests/auto/qml/v4/data/mathFloor.qml deleted file mode 100644 index 3473dccd10..0000000000 --- a/tests/auto/qml/v4/data/mathFloor.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.floor(i1.p1) - property real test2: Math.floor(i1.p2) - - property real subtest3: Math.floor() - property real subtest4: Math.floor(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.floor(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.floor(i1.p6) - - property real subtest7: Math.floor(i1.p7) - property real subtest8: Math.floor(i1.p8) - property bool test7: subtest7 === Number.NEGATIVE_INFINITY - property bool test8: subtest8 === Number.POSITIVE_INFINITY - - property real test9: Math.floor(i1.p9) - property real subtest10: Math.floor(i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - } - } diff --git a/tests/auto/qml/v4/data/mathMax.qml b/tests/auto/qml/v4/data/mathMax.qml deleted file mode 100644 index cd8a88a3e7..0000000000 --- a/tests/auto/qml/v4/data/mathMax.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.max(i1.p1, i1.p2) - property real test2: Math.max(i1.p2, i1.p3) - - property real subtest3: Math.max() - property real subtest4: Math.max(i1.p4) - property bool test3: subtest3 === -Infinity - property bool test4: isNaN(subtest4) - - property real subtest5: Math.max(i1.p5, i1.p1) - property bool test5: isNaN(subtest5) - property real test6: Math.max(i1.p6, i1.p3) - - property real test7: Math.max(i1.p7, i1.p2) - property real subtest8: Math.max(i1.p8, i1.p2) - property bool test8: subtest8 === Number.POSITIVE_INFINITY - - property real subtest9: Math.max(i1.p10, i1.p9) - property bool test9: subtest9 === 0 && (1/subtest9) === Infinity - - // Reverse the inputs to Math.max - property real subtest10: Math.max(i1.p9, i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === Infinity - - property real test11: Math.max(i1.p11, i1.p1) - property real test12: Math.max(i1.p11, i1.p2) - property real test13: Math.max(i1.p1, i1.p2, i1.p3) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property int p3: 7 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - property var p11: null - } -} diff --git a/tests/auto/qml/v4/data/mathMin.qml b/tests/auto/qml/v4/data/mathMin.qml deleted file mode 100644 index 4ae5408b58..0000000000 --- a/tests/auto/qml/v4/data/mathMin.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.min(i1.p1, i1.p2) - property real test2: Math.min(i1.p2, i1.p3) - - property real subtest3: Math.min() - property real subtest4: Math.min(i1.p4) - property bool test3: subtest3 === Infinity - property bool test4: isNaN(subtest4) - - property real subtest5: Math.min(i1.p5, i1.p1) - property bool test5: isNaN(subtest5) - property real test6: Math.min(i1.p6, i1.p3) - - property real subtest7: Math.min(i1.p7, i1.p2) - property bool test7: subtest7 === Number.NEGATIVE_INFINITY - property real test8: Math.min(i1.p8, i1.p2) - - property real subtest9: Math.min(i1.p10, i1.p9) - property bool test9: subtest9 === 0 && (1/subtest9) === -Infinity - - // Reverse the inputs to Math.min - property real subtest10: Math.min(i1.p9, i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - property real test11: Math.min(i1.p11, i1.p1) - property real test12: Math.min(i1.p11, i1.p2) - property real test13: Math.min(i1.p1, i1.p2, i1.p3) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property int p3: 95 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - property var p11: null - } - } diff --git a/tests/auto/qml/v4/data/mathSin.qml b/tests/auto/qml/v4/data/mathSin.qml deleted file mode 100644 index c48ec03fee..0000000000 --- a/tests/auto/qml/v4/data/mathSin.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.sin(i1.p1) - property real test2: Math.sin(i1.p2) - - property real subtest3: Math.sin() - property real subtest4: Math.sin(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.sin(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.sin(i1.p6) - - property real subtest7: Math.sin(i1.p7) - property real subtest8: Math.sin(i1.p8) - property bool test7: isNaN(subtest7) - property bool test8: isNaN(subtest8) - - property real subtest9: Math.sin(i1.p9) - property bool test9: subtest9 === 0 && (1/subtest9) === Infinity - property real subtest10: Math.sin(i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - property real subtest11: Math.PI / 6.66 - property real test11: Math.sin(subtest11) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - } - } diff --git a/tests/auto/qml/v4/data/nestedLogicalAnd.qml b/tests/auto/qml/v4/data/nestedLogicalAnd.qml deleted file mode 100644 index 1358fcea64..0000000000 --- a/tests/auto/qml/v4/data/nestedLogicalAnd.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt.v4 1.0 - -Result { - property bool val1: false - property bool val2: true - property bool val3: false - - property bool b1: (true && true && false) - property bool b2: (true && (false && true)) - property bool b3: ((true && true) && true) - property bool b4: (val1 && (val2 && val3)) ? true : false - - result: !b1 && !b2 && b3 && !b4 -} diff --git a/tests/auto/qml/v4/data/nestedLogicalOr.qml b/tests/auto/qml/v4/data/nestedLogicalOr.qml deleted file mode 100644 index c4478a3e7b..0000000000 --- a/tests/auto/qml/v4/data/nestedLogicalOr.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt.v4 1.0 - -Result { - property bool val1: false - property bool val2: true - property bool val3: false - - property bool b1: (false || false || true) - property bool b2: (false || (false || true)) - property bool b3: ((false || false) || true) - property bool b4: (val1 || (val2 || val3)) ? true : false - - result: b1 && b2 && b3 && b4 -} diff --git a/tests/auto/qml/v4/data/nestedObjectAccess.qml b/tests/auto/qml/v4/data/nestedObjectAccess.qml deleted file mode 100644 index 56cd17e41e..0000000000 --- a/tests/auto/qml/v4/data/nestedObjectAccess.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - result: nested.result -} diff --git a/tests/auto/qml/v4/data/nestedObjectAccess2.qml b/tests/auto/qml/v4/data/nestedObjectAccess2.qml deleted file mode 100644 index 2f0e0db01c..0000000000 --- a/tests/auto/qml/v4/data/nestedObjectAccess2.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - result: nested2.result -} diff --git a/tests/auto/qml/v4/data/nullQObject.qml b/tests/auto/qml/v4/data/nullQObject.qml deleted file mode 100644 index 00185b3988..0000000000 --- a/tests/auto/qml/v4/data/nullQObject.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Item { - property QtObject obj - property QtObject test - test: obj -} diff --git a/tests/auto/qml/v4/data/objectToBool.qml b/tests/auto/qml/v4/data/objectToBool.qml deleted file mode 100644 index 8c8a67bee0..0000000000 --- a/tests/auto/qml/v4/data/objectToBool.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property QtObject prop1: null - property QtObject prop2: QtObject {} - - property bool test1: prop1 ? true : false - property bool test2: prop2 ? true : false - - property bool test3: prop1 == false - property bool test4: prop1 === false - - property bool test5: prop2 == false - property bool test6: prop2 === false -} - diff --git a/tests/auto/qml/v4/data/qrealToIntRounding.qml b/tests/auto/qml/v4/data/qrealToIntRounding.qml deleted file mode 100644 index ee3d405073..0000000000 --- a/tests/auto/qml/v4/data/qrealToIntRounding.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property int data: 1 - - property int test1: 6.6 + data - property int test2: 6.2 + data - property int test3: 6 + data -} - diff --git a/tests/auto/qml/v4/data/qtbug_21883.qml b/tests/auto/qml/v4/data/qtbug_21883.qml deleted file mode 100644 index a51f97c944..0000000000 --- a/tests/auto/qml/v4/data/qtbug_21883.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - property Result dummy: Result -} diff --git a/tests/auto/qml/v4/data/qtbug_22816.qml b/tests/auto/qml/v4/data/qtbug_22816.qml deleted file mode 100644 index bfa8d4948c..0000000000 --- a/tests/auto/qml/v4/data/qtbug_22816.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - QtObject { - id: object - property bool prop1: true - function myfunction() { return true; } - property bool prop2: object.prop1 && myfunction(); - } - - property bool test1: object.prop1 && object.prop2 - property bool test2: object.prop1 - - Component.onCompleted: { - object.prop1 = false; - } -} - diff --git a/tests/auto/qml/v4/data/singletonType.qml b/tests/auto/qml/v4/data/singletonType.qml deleted file mode 100644 index 3fcbcae64d..0000000000 --- a/tests/auto/qml/v4/data/singletonType.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt.test 1.0 as ModApi -import QtQuick 2.0 - -Item { - property int testProp: ModApi.V4.ip - property int testProp2: 2 - - function getRandom() { - testProp2 = ModApi.V4.random(); - // testProp should also have changed. - } -} diff --git a/tests/auto/qml/v4/data/strictEquals.qml b/tests/auto/qml/v4/data/strictEquals.qml deleted file mode 100644 index 503ca50454..0000000000 --- a/tests/auto/qml/v4/data/strictEquals.qml +++ /dev/null @@ -1,53 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property QtObject myprop1: null - property QtObject myprop2: QtObject {} - property real zero: 0 - property bool falseProp: false - - property bool test1: myprop1 === false - property bool test2: myprop1 === null - property bool test3: 5 === myprop1 - property bool test4: null === myprop1 - property bool test5: myprop1 !== false - property bool test6: myprop1 !== null - property bool test7: 5 !== myprop1 - property bool test8: null !== myprop1 - - property bool test9: myprop2 === false - property bool test10: myprop2 === null - property bool test11: 5 === myprop2 - property bool test12: null === myprop2 - property bool test13: myprop2 !== false - property bool test14: myprop2 !== null - property bool test15: 5 !== myprop2 - property bool test16: null !== myprop2 - - property bool test17: myprop1 === myprop1 - property bool test18: myprop1 !== myprop1 - property bool test19: myprop1 === myprop2 - property bool test20: myprop1 !== myprop2 - property bool test21: myprop2 === myprop2 - property bool test22: myprop2 !== myprop2 - - property bool test23: myprop1 === "hello" - property bool test24: myprop1 !== "hello" - property bool test25: myprop2 === "hello" - property bool test26: myprop2 !== "hello" - - property bool test27: falseProp === zero - property bool test28: falseProp !== zero - property bool test29: falseProp === 1 - property bool test30: falseProp !== 1 - property bool test31: true === zero - property bool test32: true !== zero - property bool test33: true === 1 - property bool test34: true !== 1 - - property bool test35: zero === 5.0 - property bool test36: zero !== 5.0 - property bool test37: zero === 1 - property bool test38: zero !== 1 -} - diff --git a/tests/auto/qml/v4/data/stringComparison.qml b/tests/auto/qml/v4/data/stringComparison.qml deleted file mode 100644 index d9eab5389e..0000000000 --- a/tests/auto/qml/v4/data/stringComparison.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property string string1: "aaba" - property string string2: "aa" - property string string3: "aaab" - property string string4: "c" - property string string5: string2 + string4 - - property bool test1: string1 > string2 - property bool test2: string2 < string1 - property bool test3: string1 > string3 - property bool test4: string3 < string1 - property bool test5: string1 < string4 - property bool test6: string4 > string1 - property bool test7: string1 < string5 - property bool test8: string5 > string1 - - property bool test9: string1 == "aaba" - property bool test10: string1 != "baa" - property bool test11: string1 === "aaba" - property bool test12: string1 !== "baa" - property bool test13: string4 == "c" - property bool test14: string4 != "d" - property bool test15: string4 === "c" - property bool test16: string4 !== "d" - property bool test17: string5 === "aac" - property bool test18: string5 !== "aad" - - property bool test19: string1 >= string2 - property bool test20: string2 <= string1 - property bool test21: string1 >= string3 - property bool test22: string3 <= string1 - property bool test23: string1 <= string4 - property bool test24: string4 >= string1 - property bool test25: string4 <= "c" - property bool test26: string4 >= "c" - property bool test27: string5 <= "aac" - property bool test28: string5 >= "aac" -} - diff --git a/tests/auto/qml/v4/data/subscriptions.1.qml b/tests/auto/qml/v4/data/subscriptions.1.qml deleted file mode 100644 index 607233819e..0000000000 --- a/tests/auto/qml/v4/data/subscriptions.1.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 400 - height: 400 - - property real targetHeight: menuItems.height + 1 - property real heightValue: if (1) menuItems.height //this must be v8? - property bool boolProp: menuItems.height > heightValue //this must be v4? - - Column { - id: menuItems - Item { height: 200; width: 10 } - } -} diff --git a/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml deleted file mode 100644 index a8e05eeda1..0000000000 --- a/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - id: thisTest - - property bool cond: true - property real a: 1 - property real result: cond ? a : a - - PropertyAction { running: true; target: thisTest; property: "a"; value: 2; } -} diff --git a/tests/auto/qml/v4/data/unaryMinus.qml b/tests/auto/qml/v4/data/unaryMinus.qml deleted file mode 100644 index 410654fc3c..0000000000 --- a/tests/auto/qml/v4/data/unaryMinus.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: -i1.p2 - property int test2: -i1.p2 - property real test3: -i1.p1 - property int test4: -i1.p1 - property real test5: -i1.p3 - property int test6: -i1.p3 - property real test7: -i1.p4 - property int test8: -i1.p4 - property real test9: -i1.p5 - property int test10: -i1.p5 - - QtObject { - id: i1 - property real p1: -3.7 - property int p2: 18 - property real p3: -3.3 - property int p4: -7 - property real p5: 4.4 - } - } - diff --git a/tests/auto/qml/v4/data/unaryPlus.qml b/tests/auto/qml/v4/data/unaryPlus.qml deleted file mode 100644 index cd5315a7cc..0000000000 --- a/tests/auto/qml/v4/data/unaryPlus.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: +i1.p2 - property int test2: +i1.p2 - property real test3: +i1.p1 - property int test4: +i1.p1 - property real test5: +i1.p3 - property int test6: +i1.p3 - property real test7: +i1.p4 - property int test8: +i1.p4 - property real test9: +i1.p5 - property int test10: +i1.p5 - - QtObject { - id: i1 - property real p1: -3.7 - property int p2: 18 - property real p3: -3.3 - property int p4: -7 - property real p5: 4.4 - } -} - diff --git a/tests/auto/qml/v4/data/unnecessaryReeval.qml b/tests/auto/qml/v4/data/unnecessaryReeval.qml deleted file mode 100644 index 48662d7a2d..0000000000 --- a/tests/auto/qml/v4/data/unnecessaryReeval.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 8 - property int b: 19 - result: (a == 8)?b:7 -} diff --git a/tests/auto/qml/v4/data/varHandling.qml b/tests/auto/qml/v4/data/varHandling.qml deleted file mode 100644 index c19e6a256f..0000000000 --- a/tests/auto/qml/v4/data/varHandling.qml +++ /dev/null @@ -1,67 +0,0 @@ -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/data/variantHandling.qml b/tests/auto/qml/v4/data/variantHandling.qml deleted file mode 100644 index 3d48eef57e..0000000000 --- a/tests/auto/qml/v4/data/variantHandling.qml +++ /dev/null @@ -1,67 +0,0 @@ -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 variant - property variant pBoolVar: pBool - property variant pIntVar: pInt - property variant pRealVar: pReal - property variant pStringVar: pString - property variant pUrlVar: pUrl - property variant pColorVar: pColor - property variant pObjectVar: pObject - property variant pNullVar: null - property variant 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 variantConversionSuccess: (pVarVar == comparisonUrl) - - // Operations are not handled by V4 - they should pass through correctly - property variant pVarNot: !pBoolVar - property variant pVarComplement: ~pIntVar - property variant pVarEqual: (pBoolVar == pBoolVar) - property variant pVarLiteralEqual: (pBoolVar == true) - property variant pVarUnequal: (pUrlVar == pColorVar) - property variant pVarComparison: (pIntVar <= pIntVar) - property variant 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 (!variantConversionSuccess) console.warn('QV4: variant conversion failed'); - if (pVarNot != false) console.warn('QV4: variant negation impeded'); - if (pVarComplement != ~666) console.warn('QV4: variant complement impeded'); - if (pVarEqual != true) console.warn('QV4: variant equality impeded'); - if (pVarLiteralEqual != true) console.warn('QV4: variant/literal equality impeded'); - if (pVarUnequal != false) console.warn('QV4: variant unequality impeded'); - if (pVarComparison != true) console.warn('QV4: variant comparison impeded'); - if (pVarShift != 333) console.warn('QV4: variant shift impeded'); - } -} diff --git a/tests/auto/qml/v4/testtypes.cpp b/tests/auto/qml/v4/testtypes.cpp deleted file mode 100644 index ba81e591fc..0000000000 --- a/tests/auto/qml/v4/testtypes.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "testtypes.h" - -#include <QtQml/qqml.h> - -void registerTypes() -{ - qmlRegisterType<ResultObject>("Qt.v4", 1,0, "Result"); - qmlRegisterType<NestedObject>(); - qmlRegisterType<ConversionObject>("Qt.v4", 1, 0, "Conversion"); - qmlRegisterType<JSValueTest>("Qt.v4", 1, 0, "JSValueTest"); -} diff --git a/tests/auto/qml/v4/testtypes.h b/tests/auto/qml/v4/testtypes.h deleted file mode 100644 index ee516f2927..0000000000 --- a/tests/auto/qml/v4/testtypes.h +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QVector3D> -#include <QJSValue> - -class NestedObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int dummy READ dummy); - Q_PROPERTY(int result READ result FINAL CONSTANT); - -public: - int dummy() const { return 7; } - int result() const { return 37; } -}; - -class ResultObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int result READ result WRITE setResult FINAL) - Q_PROPERTY(NestedObject *nested READ nested CONSTANT) - Q_PROPERTY(NestedObject *nested2 READ nested2 FINAL CONSTANT) -public: - ResultObject() : m_result(0), m_resultCounter(0) {} - - int resultCounter() const { return m_resultCounter; } - void resetResultCounter() { m_resultCounter = 0; } - - int result() const { return m_result; } - void setResult(int result) { m_result = result; m_resultCounter++; } - - NestedObject *nested() { return &m_nested; } - NestedObject *nested2() { return &m_nested2; } - -private: - int m_result; - int m_resultCounter; - - NestedObject m_nested; - NestedObject m_nested2; -}; - -class ConversionObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool boolProp READ boolProp WRITE setBoolProp NOTIFY boolPropChanged) - Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged) - Q_PROPERTY(float floatProp READ floatProp WRITE setFloatProp NOTIFY floatPropChanged) - Q_PROPERTY(double doubleProp READ doubleProp WRITE setDoubleProp NOTIFY doublePropChanged) - Q_PROPERTY(qreal qrealProp READ qrealProp WRITE setQrealProp NOTIFY qrealPropChanged) - Q_PROPERTY(QString qstringProp READ qstringProp WRITE setQstringProp NOTIFY qstringPropChanged) - Q_PROPERTY(QUrl qurlProp READ qurlProp WRITE setQurlProp NOTIFY qurlPropChanged) - Q_PROPERTY(QVector3D vec3Prop READ vec3Prop WRITE setVec3Prop NOTIFY vec3PropChanged) - Q_PROPERTY(QJSValue jsvalueProp READ jsvalueProp WRITE setJsvalueProp NOTIFY jsvaluePropChanged) - -public: - ConversionObject() : m_boolProp(false), m_intProp(0), m_floatProp(0.0), m_doubleProp(0.0), m_qrealProp(0.0) {} - ~ConversionObject() {} - - bool boolProp() const { return m_boolProp; } - void setBoolProp(bool v) { m_boolProp = v; emit boolPropChanged(); } - int intProp() const { return m_intProp; } - void setIntProp(int v) { m_intProp = v; emit intPropChanged(); } - float floatProp() const { return m_floatProp; } - void setFloatProp(float v) { m_floatProp = v; emit floatPropChanged(); } - double doubleProp() const { return m_doubleProp; } - void setDoubleProp(double v) { m_doubleProp = v; emit doublePropChanged(); } - qreal qrealProp() const { return m_qrealProp; } - void setQrealProp(qreal v) { m_qrealProp = v; emit qrealPropChanged(); } - QString qstringProp() const { return m_qstringProp; } - void setQstringProp(const QString& v) { m_qstringProp = v; emit qstringPropChanged(); } - QUrl qurlProp() const { return m_qurlProp; } - void setQurlProp(const QUrl& v) { m_qurlProp = v; emit qurlPropChanged(); } - QVector3D vec3Prop() const { return m_vec3Prop; } - void setVec3Prop(const QVector3D& v) { m_vec3Prop = v; emit vec3PropChanged(); } - QJSValue jsvalueProp() const { return m_jsvalueProp; } - void setJsvalueProp(const QJSValue &v) { m_jsvalueProp = v; emit jsvaluePropChanged(); } - -signals: - void boolPropChanged(); - void intPropChanged(); - void floatPropChanged(); - void doublePropChanged(); - void qrealPropChanged(); - void qstringPropChanged(); - void qurlPropChanged(); - void vec3PropChanged(); - void jsvaluePropChanged(); - -private: - bool m_boolProp; - int m_intProp; - float m_floatProp; - double m_doubleProp; - qreal m_qrealProp; - QString m_qstringProp; - QUrl m_qurlProp; - QVector3D m_vec3Prop; - QJSValue m_jsvalueProp; -}; - -class JSValueTest : public QObject -{ - Q_OBJECT - Q_PROPERTY(QJSValue boolVar READ boolVar WRITE setBoolVar NOTIFY boolVarChanged) - Q_PROPERTY(QJSValue intVar READ intVar WRITE setIntVar NOTIFY intVarChanged) - Q_PROPERTY(QJSValue realVar READ realVar WRITE setRealVar NOTIFY realVarChanged) - Q_PROPERTY(QJSValue stringVar READ stringVar WRITE setStringVar NOTIFY stringVarChanged) - Q_PROPERTY(QJSValue urlVar READ urlVar WRITE setUrlVar NOTIFY urlVarChanged) - Q_PROPERTY(QJSValue colorVar READ colorVar WRITE setColorVar NOTIFY colorVarChanged) - Q_PROPERTY(QJSValue objectVar READ objectVar WRITE setObjectVar NOTIFY objectVarChanged) - Q_PROPERTY(QJSValue nullVar READ nullVar WRITE setNullVar NOTIFY nullVarChanged) - Q_PROPERTY(QJSValue varVar READ varVar WRITE setVarVar NOTIFY varVarChanged) - -public: - JSValueTest() {} - ~JSValueTest() {} - - QJSValue boolVar() const { return m_boolVar; } - void setBoolVar(const QJSValue &v) { m_boolVar = v; emit boolVarChanged(); } - - QJSValue intVar() const { return m_intVar; } - void setIntVar(const QJSValue &v) { m_intVar = v; emit intVarChanged(); } - - QJSValue realVar() const { return m_realVar; } - void setRealVar(const QJSValue &v) { m_realVar = v; emit realVarChanged(); } - - QJSValue stringVar() const { return m_stringVar; } - void setStringVar(const QJSValue &v) { m_stringVar = v; emit stringVarChanged(); } - - QJSValue urlVar() const { return m_urlVar; } - void setUrlVar(const QJSValue &v) { m_urlVar = v; emit urlVarChanged(); } - - QJSValue colorVar() const { return m_colorVar; } - void setColorVar(const QJSValue &v) { m_colorVar = v; emit colorVarChanged(); } - - QJSValue objectVar() const { return m_objectVar; } - void setObjectVar(const QJSValue &v) { m_objectVar = v; emit objectVarChanged(); } - - QJSValue nullVar() const { return m_nullVar; } - void setNullVar(const QJSValue &v) { m_nullVar = v; emit nullVarChanged(); } - - QJSValue varVar() const { return m_varVar; } - void setVarVar(const QJSValue &v) { m_varVar = v; emit varVarChanged(); } - -signals: - void boolVarChanged(); - void intVarChanged(); - void realVarChanged(); - void stringVarChanged(); - void urlVarChanged(); - void colorVarChanged(); - void objectVarChanged(); - void nullVarChanged(); - void varVarChanged(); - -private: - QJSValue m_boolVar; - QJSValue m_intVar; - QJSValue m_realVar; - QJSValue m_stringVar; - QJSValue m_urlVar; - QJSValue m_colorVar; - QJSValue m_objectVar; - QJSValue m_nullVar; - QJSValue m_varVar; -}; - -void registerTypes(); - -#endif // TESTTYPES_H - diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp deleted file mode 100644 index e08bccd016..0000000000 --- a/tests/auto/qml/v4/tst_v4.cpp +++ /dev/null @@ -1,1125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtest.h> -#include <QtCore/qobject.h> -#include <QtCore/qfileinfo.h> -#include <QtCore/qdir.h> -#include <QtQml/qqmlengine.h> -#include <QtQml/qqmlcomponent.h> -#include <QtCore/qdebug.h> -#include <QtGui/qcolor.h> -#include <QtCore/qnumeric.h> - -#include <private/qv4compiler_p.h> - -#include "../../shared/util.h" -#include "testtypes.h" - -class tst_v4 : public QQmlDataTest -{ - Q_OBJECT -public: - tst_v4() {} - -private slots: - void initTestCase(); - - void unnecessaryReeval(); - void logicalOr(); - void nestedLogicalOr(); - void logicalAnd(); - void nestedLogicalAnd(); - void conditionalExpr(); - void qtscript(); - void qtscript_data(); - void nestedObjectAccess(); - void subscriptionsInConditionalExpressions(); - void qtbug_21883(); - void qtbug_22816(); - void stringComparison(); - void unaryMinus(); - void unaryPlus(); - void colorType(); - void mathAbs(); - void mathCeil(); - void mathFloor(); - void mathMax(); - void mathMin(); - void mathCos(); - void mathSin(); - void singletonType(); - void integerOperations(); - - void conversions_data(); - void conversions(); - void subscriptions(); - - void debuggingDumpInstructions(); // this test should be last. - -private: - QQmlEngine engine; -}; - -void tst_v4::initTestCase() -{ - QQmlDataTest::initTestCase(); - registerTypes(); -} - -void tst_v4::qtscript() -{ - QFETCH(QString, file); - QV4Compiler::enableBindingsTest(true); - - QQmlComponent component(&engine, testFileUrl(file)); - - QQmlTestMessageHandler messageHandler; - - QObject *o = component.create(); - delete o; - - QEXPECT_FAIL("jsvalueHandling", "QTBUG-26951 - QJSValue has a different representation of NULL to QV8Engine", Continue); - const int v4ErrorCount = messageHandler.messages().filter(QLatin1String("QV4")).size(); - QVERIFY2(v4ErrorCount == 0, qPrintable(messageHandler.messageString())); - - QV4Compiler::enableBindingsTest(false); -} - -void tst_v4::qtscript_data() -{ - QTest::addColumn<QString>("file"); - - QTest::newRow("equals") << "equals.qml"; - QTest::newRow("strict equals") << "strictEquals.qml"; - QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml"; - QTest::newRow("exception on fetch") << "fetchException.qml"; - QTest::newRow("logical or") << "logicalOr.qml"; - QTest::newRow("conditional expressions") << "conditionalExpr.qml"; - QTest::newRow("double bool jump") << "doubleBoolJump.qml"; - QTest::newRow("unary minus") << "unaryMinus.qml"; - QTest::newRow("null qobject") << "nullQObject.qml"; - QTest::newRow("qobject -> bool") << "objectToBool.qml"; - QTest::newRow("conversion from bool") << "conversions.1.qml"; - QTest::newRow("conversion from int") << "conversions.2.qml"; - QTest::newRow("conversion from float") << "conversions.3.qml"; - QTest::newRow("conversion from double") << "conversions.4.qml"; - QTest::newRow("conversion from real") << "conversions.5.qml"; - QTest::newRow("conversion from string") << "conversions.6.qml"; - QTest::newRow("conversion from url") << "conversions.7.qml"; - QTest::newRow("conversion from vec3") << "conversions.8.qml"; - QTest::newRow("variantHandling") << "variantHandling.qml"; - QTest::newRow("varHandling") << "varHandling.qml"; - QTest::newRow("jsvalueHandling") << "jsvalueHandling.qml"; - QTest::newRow("integerOperations") << "integerOperations.qml"; -} - -void tst_v4::unnecessaryReeval() -{ - QQmlComponent component(&engine, testFileUrl("unnecessaryReeval.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 19); - ro->resetResultCounter(); - - ro->setProperty("b", 6); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 6); - ro->resetResultCounter(); - - ro->setProperty("a", 14); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 7); - ro->resetResultCounter(); - - ro->setProperty("b", 14); - QCOMPARE(ro->resultCounter(), 0); - QCOMPARE(ro->result(), 7); - - delete o; -} - -void tst_v4::logicalOr() -{ - { - QQmlComponent component(&engine, testFileUrl("logicalOr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalOr.2.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } -} - -void tst_v4::nestedLogicalOr() -{ - //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038) - QQmlComponent component(&engine, testFileUrl("nestedLogicalOr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; -} - -void tst_v4::logicalAnd() -{ - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.2.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.3.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - // QTBUG-24660 - QQmlComponent component(&engine, testFileUrl("logicalAnd.4.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.5.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.6.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.7.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } -} - -void tst_v4::nestedLogicalAnd() -{ - QQmlComponent component(&engine, testFileUrl("nestedLogicalAnd.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; -} - -void tst_v4::conditionalExpr() -{ - { - QQmlComponent component(&engine, testFileUrl("conditionalExpr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } -} - -// This would previously use the metaObject of the root element to result the nested access. -// That is, the index for accessing "result" would have been RootObject::result, instead of -// NestedObject::result. -void tst_v4::nestedObjectAccess() -{ - { - QQmlComponent component(&engine, testFileUrl("nestedObjectAccess.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 37); - - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("nestedObjectAccess2.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 37); - - delete o; - } -} - -void tst_v4::subscriptionsInConditionalExpressions() -{ - QQmlComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QObject *ro = qobject_cast<QObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->property("result").toReal(), qreal(2)); - - delete o; -} - -// Crash test -void tst_v4::qtbug_21883() -{ - QQmlComponent component(&engine, testFileUrl("qtbug_21883.qml")); - - QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*"; - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); - - QObject *o = component.create(); - QVERIFY(o != 0); - delete o; -} - -void tst_v4::qtbug_22816() -{ - QQmlComponent component(&engine, testFileUrl("qtbug_22816.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").toBool(), false); - QCOMPARE(o->property("test2").toBool(), false); - delete o; -} - -void tst_v4::stringComparison() -{ - QQmlComponent component(&engine, testFileUrl("stringComparison.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toBool(), true); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toBool(), true); - QCOMPARE(o->property("test12").toBool(), true); - QCOMPARE(o->property("test13").toBool(), true); - QCOMPARE(o->property("test14").toBool(), true); - QCOMPARE(o->property("test15").toBool(), true); - QCOMPARE(o->property("test16").toBool(), true); - QCOMPARE(o->property("test17").toBool(), true); - QCOMPARE(o->property("test18").toBool(), true); - QCOMPARE(o->property("test19").toBool(), true); - QCOMPARE(o->property("test20").toBool(), true); - QCOMPARE(o->property("test21").toBool(), true); - QCOMPARE(o->property("test22").toBool(), true); - delete o; -} - -void tst_v4::unaryMinus() -{ - QQmlComponent component(&engine, testFileUrl("unaryMinus.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-18)); - QCOMPARE(o->property("test2").toInt(), -18); - QCOMPARE(o->property("test3").toReal(), qreal(3.7)); - QCOMPARE(o->property("test4").toInt(), 4); - QCOMPARE(o->property("test5").toReal(), qreal(3.3)); - QCOMPARE(o->property("test6").toInt(), 3); - QCOMPARE(o->property("test7").toReal(), qreal(7)); - QCOMPARE(o->property("test8").toInt(), 7); - QCOMPARE(o->property("test9").toReal(), qreal(-4.4)); - QCOMPARE(o->property("test10").toInt(), -4); - - delete o; -} - -void tst_v4::unaryPlus() -{ - QQmlComponent component(&engine, testFileUrl("unaryPlus.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(18)); - QCOMPARE(o->property("test2").toInt(), 18); - QCOMPARE(o->property("test3").toReal(), qreal(-3.7)); - QCOMPARE(o->property("test4").toInt(), -4); - QCOMPARE(o->property("test5").toReal(), qreal(-3.3)); - QCOMPARE(o->property("test6").toInt(), -3); - QCOMPARE(o->property("test7").toReal(), qreal(-7)); - QCOMPARE(o->property("test8").toInt(), -7); - QCOMPARE(o->property("test9").toReal(), qreal(4.4)); - QCOMPARE(o->property("test10").toInt(), 4); - - delete o; -} - -void tst_v4::colorType() -{ - QQmlComponent component(&engine, testFileUrl("colorType.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").value<QColor>(), QColor("red")); - QCOMPARE(o->property("test2").value<QColor>(), QColor("red")); - QCOMPARE(o->property("test3").value<QColor>(), QColor("red")); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toBool(), true); - QCOMPARE(o->property("test7").toBool(), true); - delete o; -} - -void tst_v4::mathAbs() -{ - QQmlComponent component(&engine, testFileUrl("mathAbs.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(3.7)); - QCOMPARE(o->property("test2").toReal(), qreal(4.5)); - QCOMPARE(o->property("test3").toInt(), 18); - QCOMPARE(o->property("test4").toInt(), 72); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toBool(), true); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toInt(), 82); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toInt(), 0); - QCOMPARE(o->property("test12").toBool(), true); - - delete o; -} - -void tst_v4::mathCeil() -{ - QQmlComponent component(&engine, testFileUrl("mathCeil.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-3)); - QCOMPARE(o->property("test2").toReal(), qreal(5)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(83)); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toInt(), 0); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toBool(), true); - - delete o; -} - -void tst_v4::mathFloor() -{ - QQmlComponent component(&engine, testFileUrl("mathFloor.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-4)); - QCOMPARE(o->property("test2").toReal(), qreal(4)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(82)); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toInt(), 0); - QCOMPARE(o->property("test10").toBool(), true); - - delete o; -} - -void tst_v4::mathMax() -{ - QQmlComponent component(&engine, testFileUrl("mathMax.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(4.4)); - QCOMPARE(o->property("test2").toReal(), qreal(7)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(82.6)); - QCOMPARE(o->property("test7").toReal(), qreal(4.4)); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toReal(), qreal(0)); - QCOMPARE(o->property("test12").toReal(), qreal(4.4)); - QCOMPARE(o->property("test13").toReal(), qreal(7)); - - delete o; -} - -void tst_v4::mathMin() -{ - QQmlComponent component(&engine, testFileUrl("mathMin.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-3.7)); - QCOMPARE(o->property("test2").toReal(), qreal(4.4)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(82.6)); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toReal(), qreal(4.4)); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toReal(), qreal(-3.7)); - QCOMPARE(o->property("test12").toReal(), qreal(0)); - QCOMPARE(o->property("test13").toReal(), qreal(-3.7)); - delete o; -} - -static bool fuzzyCompare(qreal a, qreal b) -{ - const qreal EPSILON = 0.0001; - return (a + EPSILON > b) && (a - EPSILON < b); -} - -void tst_v4::mathCos() -{ - QQmlComponent component(&engine, testFileUrl("mathCos.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QVERIFY(fuzzyCompare(o->property("test1").toReal(), qreal(-0.848100))); - QVERIFY(fuzzyCompare(o->property("test2").toReal(), qreal(-0.307333))); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test6").toReal(), qreal(0.606941))); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test11").toReal(), qreal(0.890792))); - - delete o; -} - -void tst_v4::mathSin() -{ - QQmlComponent component(&engine, testFileUrl("mathSin.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QVERIFY(fuzzyCompare(o->property("test1").toReal(), qreal(0.529836))); - QVERIFY(fuzzyCompare(o->property("test2").toReal(), qreal(-0.951602))); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test6").toReal(), qreal(0.794747))); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test11").toReal(), qreal(0.454411))); - - delete o; -} - -void tst_v4::integerOperations() -{ - QQmlComponent component(&engine, testFileUrl("integerOperations.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("testa1").toInt(), 333); - QCOMPARE(o->property("testa2").toInt(), -666); - - QCOMPARE(o->property("testb1").toInt(), 0); - QCOMPARE(o->property("testb2").toInt(), 2); - QCOMPARE(o->property("testb3").toInt(), 0); - QCOMPARE(o->property("testb4").toInt(), 2); - QCOMPARE(o->property("testb5").toInt(), 0); - QCOMPARE(o->property("testb6").toInt(), 2); - QCOMPARE(o->property("testb7").toInt(), 0); - QCOMPARE(o->property("testb8").toInt(), 2); - - QCOMPARE(o->property("testc1").toInt(), 335); - QCOMPARE(o->property("testc2").toInt(), -666); - QCOMPARE(o->property("testc3").toInt(), 335); - QCOMPARE(o->property("testc4").toInt(), -666); - QCOMPARE(o->property("testc5").toInt(), 335); - QCOMPARE(o->property("testc6").toInt(), -666); - QCOMPARE(o->property("testc7").toInt(), 335); - QCOMPARE(o->property("testc8").toInt(), -666); - - QCOMPARE(o->property("testd1").toInt(), 330); - QCOMPARE(o->property("testd2").toInt(), 330); - QCOMPARE(o->property("testd3").toInt(), 330); - QCOMPARE(o->property("testd4").toInt(), 330); - - QCOMPARE(o->property("teste1").toInt(), 28); - QCOMPARE(o->property("teste2").toInt(), -28); - QCOMPARE(o->property("teste3").toInt(), 256); - QCOMPARE(o->property("teste4").toInt(), 28); - QCOMPARE(o->property("teste5").toInt(), -28); - QCOMPARE(o->property("teste6").toInt(), 256); - - QCOMPARE(o->property("testf1").toInt(), 1); - QCOMPARE(o->property("testf2").toInt(), -2); - QCOMPARE(o->property("testf3").toInt(), 0); - QCOMPARE(o->property("testf4").toInt(), 1); - QCOMPARE(o->property("testf5").toInt(), -2); - QCOMPARE(o->property("testf6").toInt(), 0); - - QCOMPARE(o->property("testg1").toInt(), 1); - QCOMPARE(o->property("testg2").toInt(), 0x3FFFFFFE); - QCOMPARE(o->property("testg3").toInt(), 0); - QCOMPARE(o->property("testg4").toInt(), 1); - QCOMPARE(o->property("testg5").toInt(), 0x3FFFFFFE); - QCOMPARE(o->property("testg6").toInt(), 0); - - delete o; -} - -class V4SingletonType : public QObject -{ - Q_OBJECT - Q_PROPERTY(int ip READ ip WRITE setIp NOTIFY ipChanged FINAL) -public: - V4SingletonType() : m_ip(12) {} - ~V4SingletonType() {} - - Q_INVOKABLE int random() { static int prng = 3; prng++; m_ip++; emit ipChanged(); return prng; } - - int ip() const { return m_ip; } - void setIp(int v) { m_ip = v; emit ipChanged(); } - -signals: - void ipChanged(); - -private: - int m_ip; -}; - -static QObject *v4_module_api_factory(QQmlEngine*, QJSEngine*) -{ - return new V4SingletonType; -} - -void tst_v4::singletonType() -{ - // register singleton type, providing typeinfo via template - qmlRegisterSingletonType<V4SingletonType>("Qt.test", 1, 0, "V4", v4_module_api_factory); - QQmlComponent component(&engine, testFileUrl("singletonType.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("testProp").toInt(), 12); - QCOMPARE(o->property("testProp2").toInt(), 2); - QMetaObject::invokeMethod(o, "getRandom"); - QCOMPARE(o->property("testProp").toInt(), 13); - QCOMPARE(o->property("testProp2").toInt(), 4); - delete o; -} - -void tst_v4::conversions_data() -{ - QTest::addColumn<QUrl>("file"); - QTest::addColumn<QStringList>("warnings"); - QTest::addColumn<bool>("boolProp"); - QTest::addColumn<int>("intProp"); - QTest::addColumn<float>("floatProp"); - QTest::addColumn<double>("doubleProp"); - QTest::addColumn<qreal>("qrealProp"); - QTest::addColumn<QString>("qstringProp"); - QTest::addColumn<QUrl>("qurlProp"); - QTest::addColumn<QVector3D>("vec3Prop"); - - QTest::newRow("from bool") << testFileUrl("conversions.1.qml") - << (QStringList() << (testFileUrl("conversions.1.qml").toString() + QLatin1String(":11:15: Unable to assign bool to QUrl"))) - << true - << (int)true - << (float)1.0 - << (double)1.0 - << (qreal)1.0 - << QString(QLatin1String("true")) - << QUrl() // cannot assign bool to url. - << QVector3D(1, 1, 1); - - QTest::newRow("from integer") << testFileUrl("conversions.2.qml") - << (QStringList() << (testFileUrl("conversions.2.qml").toString() + QLatin1String(":11:15: Unable to assign int to QUrl"))) - << (bool)4 - << 4 - << (float)4.0 - << (double)4.0 - << (qreal)4.0 - << QString(QLatin1String("4")) - << QUrl() // cannot assign int to url. - << QVector3D(4, 4, 4); - - QTest::newRow("from float") << testFileUrl("conversions.3.qml") - << (QStringList() << (testFileUrl("conversions.3.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) - << (bool)4.4 - << (int)4.4 - << (float)4.4 - << (double)((float)4.4) - << (qreal)((float)4.4) - << QString::number((double)((float)4.4), 'g', 16) - << QUrl() // cannot assign number to url. - << QVector3D(4.4, 4.4, 4.4); - - QTest::newRow("from double") << testFileUrl("conversions.4.qml") - << (QStringList() << (testFileUrl("conversions.4.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) - << (bool)4.444444444 - << (int)4.444444444 - << (float)4.444444444 - << (double)4.444444444 - << (qreal)4.444444444 - << QString::number((double)4.444444444, 'g', 16) - << QUrl() // cannot assign number to url. - << QVector3D(4.444444444, 4.444444444, 4.444444444); - - QTest::newRow("from qreal") << testFileUrl("conversions.5.qml") - << (QStringList() << (testFileUrl("conversions.5.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) - << (bool)4.44 - << (int)4.44 - << (float)4.44 - << (double)4.44 - << (qreal)4.44 - << QString(QLatin1String("4.44")) - << QUrl() // cannot assign number to url. - << QVector3D(4.44, 4.44, 4.44); - - QTest::newRow("from string") << testFileUrl("conversions.6.qml") - << (QStringList()) - << true - << 4 - << (float)4.0 - << (double)4.0 - << (qreal)4.0 - << QString(QLatin1String("4")) - << QUrl(testFileUrl("").toString() + QString(QLatin1String("4"))) - << QVector3D(4, 4, 4); - - QTest::newRow("from url") << testFileUrl("conversions.7.qml") - << (QStringList() << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":6:14: Unable to assign QUrl to int")) - << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":7:16: Unable to assign QUrl to number")) - << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":8:17: Unable to assign QUrl to number")) - << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":9:16: Unable to assign QUrl to number"))) - << true - << 0 - << (float) 0 - << (double) 0 - << (qreal) 0 - << QString(testFileUrl("").toString() + QString(QLatin1String("4"))) - << QUrl(testFileUrl("").toString() + QString(QLatin1String("4"))) - << QVector3D(qQNaN(), qQNaN(), qQNaN()); - - QTest::newRow("from vector") << testFileUrl("conversions.8.qml") - << (QStringList() << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":11: Unable to assign QVector3D to QUrl")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":10: Unable to assign QVector3D to QString")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":9: Unable to assign QVector3D to double")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":8: Unable to assign QVector3D to double")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":7: Unable to assign QVector3D to float")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":6: Unable to assign QVector3D to int"))) - << true // non-null therefore true - << (int)0 // the other values should be the default-ctor values. - << (float)0 - << (double)0 - << (qreal)0 - << QString() - << QUrl() - << QVector3D(4, 4, 4); // except this one. -} - -#define COMPARE_NUMBER(type, prop, expected) \ - if (qIsNaN(expected)) \ - QVERIFY(qIsNaN(qvariant_cast<type>(prop))); \ - else \ - QCOMPARE((prop), QVariant::fromValue<type>(expected)); - -void tst_v4::conversions() -{ - QFETCH(QUrl, file); - QFETCH(QStringList, warnings); - QFETCH(bool, boolProp); - QFETCH(int, intProp); - QFETCH(float, floatProp); - QFETCH(double, doubleProp); - QFETCH(qreal, qrealProp); - QFETCH(QString, qstringProp); - QFETCH(QUrl, qurlProp); - QFETCH(QVector3D, vec3Prop); - - foreach (const QString &w, warnings) - QTest::ignoreMessage(QtWarningMsg, qPrintable(w)); - - QQmlComponent component(&engine, file); - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("boolProp"), QVariant::fromValue<bool>(boolProp)); - QCOMPARE(o->property("intProp"), QVariant::fromValue<int>(intProp)); - COMPARE_NUMBER(float, o->property("floatProp"), floatProp); - COMPARE_NUMBER(double, o->property("doubleProp"), doubleProp); - COMPARE_NUMBER(qreal, o->property("qrealProp"), qrealProp); - QCOMPARE(o->property("qstringProp"), QVariant::fromValue<QString>(qstringProp)); - QCOMPARE(o->property("qurlProp"), QVariant::fromValue<QUrl>(qurlProp)); - - QVector3D vec3 = qvariant_cast<QVector3D>(o->property("vec3Prop")); - COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.x()), vec3Prop.x()); - COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.y()), vec3Prop.y()); - COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.z()), vec3Prop.z()); - delete o; -} - -void tst_v4::subscriptions() -{ - { - QQmlComponent component(&engine, testFileUrl("subscriptions.1.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QObject *ro = qobject_cast<QObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->property("targetHeight"), QVariant::fromValue<qreal>(201)); - - delete o; - } -} - -static QByteArray getAddress(int address) -{ - return QByteArray::number(address); -} - -static QByteArray getLeading(int address) -{ - QByteArray leading; - if (address != -1) { - leading = getAddress(address); - leading.prepend(QByteArray(8 - leading.count(), ' ')); - } - return leading; -} - -#include <private/qv4instruction_p.h> -void tst_v4::debuggingDumpInstructions() -{ - QStringList expectedPreAddress; - expectedPreAddress << "\t\tNoop"; - expectedPreAddress << "\t0:0:"; - expectedPreAddress << "\t\tSubscribeId\t\tId_Offset(0) -> Subscribe_Slot(0)"; - expectedPreAddress << "\t\tFetchAndSubscribe\tObject_Reg(0) Fast_Accessor(0x0) -> Output_Reg(0) Subscription_Slot(0)"; - expectedPreAddress << "\t\tLoadId\t\t\tId_Offset(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadScope\t\t-> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadRoot\t\t-> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadSingletonObject\t\t) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadAttached\t\tObject_Reg(0) Attached_Index(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryNot\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryMinusNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryMinusInt\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryPlusNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryPlusInt\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToInt\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - 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\tConvertIntToJSValue\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\tConvertJSValueToVar\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\tConvertNumberToJSValue\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\tConvertStringToJSValue\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\tConvertUrlToJSValue\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\tConvertColorToJSValue\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\tConvertObjectToJSValue\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\tConvertVarToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNullToJSValue\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)"; - expectedPreAddress << "\t\tMathAbsNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathRoundNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathFloorNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathCeilNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathPINumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadNull\t\tConstant(null) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadNumber\t\tConstant(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadInt\t\t\tConstant(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadBool\t\tConstant(false) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadString\t\tString_DataIndex(0) String_Length(0) -> Output_Register(0)"; - expectedPreAddress << "\t\tEnableV4Test\t\tString_DataIndex(0) String_Length(0)"; - expectedPreAddress << "\t\tTestV4Store\t\tInput_Reg(0) Reg_Type(0)"; - expectedPreAddress << "\t\tBitAndInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tBitOrInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tBitXorInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tAddNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tAddString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tSubNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMulNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tDivNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tModNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tRShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tURShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGtNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLtNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGeNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLeNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNotEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictNotEqualNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGtString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLtString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGeString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLeString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tEqualString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNotEqualString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictEqualString\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictNotEqualString\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tEqualObject\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNotEqualObject\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictEqualObject\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictNotEqualObject\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathMaxNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathMinNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNewString\t\tRegister(0)"; - expectedPreAddress << "\t\tNewUrl\t\t\tRegister(0)"; - expectedPreAddress << "\t\tCleanupRegister\t\tRegister(0)"; - expectedPreAddress << "\t\tCopy\t\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tFetch\t\t\tObject_Reg(0) Property_Index(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStore\t\t\tInput_Reg(0) -> Object_Reg(0) Property_Index(0)"; - expectedPreAddress << "\t\tJump\t\t\tAddress(UNIT_TEST_JUMP_ADDRESS) [if false == Input_Reg(0)]"; //(address + size() + i->jump.count) - expectedPreAddress << "\t\tBranchTrue\t\tAddress(UNIT_TEST_BRANCH_ADDRESS) [if true == Input_Reg(0)]"; //(address + size() + i->branchop.offset) - expectedPreAddress << "\t\tBranchFalse\t\tAddress(UNIT_TEST_BRANCH_ADDRESS) [if false == Input_Reg(0)]"; //(address + size() + i->branchop.offset) - expectedPreAddress << "\t\tBranch\t\t\tAddress(UNIT_TEST_BRANCH_ADDRESS)"; //(address + size() + i->branchop.offset) - expectedPreAddress << "\t\tBlock\t\t\tMask(0)"; - expectedPreAddress << "\t\tThrow\t\t\tInputReg(0)"; - expectedPreAddress << "\t\tInitString\t\tString_DataIndex(0) -> String_Slot(0)"; - QStringList expected; - - QQmlTestMessageHandler messageHandler; - - QQmlJS::Bytecode bc; -#define DUMP_INSTR_IN_UNIT_TEST(I, FMT) { QQmlJS::V4InstrData<QQmlJS::V4Instr::I> i; memset(&i, 0, sizeof(i)); bc.append(i); } - FOR_EACH_V4_INSTR(DUMP_INSTR_IN_UNIT_TEST); -#undef DUMP_INSTR_IN_UNIT_TEST // NOTE: we memset in order to ensure stable output. - const char *start = bc.constData(); - const char *end = start + bc.size(); - const char *codeAddr = start; - int whichExpected = 0; -#define DUMP_INSTR_SIZE_IN_UNIT_TEST(I, FMT) { \ - QString currExpected = whichExpected < expectedPreAddress.size() ? expectedPreAddress.at(whichExpected++) : QString(); \ - currExpected.prepend(getLeading(codeAddr - start)); \ - expected.append(currExpected); \ - codeAddr += QQmlJS::V4Instr::size(static_cast<QQmlJS::V4Instr::Type>(QQmlJS::V4Instr::I)); \ - } - FOR_EACH_V4_INSTR(DUMP_INSTR_SIZE_IN_UNIT_TEST); -#undef DUMP_INSTR_SIZE_IN_UNIT_TEST // so that we generate the correct address for each instruction comparison - bc.dump(start, end); - - // ensure that the output was expected. - const int messageCount = messageHandler.messages().count(); - QCOMPARE(messageCount, expected.count()); - for (int ii = 0; ii < messageCount; ++ii) { - // Calculating the destination address of a null jump/branch instruction is tricky - // so instead we simply don't compare that part of those instructions. - QRegExp ignoreAddress("\\bAddress\\((\\w*)\\)"); - ignoreAddress.setMinimal(true); - QString expectOut = expected.at(ii); expectOut.replace(ignoreAddress, ""); - QString actualOut = messageHandler.messages().at(ii); actualOut.replace(ignoreAddress, ""); - QCOMPARE(actualOut, expectOut); - } -} - - -QTEST_MAIN(tst_v4) - -#include "tst_v4.moc" diff --git a/tests/auto/qml/v4/v4.pro b/tests/auto/qml/v4/v4.pro deleted file mode 100644 index ef549538da..0000000000 --- a/tests/auto/qml/v4/v4.pro +++ /dev/null @@ -1,16 +0,0 @@ -CONFIG += testcase -TARGET = tst_qqmlv4 -macx:CONFIG -= app_bundle - -SOURCES += tst_v4.cpp \ - testtypes.cpp -HEADERS += testtypes.h - -include (../../shared/util.pri) - -TESTDATA = data/* - -CONFIG += parallel_test - -QT += core-private gui-private qml-private network testlib -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index bce1f9e4a2..2db79d7794 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -64,6 +64,7 @@ #include "../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> #include <QtGui/qstylehints.h> +#include <qmath.h> #ifdef Q_OS_MAC #include <Carbon/Carbon.h> diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index d1ed6dd05a..7bde37af38 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -55,6 +55,7 @@ #include <QDebug> #include <QDir> #include <math.h> +#include <qmath.h> #ifdef Q_OS_MAC #include <Carbon/Carbon.h> |