summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qmlcompiler.cpp33
-rw-r--r--tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml5
-rw-r--r--tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml2
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.1.qml4
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.2.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.3.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.4.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.4.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.5.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.6.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.6.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/defaultGrouped.qml10
-rw-r--r--tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/doubleSignal.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/emptySignal.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt2
-rw-r--r--tests/auto/declarative/qmllanguage/data/nestedErrors.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.1.qml4
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.10.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.10.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.11.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.11.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.2.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.3.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.4.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.4.qml8
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.5.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.6.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.6.qml11
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.7.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.7.qml11
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.8.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.8.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.9.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.9.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/test.js0
-rw-r--r--tests/auto/declarative/qmllanguage/data/test2.js0
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.h19
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp27
49 files changed, 250 insertions, 16 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 3253e72..240f16c 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -814,8 +814,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj)
create.create.type = obj->type;
if (!output->types.at(create.create.type).type &&
!obj->bindingBitmask.isEmpty()) {
- while (obj->bindingBitmask.size() % 4)
- obj->bindingBitmask.append(char(0));
+ Q_ASSERT(obj->bindingBitmask.size() % 4 == 0);
create.create.bindingBits =
output->indexForByteArray(obj->bindingBitmask);
} else {
@@ -1044,20 +1043,23 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
// Find, check and set the "id" property (if any)
Property *idProp = 0;
if (obj->properties.count() > 1 ||
- (obj->properties.count() == 1 && obj->properties.begin().key() != "id") ||
- !obj->scriptBlockObjects.isEmpty())
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component specification"));
+ (obj->properties.count() == 1 && obj->properties.begin().key() != "id"))
+ COMPILE_EXCEPTION(*obj->properties.begin(), qApp->translate("QmlCompiler","Invalid component specification"));
+
+ if (!obj->scriptBlockObjects.isEmpty())
+ COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), qApp->translate("QmlCompiler","Invalid component specification"));
if (obj->properties.count())
idProp = *obj->properties.begin();
+
if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component id specification"));
+ COMPILE_EXCEPTION(idProp, qApp->translate("QmlCompiler","Invalid component id specification"));
if (idProp) {
QString idVal = idProp->values.first()->primitive();
if (compileState.ids.contains(idVal))
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","id is not unique"));
+ COMPILE_EXCEPTION(idProp, qApp->translate("QmlCompiler","id is not unique"));
obj->id = idVal;
addId(idVal, obj);
@@ -1093,7 +1095,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script)
Property *source = *script->properties.begin();
if (script->defaultProperty)
- COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script."));
+ COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script"));
if (source->value || source->values.count() != 1 ||
source->values.at(0)->object || !source->values.at(0)->value.isString())
@@ -1180,12 +1182,10 @@ bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
bool QmlCompiler::buildSubObject(Object *obj, const BindingContext &ctxt)
{
Q_ASSERT(obj->metatype);
+ Q_ASSERT(!obj->defaultProperty);
Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
// sub-context
- if (obj->defaultProperty)
- COMPILE_CHECK(buildProperty(obj->defaultProperty, obj, ctxt));
-
foreach(Property *prop, obj->properties) {
if (isSignalPropertyName(prop->name)) {
COMPILE_CHECK(buildSignal(prop, obj, ctxt));
@@ -1230,9 +1230,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
const BindingContext &ctxt)
{
Q_ASSERT(obj->metaObject());
-
- if (prop->isEmpty())
- COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty property assignment"));
+ Q_ASSERT(!prop->isEmpty());
QByteArray name = prop->name;
Q_ASSERT(name.startsWith("on"));
@@ -1261,6 +1259,10 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
prop->values.at(0)->type = Value::SignalObject;
} else {
prop->values.at(0)->type = Value::SignalExpression;
+
+ QString script = prop->values.at(0)->value.asScript().trimmed();
+ if (script.isEmpty())
+ COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty signal assignment"));
}
}
@@ -1701,6 +1703,9 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
Q_ASSERT(prop->type != 0);
Q_ASSERT(prop->index != -1);
+ if (prop->values.count())
+ COMPILE_EXCEPTION(prop->values.first(), qApp->translate("QmlCompiler", "Invalid value in grouped property"));
+
if (prop->type < (int)QVariant::UserType) {
QmlEnginePrivate *ep =
static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
diff --git a/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml b/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml
new file mode 100644
index 0000000..5cc8d20
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+Item {
+ x: "You can't assign a string to a real!"
+}
diff --git a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
index cef9f8d..50723a3 100644
--- a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
+++ b/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
@@ -7,6 +7,7 @@ MyTypeObject {
intProperty: -19
realProperty: 23.2
doubleProperty: -19.7
+ floatProperty: 8.5
colorProperty: "red"
dateProperty: "1982-11-25"
timeProperty: "11:11:31"
@@ -21,6 +22,7 @@ MyTypeObject {
rectFProperty: "1000.1,-10.9,400x90.99"
boolProperty: true
variantProperty: "Hello World!"
+ vectorProperty: "10,1,2.2"
objectProperty: MyTypeObject { intProperty: 8 }
}
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.errors.txt b/tests/auto/declarative/qmllanguage/data/component.1.errors.txt
new file mode 100644
index 0000000..091aad6
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.1.errors.txt
@@ -0,0 +1 @@
+3:1:Cannot create empty component specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.qml b/tests/auto/declarative/qmllanguage/data/component.1.qml
new file mode 100644
index 0000000..07e463a
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.1.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Component {
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.errors.txt b/tests/auto/declarative/qmllanguage/data/component.2.errors.txt
new file mode 100644
index 0000000..76e7656
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.2.errors.txt
@@ -0,0 +1 @@
+6:9:id is not unique
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.qml b/tests/auto/declarative/qmllanguage/data/component.2.qml
new file mode 100644
index 0000000..74a4f89
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.2.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ id: myId
+ Component {
+ id: myId
+ Object {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.errors.txt b/tests/auto/declarative/qmllanguage/data/component.3.errors.txt
new file mode 100644
index 0000000..9a13142
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.3.errors.txt
@@ -0,0 +1 @@
+6:9:Invalid component id specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.qml b/tests/auto/declarative/qmllanguage/data/component.3.qml
new file mode 100644
index 0000000..043cb6b
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.3.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ Component {
+ id: myId
+ id: myId2
+ Object {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.errors.txt b/tests/auto/declarative/qmllanguage/data/component.4.errors.txt
new file mode 100644
index 0000000..2ab18685
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.4.errors.txt
@@ -0,0 +1 @@
+3:1:Invalid component body specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.qml b/tests/auto/declarative/qmllanguage/data/component.4.qml
new file mode 100644
index 0000000..3d115ba
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.4.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Component {
+ Object {}
+ Object {}
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.errors.txt b/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
new file mode 100644
index 0000000..5e88900
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
@@ -0,0 +1 @@
+4:5:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.qml b/tests/auto/declarative/qmllanguage/data/component.5.qml
new file mode 100644
index 0000000..ab57622
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.5.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Component {
+ x: 10
+ Object {}
+}
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.errors.txt b/tests/auto/declarative/qmllanguage/data/component.6.errors.txt
new file mode 100644
index 0000000..2b1c6ca
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.6.errors.txt
@@ -0,0 +1 @@
+4:5:Invalid component id specification
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.qml b/tests/auto/declarative/qmllanguage/data/component.6.qml
new file mode 100644
index 0000000..6adaf0d
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/component.6.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Component {
+ id: Object {}
+ Object {}
+}
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt b/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt
new file mode 100644
index 0000000..945d51b
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt
@@ -0,0 +1 @@
+7:9:Invalid value in grouped property
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml
new file mode 100644
index 0000000..39ac5e0
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ grouped {
+ script: print(1921)
+ Object {}
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt b/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt
new file mode 100644
index 0000000..2aea251
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt
@@ -0,0 +1 @@
+5:5:Incorrectly specified signal
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml
new file mode 100644
index 0000000..ec813c9
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyQmlObject {
+ onBasicSignal: print(1921)
+ onBasicSignal: print(1921)
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt b/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt
new file mode 100644
index 0000000..353bbf5
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt
@@ -0,0 +1 @@
+4:5:Empty signal assignment
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.qml b/tests/auto/declarative/qmllanguage/data/emptySignal.qml
new file mode 100644
index 0000000..4c5a122
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/emptySignal.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyQmlObject {
+ onBasicSignal: " "
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt
new file mode 100644
index 0000000..886da55
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt
@@ -0,0 +1,2 @@
+4:5:Unable to create type NestedErrorsType
+4:8:Invalid property assignment: double expected
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.qml b/tests/auto/declarative/qmllanguage/data/nestedErrors.qml
new file mode 100644
index 0000000..c0d755a
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/nestedErrors.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Item {
+ NestedErrorsType {}
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.errors.txt b/tests/auto/declarative/qmllanguage/data/script.1.errors.txt
new file mode 100644
index 0000000..50518cc
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.1.errors.txt
@@ -0,0 +1 @@
+3:1:Invalid use of Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.qml b/tests/auto/declarative/qmllanguage/data/script.1.qml
new file mode 100644
index 0000000..8dac8b7
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.1.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Script {
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.errors.txt b/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
new file mode 100644
index 0000000..8299d23
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
@@ -0,0 +1 @@
+6:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.qml b/tests/auto/declarative/qmllanguage/data/script.10.qml
new file mode 100644
index 0000000..516e878
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.10.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ Component {
+ Item {}
+ Script {}
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.errors.txt b/tests/auto/declarative/qmllanguage/data/script.11.errors.txt
new file mode 100644
index 0000000..a664203
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.11.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.qml b/tests/auto/declarative/qmllanguage/data/script.11.qml
new file mode 100644
index 0000000..d8313a3
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.11.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Object {
+ Script {
+ Object {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.errors.txt b/tests/auto/declarative/qmllanguage/data/script.2.errors.txt
new file mode 100644
index 0000000..8fb3bbd
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.2.errors.txt
@@ -0,0 +1 @@
+5:9:Properties cannot be set on Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.qml b/tests/auto/declarative/qmllanguage/data/script.2.qml
new file mode 100644
index 0000000..18bb7c8
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.2.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Object {
+ Script {
+ id: myScript
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.errors.txt b/tests/auto/declarative/qmllanguage/data/script.3.errors.txt
new file mode 100644
index 0000000..8fb3bbd
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.3.errors.txt
@@ -0,0 +1 @@
+5:9:Properties cannot be set on Script block
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.qml b/tests/auto/declarative/qmllanguage/data/script.3.qml
new file mode 100644
index 0000000..c2296ff
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.3.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Object {
+ Script {
+ hello: world
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.errors.txt b/tests/auto/declarative/qmllanguage/data/script.4.errors.txt
new file mode 100644
index 0000000..49a507f
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.4.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script source value
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.qml b/tests/auto/declarative/qmllanguage/data/script.4.qml
new file mode 100644
index 0000000..08115c2
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.4.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: 10
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.errors.txt b/tests/auto/declarative/qmllanguage/data/script.5.errors.txt
new file mode 100644
index 0000000..49a507f
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.5.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script source value
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.qml b/tests/auto/declarative/qmllanguage/data/script.5.qml
new file mode 100644
index 0000000..a3b1a15
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.5.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: "hello" + ".js"
+ }
+}
+
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.errors.txt b/tests/auto/declarative/qmllanguage/data/script.6.errors.txt
new file mode 100644
index 0000000..4e53b6b
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.6.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid Script block. Specify either the source property or inline script
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.qml b/tests/auto/declarative/qmllanguage/data/script.6.qml
new file mode 100644
index 0000000..e578629
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.6.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: "test.js"
+ function helloWorld() {}
+ }
+}
+
+
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.errors.txt b/tests/auto/declarative/qmllanguage/data/script.7.errors.txt
new file mode 100644
index 0000000..dc15ddf
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.7.errors.txt
@@ -0,0 +1 @@
+5:9:Variable declarations not allow in inline Script blocks
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.qml b/tests/auto/declarative/qmllanguage/data/script.7.qml
new file mode 100644
index 0000000..6bee3f9
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.7.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+Object {
+ Script {
+ var a = 10;
+ }
+}
+
+
+
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.errors.txt b/tests/auto/declarative/qmllanguage/data/script.8.errors.txt
new file mode 100644
index 0000000..b5bf1a8
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.8.errors.txt
@@ -0,0 +1 @@
+6:9:Invalid Script source value
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.qml b/tests/auto/declarative/qmllanguage/data/script.8.qml
new file mode 100644
index 0000000..55bc05c
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.8.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Object {
+ Script {
+ source: "test.js"
+ source: "test2.js"
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.errors.txt b/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
new file mode 100644
index 0000000..dc1eb53
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
@@ -0,0 +1 @@
+5:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.qml b/tests/auto/declarative/qmllanguage/data/script.9.qml
new file mode 100644
index 0000000..79aa504
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/script.9.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Item {
+ Component {
+ Script {}
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/data/test.js b/tests/auto/declarative/qmllanguage/data/test.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/test.js
diff --git a/tests/auto/declarative/qmllanguage/data/test2.js b/tests/auto/declarative/qmllanguage/data/test2.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/test2.js
diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h
index 91c6e2e..e654faa 100644
--- a/tests/auto/declarative/qmllanguage/testtypes.h
+++ b/tests/auto/declarative/qmllanguage/testtypes.h
@@ -46,6 +46,7 @@
#include <QtCore/qdatetime.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlparserstatus.h>
@@ -185,6 +186,7 @@ class MyTypeObject : public QObject
Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty);
Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty);
Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty);
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty);
Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty);
Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty);
Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty);
@@ -198,6 +200,7 @@ class MyTypeObject : public QObject
Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty);
Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty);
Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty);
Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty);
Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT);
@@ -289,6 +292,14 @@ public:
doublePropertyValue = v;
}
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
QColor colorPropertyValue;
QColor colorProperty() const {
return colorPropertyValue;
@@ -394,6 +405,14 @@ public:
variantPropertyValue = v;
}
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
QmlScriptString scriptPropertyValue;
QmlScriptString scriptProperty() const {
return scriptPropertyValue;
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index da586d9..8e0dd3e 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -246,8 +246,29 @@ void tst_qmllanguage::errors_data()
QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
-
-
+ QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false;
+ QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false;
+ QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false;
+ QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false;
+ QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false;
+ QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false;
+ QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false;
+ QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false;
+ QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false;
+ QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false;
+ QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false;
+
+ QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
+ QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
+ QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
+ QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
+ QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
+ QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
+
+ QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
+ QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
+ QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
+ QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
}
void tst_qmllanguage::errors()
@@ -371,6 +392,7 @@ void tst_qmllanguage::assignBasicTypes()
QCOMPARE(object->intProperty(), -19);
QCOMPARE((float)object->realProperty(), float(23.2));
QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
QCOMPARE(object->colorProperty(), QColor("red"));
QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
@@ -383,6 +405,7 @@ void tst_qmllanguage::assignBasicTypes()
QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)90.99));
QCOMPARE(object->boolProperty(), true);
QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
QVERIFY(object->objectProperty() != 0);
MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
QVERIFY(child != 0);