diff options
author | Lars Knoll <lars.knoll@digia.com> | 2012-12-10 22:06:33 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-11 14:50:32 +0100 |
commit | bac602c454f38ddde01167a3f75cb10ce1cfb876 (patch) | |
tree | 9e716db6d26ac6daeebc97c7bd29b37123f68a05 /tests | |
parent | f96f0083402ef0210192406aaa943b1b5297a584 (diff) |
Throw a parse error on octal numbers and escape sequences
This is compliant with EcmaScript 5.1, where octal numbers
and escape sequences are an optional and deprecated part
of the syntax.
Allow leading 0's in qml mode, but interpret the result
as decimal. This is also to keep compatibility with
existing code.
Change-Id: Ic3450ec3dd17966846751ee688a90c65939ba78f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'tests')
12 files changed, 123 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.1.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.1.qml new file mode 100644 index 0000000000..1b83a1be0b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.1.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.2.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.2.qml new file mode 100644 index 0000000000..77f13178c3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.2.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 1.01; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.3.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.3.qml new file mode 100644 index 0000000000..f20baf305a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.3.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 1e-10; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.4.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.4.qml new file mode 100644 index 0000000000..e115dbbbb1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.4.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = -1.2; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.5.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.5.qml new file mode 100644 index 0000000000..c3db17602a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.5.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = .4e-5; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.6.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.6.qml new file mode 100644 index 0000000000..471db8708a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.6.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0x1; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.7.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.7.qml new file mode 100644 index 0000000000..f8f8e1aae8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.7.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0Xa; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml new file mode 100644 index 0000000000..71b82b956d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\01"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml new file mode 100644 index 0000000000..787f1d86c7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\1a"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml new file mode 100644 index 0000000000..9954617b6b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\012"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml new file mode 100644 index 0000000000..5bf41f0c1a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\00a"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index a99c5fa8be..852c0ef4b5 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -285,6 +285,8 @@ private slots: void propertyOverride(); void concatenatedStringPropertyAccess(); void jsOwnedObjectsDeletedOnEngineDestroy(); + void numberParsing(); + void stringParsing(); private: static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -7335,6 +7337,28 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy() delete object; } +void tst_qqmlecmascript::numberParsing() +{ + for (int i = 1; i < 8; ++i) { + QString file("numberParsing.%1.qml"); + file = file.arg(i); + QQmlComponent component(&engine, testFileUrl(file)); + QObject *object = component.create(); + QVERIFY(object != 0); + } +} + +void tst_qqmlecmascript::stringParsing() +{ + for (int i = 1; i < 5; ++i) { + QString file("stringParsing_error.%1.qml"); + file = file.arg(i); + QQmlComponent component(&engine, testFileUrl(file)); + QObject *object = component.create(); + QVERIFY(object == 0); + } +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |