Add test for bug with typeof in imported js files.
authorMichael Brasser <michael.brasser@nokia.com>
Mon, 24 Oct 2011 23:49:22 +0000 (09:49 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 26 Oct 2011 05:30:56 +0000 (07:30 +0200)
Task-number: QTBUG-21864
Change-Id: I0fc9dc02f7ec00a2f7234484f5afafbbfe7ffca0
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp

diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js b/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js
new file mode 100644 (file)
index 0000000..16a3423
--- /dev/null
@@ -0,0 +1,25 @@
+var test1 = typeof a
+
+var b = {}
+var test2 = typeof b
+
+var c = 5
+var test3 = typeof c
+
+var d = "hello world"
+var test4 = typeof d
+
+var e = function() {}
+var test5 = typeof e
+
+var f = null
+var test6 = typeof f
+
+var g = undefined
+var test7 = typeof g
+
+var h = true
+var test8 = typeof h
+
+var i = []
+var test9 = typeof i
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml b/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml
new file mode 100644 (file)
index 0000000..28f7deb
--- /dev/null
@@ -0,0 +1,26 @@
+import QtQuick 2.0
+import "typeOf.js" as TypeOf
+
+QtObject {
+    property string test1
+    property string test2
+    property string test3
+    property string test4
+    property string test5
+    property string test6
+    property string test7
+    property string test8
+    property string test9
+
+    Component.onCompleted: {
+        test1 = TypeOf.test1
+        test2 = TypeOf.test2
+        test3 = TypeOf.test3
+        test4 = TypeOf.test4
+        test5 = TypeOf.test5
+        test6 = TypeOf.test6
+        test7 = TypeOf.test7
+        test8 = TypeOf.test8
+        test9 = TypeOf.test9
+    }
+}
index 33604dd..31aefd2 100644 (file)
@@ -195,6 +195,7 @@ private slots:
     void nonscriptable();
     void deleteLater();
     void in();
+    void typeOf();
     void sharedAttachedObject();
     void objectName();
     void writeRemovesBinding();
@@ -4512,6 +4513,25 @@ void tst_qdeclarativeecmascript::in()
     delete o;
 }
 
+void tst_qdeclarativeecmascript::typeOf()
+{
+    QDeclarativeComponent component(&engine, TEST_FILE("typeOf.qml"));
+    QObject *o = component.create();
+    QVERIFY(o != 0);
+    QCOMPARE(o->property("test1").toString(), QLatin1String("undefined"));
+    QEXPECT_FAIL("", "QTBUG-21864", Abort);
+    QCOMPARE(o->property("test2").toString(), QLatin1String("object"));
+    QCOMPARE(o->property("test3").toString(), QLatin1String("number"));
+    QCOMPARE(o->property("test4").toString(), QLatin1String("string"));
+    QCOMPARE(o->property("test5").toString(), QLatin1String("function"));
+    QCOMPARE(o->property("test6").toString(), QLatin1String("object"));
+    QCOMPARE(o->property("test7").toString(), QLatin1String("undefined"));
+    QCOMPARE(o->property("test8").toString(), QLatin1String("boolean"));
+    QCOMPARE(o->property("test9").toString(), QLatin1String("object"));
+
+    delete o;
+}
+
 void tst_qdeclarativeecmascript::sharedAttachedObject()
 {
     QDeclarativeComponent component(&engine, TEST_FILE("sharedAttachedObject.qml"));