qtscript-opensource-src/tests/auto/qscriptvaluegenerated/tst_qscriptvalue_generated_...

1923 lines
59 KiB
C++

/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "tst_qscriptvalue.h"
void tst_QScriptValueGenerated::toString_initData()
{
QTest::addColumn<QString>("expected");
initScriptValues();
}
static const char *toString_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static const char *toString_valueArray[] = {
"", "undefined",
"null", "true",
"false", "122",
"124", "0",
"0", "123",
"6.37e-8", "-6.37e-8",
"1126240820", "65536",
"65537", "NaN",
"NaN", "Infinity",
"-Infinity", "NaN",
"Infinity", "-Infinity",
"ciao", "ciao",
"", "",
"0", "123",
"12.4", "undefined",
"null", "true",
"false", "122",
"124", "0",
"0", "123",
"6.37e-8", "-6.37e-8",
"1126240820", "65536",
"65537", "NaN",
"NaN", "Infinity",
"-Infinity", "NaN",
"Infinity", "-Infinity",
"ciao", "ciao",
"", "",
"0", "123",
"12.3", "undefined",
"null", "true",
"false", "122",
"124", "0",
"0", "123",
"6.37e-8", "-6.37e-8",
"1126240820", "65536",
"65537", "NaN",
"NaN", "Infinity",
"-Infinity", "NaN",
"Infinity", "-Infinity",
"ciao", "ciao",
"", "",
"0", "123",
"1.23", "",
"undefined", "[object Object]",
"Invalid Date", "",
"function () {\n [native code]\n}", "Error: Unknown error",
"function Object() {\n [native code]\n}", "function Array() {\n [native code]\n}",
"function Number() {\n [native code]\n}", "function Function() {\n [native code]\n}",
"function () { return 1; }", "function () { return 'ciao'; }",
"function () { throw new Error('foo'); }", "/foo/",
"[object Object]", "",
"Error: Unknown error", "true",
"false", "123",
"/foo/gim", "ciao",
"22", "ReferenceError: Can't find variable: Undefined",
"ReferenceError: Can't find variable: Null", "ReferenceError: Can't find variable: True",
"ReferenceError: Can't find variable: False", "undefined",
"null", "true",
"false", "122",
"124", "0",
"0", "123",
"6.37e-8", "-6.37e-8",
"1126240820", "65536",
"65537", "NaN",
"Infinity", "-Infinity",
"ciao", "",
"0", "123",
"12.4", "null",
"undefined", "[object Object]",
"", ",,,,,,,,,",
"Invalid Date", "[object QMetaObject]",
"/foo/gim", "undefined",
"123", "false",
"null", "QScriptEngine(name = \"\")"};
void tst_QScriptValueGenerated::toString_makeData(const char* expr)
{
static const QHash<QString, QString> toString =
charArraysToStringHash(toString_tagArray, toString_valueArray,
int(sizeof(toString_tagArray) / sizeof(const char *)));
newRow(expr) << toString.value(expr);
}
void tst_QScriptValueGenerated::toString_test(const char*, const QScriptValue& value)
{
QFETCH(QString, expected);
QCOMPARE(value.toString(), expected);
QCOMPARE(value.toString(), expected);
}
DEFINE_TEST_FUNCTION(toString)
void tst_QScriptValueGenerated::toNumber_initData()
{
QTest::addColumn<qsreal>("expected");
initScriptValues();
}
static const char *toNumber_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static qsreal toNumber_valueArray[] = {
0, qQNaN(), 0, 1, 0, 122, 124, 0, 0, 123,
6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(),
qInf(), qInf(), qQNaN(), qQNaN(), 0, 0, 0, 123, 12.4, qQNaN(),
0, 1, 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08,
1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(),
qQNaN(), qQNaN(), 0, 0, 0, 123, 12.3, qQNaN(), 0, 1,
0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536,
65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(), qQNaN(), qQNaN(),
0, 0, 0, 123, 1.23, 0, qQNaN(), qQNaN(), qQNaN(), 0,
qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(),
qQNaN(), 0, qQNaN(), 1, 0, 123, qQNaN(), qQNaN(), 22, qQNaN(),
qQNaN(), qQNaN(), qQNaN(), qQNaN(), 0, 1, 0, 122, 124, 0,
0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qInf(), qInf(),
qQNaN(), 0, 0, 123, 12.4, 0, qQNaN(), qQNaN(), 0, qQNaN(),
qQNaN(), qQNaN(), qQNaN(), qQNaN(), 123, 0, 0, qQNaN()};
void tst_QScriptValueGenerated::toNumber_makeData(const char* expr)
{
static const QHash<QString, qsreal> toNumber =
charValueArraysToHash(toNumber_tagArray, toNumber_valueArray,
int(sizeof(toNumber_tagArray) / sizeof(const char *)));
newRow(expr) << toNumber.value(expr);
}
void tst_QScriptValueGenerated::toNumber_test(const char*, const QScriptValue& value)
{
QFETCH(qsreal, expected);
if (qIsNaN(expected)) {
QVERIFY(qIsNaN(value.toNumber()));
return;
}
if (qIsInf(expected)) {
QVERIFY(qIsInf(value.toNumber()));
QVERIFY(qIsInf(value.toNumber()));
return;
}
QCOMPARE(value.toNumber(), expected);
QCOMPARE(value.toNumber(), expected);
}
DEFINE_TEST_FUNCTION(toNumber)
void tst_QScriptValueGenerated::toBool_initData()
{
QTest::addColumn<bool>("expected");
initScriptValues();
}
static const char *toBool_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static bool toBool_valueArray[] = {
false, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
false, false,
true, true,
true, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
false, false,
true, true,
true, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
false, false,
true, true,
true, true,
false, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
true, true,
true, false,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
true, true,
false, true};
void tst_QScriptValueGenerated::toBool_makeData(const char* expr)
{
static const QHash<QString, bool> toBool =
charValueArraysToHash(toBool_tagArray, toBool_valueArray,
int(sizeof(toBool_tagArray) / sizeof(const char *)));
newRow(expr) << toBool.value(expr);
}
void tst_QScriptValueGenerated::toBool_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.toBool(), expected);
QCOMPARE(value.toBool(), expected);
}
DEFINE_TEST_FUNCTION(toBool)
void tst_QScriptValueGenerated::toBoolean_initData()
{
QTest::addColumn<bool>("expected");
initScriptValues();
}
static const char *toBoolean_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static bool toBoolean_valueArray[] = {
false, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
false, false,
true, true,
true, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
false, false,
true, true,
true, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
false, false,
true, true,
true, true,
false, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, true,
true, false,
false, true,
false, true,
true, false,
false, true,
true, true,
true, true,
true, false,
true, true,
true, false,
true, true,
true, false,
false, true,
true, true,
true, true,
true, true,
true, true,
false, true};
void tst_QScriptValueGenerated::toBoolean_makeData(const char* expr)
{
static const QHash<QString, bool> toBoolean =
charValueArraysToHash(toBoolean_tagArray, toBoolean_valueArray,
int(sizeof(toBoolean_tagArray) / sizeof(const char *)));
newRow(expr) << toBoolean.value(expr);
}
void tst_QScriptValueGenerated::toBoolean_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.toBoolean(), expected);
QCOMPARE(value.toBoolean(), expected);
}
DEFINE_TEST_FUNCTION(toBoolean)
void tst_QScriptValueGenerated::toInteger_initData()
{
QTest::addColumn<qsreal>("expected");
initScriptValues();
}
static const char *toInteger_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static qsreal toInteger_valueArray[] = {
0, 0, 0, 1, 0, 122, 124, 0, 0, 123,
0, 0, 1126240820, 65536, 65537, 0, 0, qInf(), qInf(), 0,
qInf(), qInf(), 0, 0, 0, 0, 0, 123, 12, 0,
0, 1, 0, 122, 124, 0, 0, 123, 0, 0,
1126240820, 65536, 65537, 0, 0, qInf(), qInf(), 0, qInf(), qInf(),
0, 0, 0, 0, 0, 123, 12, 0, 0, 1,
0, 122, 124, 0, 0, 123, 0, 0, 1126240820, 65536,
65537, 0, 0, qInf(), qInf(), 0, qInf(), qInf(), 0, 0,
0, 0, 0, 123, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 123, 0, 0, 22, 0,
0, 0, 0, 0, 0, 1, 0, 122, 124, 0,
0, 123, 0, 0, 1126240820, 65536, 65537, 0, qInf(), qInf(),
0, 0, 0, 123, 12, 0, 0, 0, 0, 0,
0, 0, 0, 0, 123, 0, 0, 0};
void tst_QScriptValueGenerated::toInteger_makeData(const char* expr)
{
static const QHash<QString, qsreal> toInteger =
charValueArraysToHash(toInteger_tagArray, toInteger_valueArray,
int(sizeof(toInteger_tagArray) / sizeof(const char *)));
newRow(expr) << toInteger.value(expr);
}
void tst_QScriptValueGenerated::toInteger_test(const char*, const QScriptValue& value)
{
QFETCH(qsreal, expected);
if (qIsInf(expected)) {
QVERIFY(qIsInf(value.toInteger()));
QVERIFY(qIsInf(value.toInteger()));
return;
}
QCOMPARE(value.toInteger(), expected);
QCOMPARE(value.toInteger(), expected);
}
DEFINE_TEST_FUNCTION(toInteger)
void tst_QScriptValueGenerated::toInt32_initData()
{
QTest::addColumn<qint32>("expected");
initScriptValues();
}
static const char *toInt32_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static qint32 toInt32_valueArray[] = {
0, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
1, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 1,
0, 123,
0, 0,
22, 0,
0, 0,
0, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 0,
0, 0,
0, 0,
0, 0,
123, 0,
0, 0};
void tst_QScriptValueGenerated::toInt32_makeData(const char* expr)
{
static const QHash<QString, qint32> toInt32 =
charValueArraysToHash(toInt32_tagArray, toInt32_valueArray,
int(sizeof(toInt32_tagArray) / sizeof(const char *)));
newRow(expr) << toInt32.value(expr);
}
void tst_QScriptValueGenerated::toInt32_test(const char*, const QScriptValue& value)
{
QFETCH(qint32, expected);
QCOMPARE(value.toInt32(), expected);
QCOMPARE(value.toInt32(), expected);
}
DEFINE_TEST_FUNCTION(toInt32)
void tst_QScriptValueGenerated::toUInt32_initData()
{
QTest::addColumn<quint32>("expected");
initScriptValues();
}
static const char *toUInt32_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static quint32 toUInt32_valueArray[] = {
0, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
1, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 1,
0, 123,
0, 0,
22, 0,
0, 0,
0, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
1126240820, 65536,
65537, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 0,
0, 0,
0, 0,
0, 0,
123, 0,
0, 0};
void tst_QScriptValueGenerated::toUInt32_makeData(const char* expr)
{
static const QHash<QString, quint32> toUInt32 =
charValueArraysToHash(toUInt32_tagArray, toUInt32_valueArray,
int(sizeof(toUInt32_tagArray) / sizeof(const char *)));
newRow(expr) << toUInt32.value(expr);
}
void tst_QScriptValueGenerated::toUInt32_test(const char*, const QScriptValue& value)
{
QFETCH(quint32, expected);
QCOMPARE(value.toUInt32(), expected);
QCOMPARE(value.toUInt32(), expected);
}
DEFINE_TEST_FUNCTION(toUInt32)
void tst_QScriptValueGenerated::toUInt16_initData()
{
QTest::addColumn<quint16>("expected");
initScriptValues();
}
static const char *toUInt16_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
"QScriptValue(0.0)",
"QScriptValue(123.0)",
"QScriptValue(6.37e-8)",
"QScriptValue(-6.37e-8)",
"QScriptValue(0x43211234)",
"QScriptValue(0x10000)",
"QScriptValue(0x10001)",
"QScriptValue(qSNaN())",
"QScriptValue(qQNaN())",
"QScriptValue(qInf())",
"QScriptValue(-qInf())",
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
"QScriptValue(\"ciao\")",
"QScriptValue(QString::fromLatin1(\"ciao\"))",
"QScriptValue(QString(\"\"))",
"QScriptValue(QString())",
"QScriptValue(QString(\"0\"))",
"QScriptValue(QString(\"123\"))",
"QScriptValue(QString(\"12.4\"))",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(0, true)",
"QScriptValue(0, false)",
"QScriptValue(0, int(122))",
"QScriptValue(0, uint(124))",
"QScriptValue(0, 0)",
"QScriptValue(0, 0.0)",
"QScriptValue(0, 123.0)",
"QScriptValue(0, 6.37e-8)",
"QScriptValue(0, -6.37e-8)",
"QScriptValue(0, 0x43211234)",
"QScriptValue(0, 0x10000)",
"QScriptValue(0, 0x10001)",
"QScriptValue(0, qSNaN())",
"QScriptValue(0, qQNaN())",
"QScriptValue(0, qInf())",
"QScriptValue(0, -qInf())",
"QScriptValue(0, \"NaN\")",
"QScriptValue(0, \"Infinity\")",
"QScriptValue(0, \"-Infinity\")",
"QScriptValue(0, \"ciao\")",
"QScriptValue(0, QString::fromLatin1(\"ciao\"))",
"QScriptValue(0, QString(\"\"))",
"QScriptValue(0, QString())",
"QScriptValue(0, QString(\"0\"))",
"QScriptValue(0, QString(\"123\"))",
"QScriptValue(0, QString(\"12.3\"))",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"QScriptValue(engine, true)",
"QScriptValue(engine, false)",
"QScriptValue(engine, int(122))",
"QScriptValue(engine, uint(124))",
"QScriptValue(engine, 0)",
"QScriptValue(engine, 0.0)",
"QScriptValue(engine, 123.0)",
"QScriptValue(engine, 6.37e-8)",
"QScriptValue(engine, -6.37e-8)",
"QScriptValue(engine, 0x43211234)",
"QScriptValue(engine, 0x10000)",
"QScriptValue(engine, 0x10001)",
"QScriptValue(engine, qSNaN())",
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
"QScriptValue(engine, \"NaN\")",
"QScriptValue(engine, \"Infinity\")",
"QScriptValue(engine, \"-Infinity\")",
"QScriptValue(engine, \"ciao\")",
"QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
"QScriptValue(engine, QString(\"\"))",
"QScriptValue(engine, QString())",
"QScriptValue(engine, QString(\"0\"))",
"QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"1.23\"))",
"engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
"engine->evaluate(\"Array.prototype\")",
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Error.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
"engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
"engine->evaluate(\"new Boolean(true)\")",
"engine->evaluate(\"new Boolean(false)\")",
"engine->evaluate(\"new Number(123)\")",
"engine->evaluate(\"new RegExp('foo', 'gim')\")",
"engine->evaluate(\"new String('ciao')\")",
"engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
"engine->evaluate(\"False\")",
"engine->evaluate(\"undefined\")",
"engine->evaluate(\"null\")",
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
"engine->evaluate(\"0.0\")",
"engine->evaluate(\"123.0\")",
"engine->evaluate(\"6.37e-8\")",
"engine->evaluate(\"-6.37e-8\")",
"engine->evaluate(\"0x43211234\")",
"engine->evaluate(\"0x10000\")",
"engine->evaluate(\"0x10001\")",
"engine->evaluate(\"NaN\")",
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")",
"engine->evaluate(\"'ciao'\")",
"engine->evaluate(\"''\")",
"engine->evaluate(\"'0'\")",
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
"engine->undefinedValue()",
"engine->newObject()",
"engine->newArray()",
"engine->newArray(10)",
"engine->newDate(QDateTime())",
"engine->newQMetaObject(&QObject::staticMetaObject)",
"engine->newRegExp(\"foo\", \"gim\")",
"engine->newVariant(QVariant())",
"engine->newVariant(QVariant(123))",
"engine->newVariant(QVariant(false))",
"engine->newQObject(0)",
"engine->newQObject(engine)"};
static quint16 toUInt16_valueArray[] = {
0, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
4660, 0,
1, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
4660, 0,
1, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
4660, 0,
1, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 123,
1, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 1,
0, 123,
0, 0,
22, 0,
0, 0,
0, 0,
0, 1,
0, 122,
124, 0,
0, 123,
0, 0,
4660, 0,
1, 0,
0, 0,
0, 0,
0, 123,
12, 0,
0, 0,
0, 0,
0, 0,
0, 0,
123, 0,
0, 0};
void tst_QScriptValueGenerated::toUInt16_makeData(const char* expr)
{
static const QHash<QString, quint16> toUInt16 =
charValueArraysToHash(toUInt16_tagArray, toUInt16_valueArray,
int(sizeof(toUInt16_tagArray) / sizeof(const char *)));
newRow(expr) << toUInt16.value(expr);
}
void tst_QScriptValueGenerated::toUInt16_test(const char*, const QScriptValue& value)
{
QFETCH(quint16, expected);
QCOMPARE(value.toUInt16(), expected);
QCOMPARE(value.toUInt16(), expected);
}
DEFINE_TEST_FUNCTION(toUInt16)