diff options
author | Chris Adams <christopher.adams@nokia.com> | 2011-09-23 11:58:39 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-04 01:25:05 +0200 |
commit | 4c01174b63e049eeb945081e1e6cc7b09514fc6b (patch) | |
tree | cc3a555a7bc7e19cab2b80a20b74e6c823813def /tests/auto/declarative/qdeclarativeecmascript/data | |
parent | 61e7c0b9383998525f5df39a3596eb0cf39a270d (diff) |
Allow .pragma library scripts to import other scripts
Previously, a .pragma library script would have a new context which
did not have an engine set. If the script then imported other scripts
a crash would occur due to dereferencing the (null) engine ptr.
This commit ensures that even if no parent context is used (eg, for
shared scripts which don't import the parent context) the engine from
the parent context is used as the engine in the new context.
Finally, unit tests for the .pragma library import with imports cases
were added to tst_qdeclarativeecmascript.
Task-number: QTBUG-21620
Change-Id: I671ffc9eee98a69cce7c169ce5b9d5aae4d1ff0d
Reviewed-on: http://codereview.qt-project.org/5421
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript/data')
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js new file mode 100644 index 0000000000..3f2e6589dd --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js @@ -0,0 +1,9 @@ +.pragma library +.import "importFive.js" as ImportFive + +var i = 4; + +function importIncrementedValue() { + i = i + 1; + return (i + ImportFive.importFiveFunction()); // i + '5' (not i+5) +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js new file mode 100644 index 0000000000..fa6497d99b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js @@ -0,0 +1,11 @@ +.pragma library +.import "importPragmaLibrary.js" as LibraryImport + +var i = 10; + +function importIncrementedValue() { + i = i + 1; + // because LibraryImport is shared, and used in previous tests, + // the value will be large (already incremented a bunch of times). + return (i + LibraryImport.importIncrementedValue()); +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml new file mode 100644 index 0000000000..6a7459d3bb --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import "importPragmaLibraryWithImports.js" as LibraryImport + +QtObject { + id: root + property int testValue: LibraryImport.importIncrementedValue(); // valueOf(4 + 1 + '5') = valueOf('55') = 55 +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml new file mode 100644 index 0000000000..01f08dbdc3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import "importPragmaLibraryWithPragmaLibraryImports.js" as LibraryImport + +QtObject { + id: root + property int testValue: LibraryImport.importIncrementedValue(); // 10 + 1 + (7 due to previous tests) = 18 +} |