summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmlecmascript/data/scriptErrors.js2
-rw-r--r--tests/auto/declarative/qmlecmascript/data/scriptErrors.qml10
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp20
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.js b/tests/auto/declarative/qmlecmascript/data/scriptErrors.js
new file mode 100644
index 0000000..1d7b357
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/scriptErrors.js
@@ -0,0 +1,2 @@
+// Comment
+a = 10
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml
new file mode 100644
index 0000000..3fb8ff7
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Object {
+ Script { source: "scriptErrors.js" }
+ Script { function getValue() { a = 10; return 0; } }
+
+ property int x: a.value
+ property int y: getValue();
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index dde3bb7..673be35 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -61,6 +61,7 @@ private slots:
void objectToString();
void selfDeletingBinding();
void extendedObjectPropertyLookup();
+ void scriptErrors();
private:
QmlEngine engine;
@@ -724,6 +725,25 @@ void tst_qmlecmascript::extendedObjectPropertyLookup()
QVERIFY(object != 0);
}
+/*
+Test file/lineNumbers for binding/Script errors.
+*/
+void tst_qmlecmascript::scriptErrors()
+{
+ QmlComponent component(&engine, TEST_FILE("scriptErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
+ QString warning2 = url + ":7: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning3 = url + ":5: Error: Invalid write to global property \"a\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
QTEST_MAIN(tst_qmlecmascript)
#include "tst_qmlecmascript.moc"