aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2019-06-17 16:02:23 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2019-07-04 12:41:09 +0200
commit9b1f2a7d0efa42f0f07afd398794a3e6fd20db31 (patch)
tree14296326c52c48d6553f9ae4c84bf42f33610f48 /tests
parent1289bd6045818249915028fb345ec29c4ead52e5 (diff)
extend grammar for better version parsing support
Be more strict in parsing version numbers This also makes it easier to access the version number in other places using the Visitor interface, like (soon) the linter and avoids reparsing the text twice. Potential disadvantages: previously allowed import statements will rejected at parse time, e.g. import QtQuick 0b10 Potential further advantage: Weird import statements like import QtQuick 0b10 will be rejected earlier Change-Id: Ifcd187b79a90952bc964c688afa4ea9b158e5109 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index f16e96a385..5f58df75d4 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -55,6 +55,7 @@ private slots:
void templateLiteral();
void leadingSemicolonInClass();
void templatedReadonlyProperty();
+ void qmlImportInJSRequiresFullVersion();
private:
QStringList excludedDirs;
@@ -299,6 +300,40 @@ void tst_qqmlparser::templatedReadonlyProperty()
QVERIFY(parser.parse());
}
+void tst_qqmlparser::qmlImportInJSRequiresFullVersion()
+{
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test 1.0 as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ bool b = parser.parseProgram();
+ qDebug() << parser.errorMessage();
+ QVERIFY(b);
+ }
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test 1 as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(!parser.parseProgram());
+ }
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test 1 as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(!parser.parseProgram());
+ }
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(!parser.parseProgram());
+ }
+}
+
QTEST_MAIN(tst_qqmlparser)
#include "tst_qqmlparser.moc"