From b35d6b475333fc2fabd0e91f1bfcf2f65aa4d4f4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 23 Jun 2011 11:20:00 +1000 Subject: Fix regression against 4.7 Task-number: QTBUG-19136 --- .../qdeclarativeecmascript/data/importScope.1.js | 1 + .../qdeclarativeecmascript/data/importScope.2.js | 3 +++ .../qdeclarativeecmascript/data/importScope.qml | 7 +++++++ .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 14 ++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js new file mode 100644 index 0000000000..4c556f9e96 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js @@ -0,0 +1 @@ +var value = 240 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js new file mode 100644 index 0000000000..291fb9d2cc --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js @@ -0,0 +1,3 @@ +function getValue() { + return ImportScope1.value +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml new file mode 100644 index 0000000000..a72847f0d7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 +import "importScope.1.js" as ImportScope1 +import "importScope.2.js" as ImportScope2 + +QtObject { + property int test: ImportScope2.getValue() +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index cabaddeeb7..3c4c336822 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -108,6 +108,7 @@ private slots: void aliasPropertyAndBinding(); void nonExistentAttachedObject(); void scope(); + void importScope(); void signalParameterTypes(); void objectsCompareAsEqual(); void dynamicCreation_data(); @@ -959,6 +960,19 @@ void tst_qdeclarativeecmascript::scope() } } +// In 4.7, non-library javascript files that had no imports shared the imports of their +// importing context +void tst_qdeclarativeecmascript::importScope() +{ + QDeclarativeComponent component(&engine, TEST_FILE("importScope.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toInt(), 240); + + delete o; +} + /* Tests that "any" type passes through a synthesized signal parameter. This is essentially a test of QDeclarativeMetaType::copy() -- cgit v1.2.3