aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/v4/qv4bindings.cpp2
-rw-r--r--src/declarative/qml/v8/qjsvalue.cpp32
-rw-r--r--src/declarative/qml/v8/qjsvalue.h2
-rw-r--r--tests/auto/declarative/qjsengine/tst_qjsengine.cpp224
-rw-r--r--tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp200
-rw-r--r--tests/auto/declarative/qjsvalue/tst_qjsvalue.h4
-rw-r--r--tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp14
7 files changed, 252 insertions, 226 deletions
diff --git a/src/declarative/qml/v4/qv4bindings.cpp b/src/declarative/qml/v4/qv4bindings.cpp
index ba53a4176c..7c1ff14cd3 100644
--- a/src/declarative/qml/v4/qv4bindings.cpp
+++ b/src/declarative/qml/v4/qv4bindings.cpp
@@ -975,7 +975,7 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
output.cleanupString();
MARK_CLEAN_REGISTER(instr->unaryop.output);
}
- output.setint(tmp.toInt32());
+ output.setint(tmp.toInt());
}
}
QML_V4_END_INSTR(ConvertStringToInt, unaryop)
diff --git a/src/declarative/qml/v8/qjsvalue.cpp b/src/declarative/qml/v8/qjsvalue.cpp
index 9d21a1db28..482216ac49 100644
--- a/src/declarative/qml/v8/qjsvalue.cpp
+++ b/src/declarative/qml/v8/qjsvalue.cpp
@@ -515,7 +515,7 @@ QString QJSValue::toString() const
attempt to convert the object to a primitive value (possibly
resulting in an uncaught script exception).
- \sa isNumber(), toInteger(), toInt32(), toUInt32(), toUInt16()
+ \sa isNumber(), toInteger(), toInt(), toUInt(), toUInt16()
*/
double QJSValue::toNumber() const
{
@@ -572,9 +572,9 @@ double QJSValue::toInteger() const
attempt to convert the object to a primitive value (possibly
resulting in an uncaught script exception).
- \sa toNumber(), toUInt32()
+ \sa toNumber(), toUInt()
*/
-qint32 QJSValue::toInt32() const
+qint32 QJSValue::toInt() const
{
Q_D(const QJSValue);
QScriptIsolate api(d->engine());
@@ -591,7 +591,31 @@ qint32 QJSValue::toInt32() const
attempt to convert the object to a primitive value (possibly
resulting in an uncaught script exception).
- \sa toNumber(), toInt32()
+ \sa toNumber(), toInt()
+*/
+quint32 QJSValue::toUInt() const
+{
+ Q_D(const QJSValue);
+ QScriptIsolate api(d->engine());
+ return d->toUInt32();
+}
+
+/*!
+ \obsolete
+
+ Use toInt() instead.
+*/
+qint32 QJSValue::toInt32() const
+{
+ Q_D(const QJSValue);
+ QScriptIsolate api(d->engine());
+ return d->toInt32();
+}
+
+/*!
+ \obsolete
+
+ Use toUInt() instead.
*/
quint32 QJSValue::toUInt32() const
{
diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h
index 280f44e924..4467cef354 100644
--- a/src/declarative/qml/v8/qjsvalue.h
+++ b/src/declarative/qml/v8/qjsvalue.h
@@ -106,6 +106,8 @@ public:
QString toString() const;
double toNumber() const;
+ qint32 toInt() const;
+ quint32 toUInt() const;
bool toBool() const;
double toInteger() const;
qint32 toInt32() const;
diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
index 4b41765a58..b6c7f4fbba 100644
--- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
@@ -513,7 +513,7 @@ void tst_QJSEngine::newFunctionWithProto()
QScriptValue result = fun.call();
QCOMPARE(result.isNumber(), true);
- QCOMPARE(result.toInt32(), 42);
+ QCOMPARE(result.toInt(), 42);
}
// whether the return value is assigned to the correct engine
{
@@ -525,7 +525,7 @@ void tst_QJSEngine::newFunctionWithProto()
QScriptValue result = fun.call();
QCOMPARE(result.engine(), &eng);
QCOMPARE(result.isNumber(), true);
- QCOMPARE(result.toInt32(), 1024);
+ QCOMPARE(result.toInt(), 1024);
}
// whether the return value is undefined when returning a value with wrong engine
{
@@ -552,19 +552,19 @@ void tst_QJSEngine::newFunctionWithProto()
QScriptValue result = fun.call();
QCOMPARE(result.isNumber(), true);
- QCOMPARE(result.toInt32(), 0);
+ QCOMPARE(result.toInt(), 0);
result = fun.call(QScriptValue(), QScriptValueList() << 1);
QCOMPARE(result.isNumber(), true);
- QCOMPARE(result.toInt32(), 1);
+ QCOMPARE(result.toInt(), 1);
result = fun.call(QScriptValue(), QScriptValueList() << 1 << 2 << 3);
QCOMPARE(result.isNumber(), true);
- QCOMPARE(result.toInt32(), 6);
+ QCOMPARE(result.toInt(), 6);
result = fun.call(QScriptValue(), QScriptValueList() << 1 << 2 << 3 << 4);
QCOMPARE(result.isNumber(), true);
- QCOMPARE(result.toInt32(), 10);
+ QCOMPARE(result.toInt(), 10);
}
}
#endif
@@ -604,27 +604,27 @@ void tst_QJSEngine::newArray_HooliganTask218092()
{
QJSValue ret = eng.evaluate("[].splice(0, 0, 'a')");
QVERIFY(ret.isArray());
- QCOMPARE(ret.property("length").toInt32(), 0);
+ QCOMPARE(ret.property("length").toInt(), 0);
}
{
QJSValue ret = eng.evaluate("['a'].splice(0, 1, 'b')");
QVERIFY(ret.isArray());
- QCOMPARE(ret.property("length").toInt32(), 1);
+ QCOMPARE(ret.property("length").toInt(), 1);
}
{
QJSValue ret = eng.evaluate("['a', 'b'].splice(0, 1, 'c')");
QVERIFY(ret.isArray());
- QCOMPARE(ret.property("length").toInt32(), 1);
+ QCOMPARE(ret.property("length").toInt(), 1);
}
{
QJSValue ret = eng.evaluate("['a', 'b', 'c'].splice(0, 2, 'd')");
QVERIFY(ret.isArray());
- QCOMPARE(ret.property("length").toInt32(), 2);
+ QCOMPARE(ret.property("length").toInt(), 2);
}
{
QJSValue ret = eng.evaluate("['a', 'b', 'c'].splice(1, 2, 'd', 'e', 'f')");
QVERIFY(ret.isArray());
- QCOMPARE(ret.property("length").toInt32(), 2);
+ QCOMPARE(ret.property("length").toInt(), 2);
}
}
@@ -639,15 +639,15 @@ void tst_QJSEngine::newArray_HooliganTask233836()
{
QJSValue ret = eng.newArray(0xFFFFFFFF);
QEXPECT_FAIL("", "The maximum length of arrays is defined by v8 currently and differs from QtScript", Abort);
- QCOMPARE(ret.property("length").toUInt32(), uint(0xFFFFFFFF));
+ QCOMPARE(ret.property("length").toUInt(), uint(0xFFFFFFFF));
ret.setProperty(0xFFFFFFFF, 123);
- QCOMPARE(ret.property("length").toUInt32(), uint(0xFFFFFFFF));
+ QCOMPARE(ret.property("length").toUInt(), uint(0xFFFFFFFF));
QVERIFY(ret.property(0xFFFFFFFF).isNumber());
- QCOMPARE(ret.property(0xFFFFFFFF).toInt32(), 123);
+ QCOMPARE(ret.property(0xFFFFFFFF).toInt(), 123);
ret.setProperty(123, 456);
- QCOMPARE(ret.property("length").toUInt32(), uint(0xFFFFFFFF));
+ QCOMPARE(ret.property("length").toUInt(), uint(0xFFFFFFFF));
QVERIFY(ret.property(123).isNumber());
- QCOMPARE(ret.property(123).toInt32(), 456);
+ QCOMPARE(ret.property(123).toInt(), 456);
}
}
@@ -736,7 +736,7 @@ void tst_QJSEngine::newVariant_valueOfToString()
QJSValue object = eng.newVariant(QVariant(123));
QJSValue value = object.property("valueOf").call(object);
QVERIFY(value.isNumber());
- QCOMPARE(value.toInt32(), 123);
+ QCOMPARE(value.toInt(), 123);
QCOMPARE(object.toString(), QString::fromLatin1("123"));
QCOMPARE(object.toVariant().toString(), object.toString());
}
@@ -1401,7 +1401,7 @@ void tst_QJSEngine::getSetGlobalObject()
{
QScriptValue ret = obj.property("foo");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
QVERIFY(!obj.property("bar").isValid());
@@ -1409,7 +1409,7 @@ void tst_QJSEngine::getSetGlobalObject()
{
QScriptValue ret = obj.property("bar");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 456);
+ QCOMPARE(ret.toInt(), 456);
}
QVERIFY(!obj.property("baz").isValid());
@@ -1417,7 +1417,7 @@ void tst_QJSEngine::getSetGlobalObject()
{
QScriptValue ret = obj.property("baz");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 789);
+ QCOMPARE(ret.toInt(), 789);
}
{
@@ -2352,8 +2352,8 @@ static QJSValue fooToScriptValue(QJSEngine *eng, const Foo &foo)
static void fooFromScriptValue(const QJSValue &value, Foo &foo)
{
- foo.x = value.property("x").toInt32();
- foo.y = value.property("y").toInt32();
+ foo.x = value.property("x").toInt();
+ foo.y = value.property("y").toInt();
}
static QJSValue fooToScriptValueV2(QJSEngine *eng, const Foo &foo)
@@ -2363,7 +2363,7 @@ static QJSValue fooToScriptValueV2(QJSEngine *eng, const Foo &foo)
static void fooFromScriptValueV2(const QJSValue &value, Foo &foo)
{
- foo.x = value.toInt32();
+ foo.x = value.toInt();
}
Q_DECLARE_METATYPE(QLinkedList<QString>)
@@ -2498,7 +2498,7 @@ void tst_QJSEngine::valueConversion_sequence()
lst << QLatin1String("foo") << QLatin1String("bar");
QScriptValue lstVal = eng.toScriptValue(lst);
QCOMPARE(lstVal.isArray(), true);
- QCOMPARE(lstVal.property("length").toInt32(), 2);
+ QCOMPARE(lstVal.property("length").toInt(), 2);
QCOMPARE(lstVal.property("0").isString(), true);
QCOMPARE(lstVal.property("0").toString(), QLatin1String("foo"));
QCOMPARE(lstVal.property("1").isString(), true);
@@ -2517,14 +2517,14 @@ void tst_QJSEngine::valueConversion_sequence()
QStack<int> second; second << 99999;lst << second;
QScriptValue lstVal = eng.toScriptValue(lst);
QCOMPARE(lstVal.isArray(), true);
- QCOMPARE(lstVal.property("length").toInt32(), 2);
+ QCOMPARE(lstVal.property("length").toInt(), 2);
QCOMPARE(lstVal.property("0").isArray(), true);
- QCOMPARE(lstVal.property("0").property("length").toInt32(), 2);
- QCOMPARE(lstVal.property("0").property("0").toInt32(), first.at(0));
- QCOMPARE(lstVal.property("0").property("1").toInt32(), first.at(1));
+ QCOMPARE(lstVal.property("0").property("length").toInt(), 2);
+ QCOMPARE(lstVal.property("0").property("0").toInt(), first.at(0));
+ QCOMPARE(lstVal.property("0").property("1").toInt(), first.at(1));
QCOMPARE(lstVal.property("1").isArray(), true);
- QCOMPARE(lstVal.property("1").property("length").toInt32(), 1);
- QCOMPARE(lstVal.property("1").property("0").toInt32(), second.at(0));
+ QCOMPARE(lstVal.property("1").property("length").toInt(), 1);
+ QCOMPARE(lstVal.property("1").property("0").toInt(), second.at(0));
QCOMPARE(qscriptvalue_cast<QStack<int> >(lstVal.property("0")), first);
QCOMPARE(qscriptvalue_cast<QStack<int> >(lstVal.property("1")), second);
QCOMPARE(qscriptvalue_cast<QLinkedList<QStack<int> > >(lstVal), lst);
@@ -2552,10 +2552,10 @@ void tst_QJSEngine::valueConversion_sequence()
lst << 1 << 2 << 3;
QScriptValue val = eng.toScriptValue(lst);
QVERIFY(val.isArray());
- QCOMPARE(val.property("length").toInt32(), lst.size());
- QCOMPARE(val.property(0).toInt32(), lst.at(0));
- QCOMPARE(val.property(1).toInt32(), lst.at(1));
- QCOMPARE(val.property(2).toInt32(), lst.at(2));
+ QCOMPARE(val.property("length").toInt(), lst.size());
+ QCOMPARE(val.property(0).toInt(), lst.at(0));
+ QCOMPARE(val.property(1).toInt(), lst.at(1));
+ QCOMPARE(val.property(2).toInt(), lst.at(2));
QCOMPARE(qscriptvalue_cast<QList<int> >(val), lst);
}
@@ -2564,7 +2564,7 @@ void tst_QJSEngine::valueConversion_sequence()
lst << this;
QScriptValue val = eng.toScriptValue(lst);
QVERIFY(val.isArray());
- QCOMPARE(val.property("length").toInt32(), lst.size());
+ QCOMPARE(val.property("length").toInt(), lst.size());
QCOMPARE(val.property(0).toQObject(), (QObject *)this);
QCOMPARE(qscriptvalue_cast<QObjectList>(val), lst);
@@ -2689,37 +2689,37 @@ void tst_QJSEngine::valueConversion_basic2()
{
QJSValue val = eng.toScriptValue(uint(123));
QVERIFY(val.isNumber());
- QCOMPARE(val.toInt32(), 123);
+ QCOMPARE(val.toInt(), 123);
}
{
QJSValue val = eng.toScriptValue(qulonglong(123));
QVERIFY(val.isNumber());
- QCOMPARE(val.toInt32(), 123);
+ QCOMPARE(val.toInt(), 123);
}
{
QJSValue val = eng.toScriptValue(float(123));
QVERIFY(val.isNumber());
- QCOMPARE(val.toInt32(), 123);
+ QCOMPARE(val.toInt(), 123);
}
{
QJSValue val = eng.toScriptValue(short(123));
QVERIFY(val.isNumber());
- QCOMPARE(val.toInt32(), 123);
+ QCOMPARE(val.toInt(), 123);
}
{
QJSValue val = eng.toScriptValue(ushort(123));
QVERIFY(val.isNumber());
- QCOMPARE(val.toInt32(), 123);
+ QCOMPARE(val.toInt(), 123);
}
{
QJSValue val = eng.toScriptValue(char(123));
QVERIFY(val.isNumber());
- QCOMPARE(val.toInt32(), 123);
+ QCOMPARE(val.toInt(), 123);
}
{
QJSValue val = eng.toScriptValue(uchar(123));
QVERIFY(val.isNumber());
- QCOMPARE(val.toInt32(), 123);
+ QCOMPARE(val.toInt(), 123);
}
}
@@ -3353,13 +3353,13 @@ void tst_QJSEngine::stacktrace()
// FIXME? it is not standard.
//QCOMPARE(result.property("fileName").toString(), fileName);
- //QCOMPARE(result.property("lineNumber").toInt32(), 9);
+ //QCOMPARE(result.property("lineNumber").toInt(), 9);
QJSValue stack = result.property("stack");
// FIXME? it is not standard.
// QVERIFY(stack.isArray());
- //QCOMPARE(stack.property("length").toInt32(), 7);
+ //QCOMPARE(stack.property("length").toInt(), 7);
QJSValueIterator it(stack);
int counter = 5;
@@ -3373,7 +3373,7 @@ void tst_QJSEngine::stacktrace()
QJSValue callee = frame.property("arguments").property("callee");
QVERIFY(callee.strictlyEquals(eng.globalObject().property("foo")));
QCOMPARE(obj.property("functionName").toString(), QString("foo"));
- int line = obj.property("lineNumber").toInt32();
+ int line = obj.property("lineNumber").toInt();
if (counter == 5)
QCOMPARE(line, 9);
else
@@ -3467,7 +3467,7 @@ void tst_QJSEngine::automaticSemicolonInsertion()
{
QJSValue ret = eng.evaluate("{ 1\n2 } 3");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
{
QJSValue ret = eng.evaluate("for (a; b\n)");
@@ -3482,7 +3482,7 @@ void tst_QJSEngine::automaticSemicolonInsertion()
eng.evaluate("c = 2; b = 1");
QJSValue ret = eng.evaluate("a = b\n++c");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
{
QJSValue ret = eng.evaluate("if (a > b)\nelse c = d");
@@ -3494,7 +3494,7 @@ void tst_QJSEngine::automaticSemicolonInsertion()
eng.evaluate("b = 1; d = 2; e = 3");
QJSValue ret = eng.evaluate("a = b + c\n(d + e).foo()");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 6);
+ QCOMPARE(ret.toInt(), 6);
}
{
QJSValue ret = eng.evaluate("throw\n1");
@@ -3504,7 +3504,7 @@ void tst_QJSEngine::automaticSemicolonInsertion()
{
QJSValue ret = eng.evaluate("a = Number(1)\n++a");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 2);
+ QCOMPARE(ret.toInt(), 2);
}
// "a semicolon is never inserted automatically if the semicolon
@@ -3513,31 +3513,31 @@ void tst_QJSEngine::automaticSemicolonInsertion()
eng.evaluate("a = 123");
QJSValue ret = eng.evaluate("if (0)\n ++a; a");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
{
eng.evaluate("a = 123");
QJSValue ret = eng.evaluate("if (0)\n --a; a");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
{
eng.evaluate("a = 123");
QJSValue ret = eng.evaluate("if ((0))\n ++a; a");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
{
eng.evaluate("a = 123");
QJSValue ret = eng.evaluate("if ((0))\n --a; a");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
{
eng.evaluate("a = 123");
QJSValue ret = eng.evaluate("if (0\n)\n ++a; a");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
{
eng.evaluate("a = 123");
@@ -3552,83 +3552,83 @@ void tst_QJSEngine::automaticSemicolonInsertion()
{
QJSValue ret = eng.evaluate("n = 0; for (i = 0; i < 10; ++i)\n ++n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 10);
+ QCOMPARE(ret.toInt(), 10);
}
{
QJSValue ret = eng.evaluate("n = 30; for (i = 0; i < 10; ++i)\n --n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 20);
+ QCOMPARE(ret.toInt(), 20);
}
{
QJSValue ret = eng.evaluate("n = 0; for (var i = 0; i < 10; ++i)\n ++n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 10);
+ QCOMPARE(ret.toInt(), 10);
}
{
QJSValue ret = eng.evaluate("n = 30; for (var i = 0; i < 10; ++i)\n --n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 20);
+ QCOMPARE(ret.toInt(), 20);
}
{
QJSValue ret = eng.evaluate("n = 0; i = 0; while (i++ < 10)\n ++n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 10);
+ QCOMPARE(ret.toInt(), 10);
}
{
QJSValue ret = eng.evaluate("n = 30; i = 0; while (i++ < 10)\n --n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 20);
+ QCOMPARE(ret.toInt(), 20);
}
{
QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 0; for (i in o)\n ++n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
{
QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 9; for (i in o)\n --n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 6);
+ QCOMPARE(ret.toInt(), 6);
}
{
QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 0; for (var i in o)\n ++n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
{
QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 9; for (var i in o)\n --n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 6);
+ QCOMPARE(ret.toInt(), 6);
}
{
QJSValue ret = eng.evaluate("o = { n: 3 }; n = 5; with (o)\n ++n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 5);
+ QCOMPARE(ret.toInt(), 5);
}
{
QJSValue ret = eng.evaluate("o = { n: 3 }; n = 10; with (o)\n --n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 10);
+ QCOMPARE(ret.toInt(), 10);
}
{
QJSValue ret = eng.evaluate("n = 5; i = 0; do\n ++n; while (++i < 10); n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 15);
+ QCOMPARE(ret.toInt(), 15);
}
{
QJSValue ret = eng.evaluate("n = 20; i = 0; do\n --n; while (++i < 10); n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 10);
+ QCOMPARE(ret.toInt(), 10);
}
{
QJSValue ret = eng.evaluate("n = 1; i = 0; if (n) i\n++n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 2);
+ QCOMPARE(ret.toInt(), 2);
}
{
QJSValue ret = eng.evaluate("n = 1; i = 0; if (n) i\n--n; n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 0);
+ QCOMPARE(ret.toInt(), 0);
}
{
@@ -3753,7 +3753,7 @@ void tst_QJSEngine::abortEvaluation()
case EventReceiver3::Number:
QVERIFY(!eng.hasUncaughtException());
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 1234);
+ QCOMPARE(ret.toInt(), 1234);
break;
case EventReceiver3::String:
QVERIFY(!eng.hasUncaughtException());
@@ -3796,7 +3796,7 @@ void tst_QJSEngine::abortEvaluation_tryCatch()
case EventReceiver3::Number:
QVERIFY(!eng.hasUncaughtException());
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 1234);
+ QCOMPARE(ret.toInt(), 1234);
break;
case EventReceiver3::String:
QVERIFY(!eng.hasUncaughtException());
@@ -4002,7 +4002,7 @@ void tst_QJSEngine::errorConstructors()
QVERIFY(ret.toString().startsWith(name));
//QTBUG-6138: JSC doesn't assign lineNumber when errors are not thrown
QEXPECT_FAIL("", "we have no more lineNumber property ", Continue);
- QCOMPARE(ret.property("lineNumber").toInt32(), i+2);
+ QCOMPARE(ret.property("lineNumber").toInt(), i+2);
}
}
}
@@ -4021,7 +4021,7 @@ void tst_QJSEngine::argumentsProperty_globalContext()
{
QJSValue ret = eng.evaluate("arguments");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 10);
+ QCOMPARE(ret.toInt(), 10);
}
QVERIFY(eng.evaluate("delete arguments").toBool());
QVERIFY(!eng.globalObject().property("arguments").isValid());
@@ -4034,7 +4034,7 @@ void tst_QJSEngine::argumentsProperty_JS()
eng.evaluate("o = { arguments: 123 }");
QJSValue ret = eng.evaluate("with (o) { arguments; }");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
{
QJSEngine eng;
@@ -4043,7 +4043,7 @@ void tst_QJSEngine::argumentsProperty_JS()
// appears like a local variable, and it can be replaced.
QJSValue ret = eng.evaluate("(function() { arguments = 456; return arguments; })()");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 456);
+ QCOMPARE(ret.toInt(), 456);
QVERIFY(!eng.globalObject().property("arguments").isValid());
}
}
@@ -4066,7 +4066,7 @@ void tst_QJSEngine::argumentsProperty_evaluateInNativeFunction()
eng.globalObject().setProperty("fun", eng.newFunction(argumentsProperty_fun));
QScriptValue result = eng.evaluate("fun(18)");
QVERIFY(result.isNumber());
- QCOMPARE(result.toInt32(), 200+18);
+ QCOMPARE(result.toInt(), 200+18);
}
#endif
@@ -4367,7 +4367,7 @@ void tst_QJSEngine::stringObjects()
// in C++
{
QJSValue obj = QJSValue(&eng, str).toObject();
- QCOMPARE(obj.property("length").toInt32(), str.length());
+ QCOMPARE(obj.property("length").toInt(), str.length());
QCOMPARE(obj.propertyFlags("length"), QJSValue::PropertyFlags(QJSValue::Undeletable | QJSValue::SkipInEnumeration | QJSValue::ReadOnly));
for (int i = 0; i < str.length(); ++i) {
QString pname = QString::number(i);
@@ -4406,11 +4406,11 @@ void tst_QJSEngine::stringObjects()
QJSValue ret3 = eng.evaluate("s[-1] = 123; s[-1]");
QVERIFY(ret3.isNumber());
- QCOMPARE(ret3.toInt32(), 123);
+ QCOMPARE(ret3.toInt(), 123);
QJSValue ret4 = eng.evaluate("s[s.length] = 456; s[s.length]");
QVERIFY(ret4.isNumber());
- QCOMPARE(ret4.toInt32(), 456);
+ QCOMPARE(ret4.toInt(), 456);
QJSValue ret5 = eng.evaluate("delete s[0]");
QVERIFY(ret5.isBool());
@@ -4434,15 +4434,15 @@ void tst_QJSEngine::jsStringPrototypeReplaceBugs()
{
QJSValue ret = eng.evaluate("replace_args = []; \"a a a\".replace(/(a)/g, function() { replace_args.push(arguments); }); replace_args");
QVERIFY(ret.isArray());
- int len = ret.property("length").toInt32();
+ int len = ret.property("length").toInt();
QCOMPARE(len, 3);
for (int i = 0; i < len; ++i) {
QJSValue args = ret.property(i);
- QCOMPARE(args.property("length").toInt32(), 4);
+ QCOMPARE(args.property("length").toInt(), 4);
QCOMPARE(args.property(0).toString(), QString::fromLatin1("a")); // matched string
QCOMPARE(args.property(1).toString(), QString::fromLatin1("a")); // capture
QVERIFY(args.property(2).isNumber());
- QCOMPARE(args.property(2).toInt32(), i*2); // index of match
+ QCOMPARE(args.property(2).toInt(), i*2); // index of match
QCOMPARE(args.property(3).toString(), QString::fromLatin1("a a a"));
}
}
@@ -4604,7 +4604,7 @@ void tst_QJSEngine::jsContinueInSwitch()
" }\n"
"}; j");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
// for - switch - case - default - continue
{
@@ -4617,7 +4617,7 @@ void tst_QJSEngine::jsContinueInSwitch()
" }\n"
"}; j");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
// switch - for - continue
{
@@ -4628,7 +4628,7 @@ void tst_QJSEngine::jsContinueInSwitch()
" }\n"
"}; i\n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 100000);
+ QCOMPARE(ret.toInt(), 100000);
}
// switch - switch - continue
{
@@ -4646,7 +4646,7 @@ void tst_QJSEngine::jsContinueInSwitch()
" }\n"
"}; j");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 1);
+ QCOMPARE(ret.toInt(), 1);
}
// switch - for - switch - continue
{
@@ -4660,7 +4660,7 @@ void tst_QJSEngine::jsContinueInSwitch()
" }\n"
"}; i\n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 100000);
+ QCOMPARE(ret.toInt(), 100000);
}
}
@@ -4673,7 +4673,7 @@ void tst_QJSEngine::jsShadowReadOnlyPrototypeProperty()
// just seems weird -- and non-compliant. Adopt the JSC behavior instead.
QJSEngine eng;
QVERIFY(eng.evaluate("o = {}; o.__proto__ = parseInt; o.length").isNumber());
- QCOMPARE(eng.evaluate("o.length = 123; o.length").toInt32(), 123);
+ QCOMPARE(eng.evaluate("o.length = 123; o.length").toInt(), 123);
QVERIFY(eng.evaluate("o.hasOwnProperty('length')").toBool());
}
@@ -4948,7 +4948,7 @@ void tst_QJSEngine::jsThrowInsideWithStatement()
" }"
"}");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
QVERIFY(eng.hasUncaughtException());
}
{
@@ -5045,8 +5045,8 @@ void tst_QJSEngine::reentrancy_typeConversion()
QScriptValue fooVal = qScriptValueFromValue(&eng1, foo);
QVERIFY(fooVal.isObject());
QVERIFY(!fooVal.isVariant());
- QCOMPARE(fooVal.property("x").toInt32(), 12);
- QCOMPARE(fooVal.property("y").toInt32(), 34);
+ QCOMPARE(fooVal.property("x").toInt(), 12);
+ QCOMPARE(fooVal.property("y").toInt(), 34);
fooVal.setProperty("x", 56);
fooVal.setProperty("y", 78);
@@ -5084,7 +5084,7 @@ void tst_QJSEngine::reentrancy_globalObjectProperties()
QVERIFY(!eng2.globalObject().property("a").isValid());
eng2.evaluate("a = 20");
QVERIFY(eng2.globalObject().property("a").isNumber());
- QCOMPARE(eng1.globalObject().property("a").toInt32(), 10);
+ QCOMPARE(eng1.globalObject().property("a").toInt(), 10);
}
void tst_QJSEngine::reentrancy_Array()
@@ -5182,22 +5182,22 @@ void tst_QJSEngine::jsIncDecNonObjectProperty()
{
QJSValue ret = eng.evaluate("var a = 'ciao'; a.length++");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 4);
+ QCOMPARE(ret.toInt(), 4);
}
{
QJSValue ret = eng.evaluate("var a = 'ciao'; a.length--");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 4);
+ QCOMPARE(ret.toInt(), 4);
}
{
QJSValue ret = eng.evaluate("var a = 'ciao'; ++a.length");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 5);
+ QCOMPARE(ret.toInt(), 5);
}
{
QJSValue ret = eng.evaluate("var a = 'ciao'; --a.length");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
}
@@ -5708,20 +5708,20 @@ void tst_QJSEngine::functionScopes()
{
QScriptValue ret = fun.call();
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
QScriptValue scope = fun.scope();
QVERIFY(scope.isObject());
{
QScriptValue ret = scope.property("foo");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
QCOMPARE(scope.propertyFlags("foo"), QScriptValue::Undeletable);
}
{
QScriptValue ret = scope.property("arg");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
QCOMPARE(scope.propertyFlags("arg"), QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
}
@@ -5729,7 +5729,7 @@ void tst_QJSEngine::functionScopes()
{
QScriptValue ret = fun.call();
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 456);
+ QCOMPARE(ret.toInt(), 456);
}
scope = scope.scope();
@@ -5751,7 +5751,7 @@ static QScriptValue counter_inner(QScriptContext *ctx, QScriptEngine *)
static QScriptValue counter(QScriptContext *ctx, QScriptEngine *eng)
{
QScriptValue act = ctx->activationObject();
- act.setProperty("count", ctx->argument(0).toInt32());
+ act.setProperty("count", ctx->argument(0).toInt());
QScriptValue result = eng->newFunction(counter_inner);
result.setScope(act);
return result;
@@ -5760,7 +5760,7 @@ static QScriptValue counter(QScriptContext *ctx, QScriptEngine *eng)
static QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng)
{
QScriptValue act = ctx->activationObject();
- act.setProperty("count", ctx->argument(0).toInt32());
+ act.setProperty("count", ctx->argument(0).toInt());
return eng->evaluate("(function() { return count++; })");
}
@@ -5775,7 +5775,7 @@ void tst_QJSEngine::nativeFunctionScopes()
QScriptValue ret = cnt.call();
QVERIFY(ret.isNumber());
QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue);
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
}
{
@@ -5785,7 +5785,7 @@ void tst_QJSEngine::nativeFunctionScopes()
{
QScriptValue ret = cnt.call();
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
}
@@ -5954,7 +5954,7 @@ void tst_QJSEngine::evaluateProgram_executeLater()
QScriptValue ret = eng.evaluate(program);
QVERIFY(!ret.isError());
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
}
}
@@ -6168,7 +6168,7 @@ static QScriptValue createAnotherEngine(QScriptContext *, QScriptEngine *)
QScriptEngine eng;
eng.evaluate("function foo(x, y) { return x + y; }" );
eng.evaluate("hello = 5; world = 6" );
- return eng.evaluate("foo(hello,world)").toInt32();
+ return eng.evaluate("foo(hello,world)").toInt();
}
@@ -6177,10 +6177,10 @@ void tst_QJSEngine::reentrency()
QScriptEngine eng;
eng.globalObject().setProperty("foo", eng.newFunction(createAnotherEngine));
eng.evaluate("function bar() { return foo(); } hello = 9; function getHello() { return hello; }");
- QCOMPARE(eng.evaluate("foo() + getHello() + foo()").toInt32(), 5+6 + 9 + 5+6);
- QCOMPARE(eng.evaluate("foo").call().toInt32(), 5+6);
- QCOMPARE(eng.evaluate("hello").toInt32(), 9);
- QCOMPARE(eng.evaluate("foo() + hello").toInt32(), 5+6+9);
+ QCOMPARE(eng.evaluate("foo() + getHello() + foo()").toInt(), 5+6 + 9 + 5+6);
+ QCOMPARE(eng.evaluate("foo").call().toInt(), 5+6);
+ QCOMPARE(eng.evaluate("hello").toInt(), 9);
+ QCOMPARE(eng.evaluate("foo() + hello").toInt(), 5+6+9);
}
#endif
@@ -6486,7 +6486,7 @@ void tst_QJSEngine::functionPrototypeExtensions()
QJSValue props = eng.evaluate("props = []; for (var p in Function.prototype) props.push(p); props");
QVERIFY(!eng.hasUncaughtException());
QVERIFY(props.isArray());
- QCOMPARE(props.property("length").toInt32(), 0);
+ QCOMPARE(props.property("length").toInt(), 0);
}
class ThreadedTestEngine : public QThread {
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
index caff7fc065..7b19a2d85e 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
@@ -123,7 +123,7 @@ void tst_QJSValue::ctor_int()
{
QJSValue v(int(0x43211234));
QVERIFY(v.isNumber());
- QCOMPARE(v.toInt32(), 0x43211234);
+ QCOMPARE(v.toInt(), 0x43211234);
}
{
QJSValue v(int(1));
@@ -153,7 +153,7 @@ void tst_QJSValue::ctor_uint()
{
QJSValue v(uint(0x43211234));
QVERIFY(v.isNumber());
- QCOMPARE(v.toUInt32(), uint(0x43211234));
+ QCOMPARE(v.toUInt(), uint(0x43211234));
}
{
QJSValue v(uint(1));
@@ -818,271 +818,271 @@ void tst_QJSValue::toInteger()
QCOMPARE(inv.toInteger(), 0.0);
}
-void tst_QJSValue::toInt32()
+void tst_QJSValue::toInt()
{
QJSEngine eng;
{
QJSValue zer0 = QJSValue(&eng, 0.0);
- QCOMPARE(zer0.toInt32(), 0);
+ QCOMPARE(zer0.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(zer0), 0);
QJSValue number = QJSValue(&eng, 123.0);
- QCOMPARE(number.toInt32(), 123);
+ QCOMPARE(number.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(number), 123);
QJSValue number2 = QJSValue(&eng, qSNaN());
- QCOMPARE(number2.toInt32(), 0);
+ QCOMPARE(number2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number2), 0);
QJSValue number3 = QJSValue(&eng, +qInf());
- QCOMPARE(number3.toInt32(), 0);
+ QCOMPARE(number3.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number3), 0);
QJSValue number3_2 = QJSValue(&eng, -qInf());
- QCOMPARE(number3_2.toInt32(), 0);
+ QCOMPARE(number3_2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number3_2), 0);
QJSValue number4 = QJSValue(&eng, 0.5);
- QCOMPARE(number4.toInt32(), 0);
+ QCOMPARE(number4.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number4), 0);
QJSValue number5 = QJSValue(&eng, 123.5);
- QCOMPARE(number5.toInt32(), 123);
+ QCOMPARE(number5.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(number5), 123);
QJSValue number6 = QJSValue(&eng, -456.5);
- QCOMPARE(number6.toInt32(), -456);
+ QCOMPARE(number6.toInt(), -456);
QCOMPARE(qjsvalue_cast<qint32>(number6), -456);
QJSValue str = QJSValue(&eng, QLatin1String("123.0"));
- QCOMPARE(str.toInt32(), 123);
+ QCOMPARE(str.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(str), 123);
QJSValue str2 = QJSValue(&eng, QLatin1String("NaN"));
- QCOMPARE(str2.toInt32(), 0);
+ QCOMPARE(str2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str2), 0);
QJSValue str3 = QJSValue(&eng, QLatin1String("Infinity"));
- QCOMPARE(str3.toInt32(), 0);
+ QCOMPARE(str3.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str3), 0);
QJSValue str3_2 = QJSValue(&eng, QLatin1String("-Infinity"));
- QCOMPARE(str3_2.toInt32(), 0);
+ QCOMPARE(str3_2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str3_2), 0);
QJSValue str4 = QJSValue(&eng, QLatin1String("0.5"));
- QCOMPARE(str4.toInt32(), 0);
+ QCOMPARE(str4.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str4), 0);
QJSValue str5 = QJSValue(&eng, QLatin1String("123.5"));
- QCOMPARE(str5.toInt32(), 123);
+ QCOMPARE(str5.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(str5), 123);
QJSValue str6 = QJSValue(&eng, QLatin1String("-456.5"));
- QCOMPARE(str6.toInt32(), -456);
+ QCOMPARE(str6.toInt(), -456);
QCOMPARE(qjsvalue_cast<qint32>(str6), -456);
}
// V2 constructors
{
QJSValue zer0 = QJSValue(0.0);
- QCOMPARE(zer0.toInt32(), 0);
+ QCOMPARE(zer0.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(zer0), 0);
QJSValue number = QJSValue(123.0);
- QCOMPARE(number.toInt32(), 123);
+ QCOMPARE(number.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(number), 123);
QJSValue number2 = QJSValue(qSNaN());
- QCOMPARE(number2.toInt32(), 0);
+ QCOMPARE(number2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number2), 0);
QJSValue number3 = QJSValue(+qInf());
- QCOMPARE(number3.toInt32(), 0);
+ QCOMPARE(number3.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number3), 0);
QJSValue number3_2 = QJSValue(-qInf());
- QCOMPARE(number3_2.toInt32(), 0);
+ QCOMPARE(number3_2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number3_2), 0);
QJSValue number4 = QJSValue(0.5);
- QCOMPARE(number4.toInt32(), 0);
+ QCOMPARE(number4.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(number4), 0);
QJSValue number5 = QJSValue(123.5);
- QCOMPARE(number5.toInt32(), 123);
+ QCOMPARE(number5.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(number5), 123);
QJSValue number6 = QJSValue(-456.5);
- QCOMPARE(number6.toInt32(), -456);
+ QCOMPARE(number6.toInt(), -456);
QCOMPARE(qjsvalue_cast<qint32>(number6), -456);
QJSValue number7 = QJSValue(0x43211234);
- QCOMPARE(number7.toInt32(), 0x43211234);
+ QCOMPARE(number7.toInt(), 0x43211234);
QJSValue str = QJSValue("123.0");
- QCOMPARE(str.toInt32(), 123);
+ QCOMPARE(str.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(str), 123);
QJSValue str2 = QJSValue("NaN");
- QCOMPARE(str2.toInt32(), 0);
+ QCOMPARE(str2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str2), 0);
QJSValue str3 = QJSValue("Infinity");
- QCOMPARE(str3.toInt32(), 0);
+ QCOMPARE(str3.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str3), 0);
QJSValue str3_2 = QJSValue("-Infinity");
- QCOMPARE(str3_2.toInt32(), 0);
+ QCOMPARE(str3_2.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str3_2), 0);
QJSValue str4 = QJSValue("0.5");
- QCOMPARE(str4.toInt32(), 0);
+ QCOMPARE(str4.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(str4), 0);
QJSValue str5 = QJSValue("123.5");
- QCOMPARE(str5.toInt32(), 123);
+ QCOMPARE(str5.toInt(), 123);
QCOMPARE(qjsvalue_cast<qint32>(str5), 123);
QJSValue str6 = QJSValue("-456.5");
- QCOMPARE(str6.toInt32(), -456);
+ QCOMPARE(str6.toInt(), -456);
QCOMPARE(qjsvalue_cast<qint32>(str6), -456);
}
QJSValue inv;
- QCOMPARE(inv.toInt32(), 0);
+ QCOMPARE(inv.toInt(), 0);
QCOMPARE(qjsvalue_cast<qint32>(inv), 0);
}
-void tst_QJSValue::toUInt32()
+void tst_QJSValue::toUInt()
{
QJSEngine eng;
{
- QJSValue zer0 = QJSValue(&eng, 0.0);
- QCOMPARE(zer0.toUInt32(), quint32(0));
+ QJSValue zer0 = eng.toScriptValue(0.0);
+ QCOMPARE(zer0.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(zer0), quint32(0));
- QJSValue number = QJSValue(&eng, 123.0);
- QCOMPARE(number.toUInt32(), quint32(123));
+ QJSValue number = eng.toScriptValue(123.0);
+ QCOMPARE(number.toUInt(), quint32(123));
QCOMPARE(qjsvalue_cast<quint32>(number), quint32(123));
- QJSValue number2 = QJSValue(&eng, qSNaN());
- QCOMPARE(number2.toUInt32(), quint32(0));
+ QJSValue number2 = eng.toScriptValue(qSNaN());
+ QCOMPARE(number2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(number2), quint32(0));
- QJSValue number3 = QJSValue(&eng, +qInf());
- QCOMPARE(number3.toUInt32(), quint32(0));
+ QJSValue number3 = eng.toScriptValue(+qInf());
+ QCOMPARE(number3.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(number3), quint32(0));
- QJSValue number3_2 = QJSValue(&eng, -qInf());
- QCOMPARE(number3_2.toUInt32(), quint32(0));
+ QJSValue number3_2 = eng.toScriptValue(-qInf());
+ QCOMPARE(number3_2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(number3_2), quint32(0));
- QJSValue number4 = QJSValue(&eng, 0.5);
- QCOMPARE(number4.toUInt32(), quint32(0));
+ QJSValue number4 = eng.toScriptValue(0.5);
+ QCOMPARE(number4.toUInt(), quint32(0));
- QJSValue number5 = QJSValue(&eng, 123.5);
- QCOMPARE(number5.toUInt32(), quint32(123));
+ QJSValue number5 = eng.toScriptValue(123.5);
+ QCOMPARE(number5.toUInt(), quint32(123));
- QJSValue number6 = QJSValue(&eng, -456.5);
- QCOMPARE(number6.toUInt32(), quint32(-456));
+ QJSValue number6 = eng.toScriptValue(-456.5);
+ QCOMPARE(number6.toUInt(), quint32(-456));
QCOMPARE(qjsvalue_cast<quint32>(number6), quint32(-456));
- QJSValue str = QJSValue(&eng, QLatin1String("123.0"));
- QCOMPARE(str.toUInt32(), quint32(123));
+ QJSValue str = eng.toScriptValue(QString::fromLatin1("123.0"));
+ QCOMPARE(str.toUInt(), quint32(123));
QCOMPARE(qjsvalue_cast<quint32>(str), quint32(123));
- QJSValue str2 = QJSValue(&eng, QLatin1String("NaN"));
- QCOMPARE(str2.toUInt32(), quint32(0));
+ QJSValue str2 = eng.toScriptValue(QString::fromLatin1("NaN"));
+ QCOMPARE(str2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str2), quint32(0));
- QJSValue str3 = QJSValue(&eng, QLatin1String("Infinity"));
- QCOMPARE(str3.toUInt32(), quint32(0));
+ QJSValue str3 = eng.toScriptValue(QString::fromLatin1("Infinity"));
+ QCOMPARE(str3.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str3), quint32(0));
- QJSValue str3_2 = QJSValue(&eng, QLatin1String("-Infinity"));
- QCOMPARE(str3_2.toUInt32(), quint32(0));
+ QJSValue str3_2 = eng.toScriptValue(QString::fromLatin1("-Infinity"));
+ QCOMPARE(str3_2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str3_2), quint32(0));
- QJSValue str4 = QJSValue(&eng, QLatin1String("0.5"));
- QCOMPARE(str4.toUInt32(), quint32(0));
+ QJSValue str4 = eng.toScriptValue(QString::fromLatin1("0.5"));
+ QCOMPARE(str4.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str4), quint32(0));
- QJSValue str5 = QJSValue(&eng, QLatin1String("123.5"));
- QCOMPARE(str5.toUInt32(), quint32(123));
+ QJSValue str5 = eng.toScriptValue(QString::fromLatin1("123.5"));
+ QCOMPARE(str5.toUInt(), quint32(123));
QCOMPARE(qjsvalue_cast<quint32>(str5), quint32(123));
- QJSValue str6 = QJSValue(&eng, QLatin1String("-456.5"));
- QCOMPARE(str6.toUInt32(), quint32(-456));
+ QJSValue str6 = eng.toScriptValue(QString::fromLatin1("-456.5"));
+ QCOMPARE(str6.toUInt(), quint32(-456));
QCOMPARE(qjsvalue_cast<quint32>(str6), quint32(-456));
}
// V2 constructors
{
QJSValue zer0 = QJSValue(0.0);
- QCOMPARE(zer0.toUInt32(), quint32(0));
+ QCOMPARE(zer0.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(zer0), quint32(0));
QJSValue number = QJSValue(123.0);
- QCOMPARE(number.toUInt32(), quint32(123));
+ QCOMPARE(number.toUInt(), quint32(123));
QCOMPARE(qjsvalue_cast<quint32>(number), quint32(123));
QJSValue number2 = QJSValue(qSNaN());
- QCOMPARE(number2.toUInt32(), quint32(0));
+ QCOMPARE(number2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(number2), quint32(0));
QJSValue number3 = QJSValue(+qInf());
- QCOMPARE(number3.toUInt32(), quint32(0));
+ QCOMPARE(number3.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(number3), quint32(0));
QJSValue number3_2 = QJSValue(-qInf());
- QCOMPARE(number3_2.toUInt32(), quint32(0));
+ QCOMPARE(number3_2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(number3_2), quint32(0));
QJSValue number4 = QJSValue(0.5);
- QCOMPARE(number4.toUInt32(), quint32(0));
+ QCOMPARE(number4.toUInt(), quint32(0));
QJSValue number5 = QJSValue(123.5);
- QCOMPARE(number5.toUInt32(), quint32(123));
+ QCOMPARE(number5.toUInt(), quint32(123));
QJSValue number6 = QJSValue(-456.5);
- QCOMPARE(number6.toUInt32(), quint32(-456));
+ QCOMPARE(number6.toUInt(), quint32(-456));
QCOMPARE(qjsvalue_cast<quint32>(number6), quint32(-456));
QJSValue number7 = QJSValue(0x43211234);
- QCOMPARE(number7.toUInt32(), quint32(0x43211234));
+ QCOMPARE(number7.toUInt(), quint32(0x43211234));
QJSValue str = QJSValue(QLatin1String("123.0"));
- QCOMPARE(str.toUInt32(), quint32(123));
+ QCOMPARE(str.toUInt(), quint32(123));
QCOMPARE(qjsvalue_cast<quint32>(str), quint32(123));
QJSValue str2 = QJSValue(QLatin1String("NaN"));
- QCOMPARE(str2.toUInt32(), quint32(0));
+ QCOMPARE(str2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str2), quint32(0));
QJSValue str3 = QJSValue(QLatin1String("Infinity"));
- QCOMPARE(str3.toUInt32(), quint32(0));
+ QCOMPARE(str3.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str3), quint32(0));
QJSValue str3_2 = QJSValue(QLatin1String("-Infinity"));
- QCOMPARE(str3_2.toUInt32(), quint32(0));
+ QCOMPARE(str3_2.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str3_2), quint32(0));
QJSValue str4 = QJSValue(QLatin1String("0.5"));
- QCOMPARE(str4.toUInt32(), quint32(0));
+ QCOMPARE(str4.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(str4), quint32(0));
QJSValue str5 = QJSValue(QLatin1String("123.5"));
- QCOMPARE(str5.toUInt32(), quint32(123));
+ QCOMPARE(str5.toUInt(), quint32(123));
QCOMPARE(qjsvalue_cast<quint32>(str5), quint32(123));
QJSValue str6 = QJSValue(QLatin1String("-456.5"));
- QCOMPARE(str6.toUInt32(), quint32(-456));
+ QCOMPARE(str6.toUInt(), quint32(-456));
QCOMPARE(qjsvalue_cast<quint32>(str6), quint32(-456));
}
QJSValue inv;
- QCOMPARE(inv.toUInt32(), quint32(0));
+ QCOMPARE(inv.toUInt(), quint32(0));
QCOMPARE(qjsvalue_cast<quint32>(inv), quint32(0));
}
@@ -1340,7 +1340,7 @@ void tst_QJSValue::toVariant()
listIn << 123 << "hello";
QJSValue array = qScriptValueFromValue(&eng, listIn);
QVERIFY(array.isArray());
- QCOMPARE(array.property("length").toInt32(), 2);
+ QCOMPARE(array.property("length").toInt(), 2);
QVariant ret = array.toVariant();
QCOMPARE(ret.type(), QVariant::List);
QVariantList listOut = ret.toList();
@@ -1350,8 +1350,8 @@ void tst_QJSValue::toVariant()
// round-trip conversion
QJSValue array2 = qScriptValueFromValue(&eng, ret);
QVERIFY(array2.isArray());
- QCOMPARE(array2.property("length").toInt32(), array.property("length").toInt32());
- for (int i = 0; i < array.property("length").toInt32(); ++i)
+ QCOMPARE(array2.property("length").toInt(), array.property("length").toInt());
+ for (int i = 0; i < array.property("length").toInt(); ++i)
QVERIFY(array2.property(i).strictlyEquals(array.property(i)));
}
#endif
@@ -1530,7 +1530,7 @@ void tst_QJSValue::toObject()
{
QJSValue tmp = eng.toObject(number);
QVERIFY(tmp.isObject());
- QCOMPARE(tmp.toInt32(), number.toInt32());
+ QCOMPARE(tmp.toInt(), number.toInt());
}
QVERIFY(number.isNumber());
@@ -2197,9 +2197,9 @@ void tst_QJSValue::getSetProperty_gettersAndSettersChange()
eng.globalObject().setProperty("object", object);
QJSValue res = eng.evaluate("object.x = 89; var a = object.foo; object.foo = 65; a");
- QCOMPARE(res.toInt32(), 89);
- QCOMPARE(object.property("x").toInt32(), 65);
- QCOMPARE(object.property("foo").toInt32(), 65);
+ QCOMPARE(res.toInt(), 89);
+ QCOMPARE(object.property("x").toInt(), 65);
+ QCOMPARE(object.property("foo").toInt(), 65);
#endif
}
@@ -2214,13 +2214,13 @@ void tst_QJSValue::getSetProperty_array()
array.setProperty(0, num);
QCOMPARE(array.property(0).toNumber(), num.toNumber());
QCOMPARE(array.property("0").toNumber(), num.toNumber());
- QCOMPARE(array.property("length").toUInt32(), quint32(1));
+ QCOMPARE(array.property("length").toUInt(), quint32(1));
array.setProperty(1, str);
QCOMPARE(array.property(1).toString(), str.toString());
QCOMPARE(array.property("1").toString(), str.toString());
- QCOMPARE(array.property("length").toUInt32(), quint32(2));
+ QCOMPARE(array.property("length").toUInt(), quint32(2));
array.setProperty("length", QJSValue(&eng, 1));
- QCOMPARE(array.property("length").toUInt32(), quint32(1));
+ QCOMPARE(array.property("length").toUInt(), quint32(1));
QCOMPARE(array.property(1).isValid(), false);
}
@@ -2582,7 +2582,7 @@ void tst_QJSValue::getSetScope()
{
QJSValue ret = object2.property("foo", QJSValue::ResolveScope);
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
QJSValue inv;
@@ -2819,7 +2819,7 @@ void tst_QJSValue::call_function()
QVERIFY(fun.isFunction());
QJSValue result = fun.call();
QVERIFY(result.isNumber());
- QCOMPARE(result.toInt32(), 1);
+ QCOMPARE(result.toInt(), 1);
}
void tst_QJSValue::call_object()
@@ -3175,7 +3175,7 @@ void tst_QJSValue::construct_simple()
QJSValue ret = fun.construct();
QVERIFY(ret.isObject());
QVERIFY(ret.instanceOf(fun));
- QCOMPARE(ret.property("foo").toInt32(), 123);
+ QCOMPARE(ret.property("foo").toInt(), 123);
}
void tst_QJSValue::construct_newObjectJS()
@@ -3187,7 +3187,7 @@ void tst_QJSValue::construct_newObjectJS()
QJSValue ret = fun.construct();
QVERIFY(ret.isObject());
QVERIFY(!ret.instanceOf(fun));
- QCOMPARE(ret.property("bar").toInt32(), 456);
+ QCOMPARE(ret.property("bar").toInt(), 456);
}
#if 0 // FIXME: no c-style callbacks
@@ -3198,7 +3198,7 @@ void tst_QJSValue::construct_undefined()
QJSValue ret = fun.construct();
QVERIFY(ret.isObject());
QVERIFY(ret.instanceOf(fun));
- QCOMPARE(ret.property("foo").toInt32(), 123);
+ QCOMPARE(ret.property("foo").toInt(), 123);
}
void tst_QJSValue::construct_newObjectCpp()
@@ -3208,7 +3208,7 @@ void tst_QJSValue::construct_newObjectCpp()
QJSValue ret = fun.construct();
QVERIFY(ret.isObject());
QVERIFY(!ret.instanceOf(fun));
- QCOMPARE(ret.property("bar").toInt32(), 456);
+ QCOMPARE(ret.property("bar").toInt(), 456);
}
#endif
@@ -4040,7 +4040,7 @@ void tst_QJSValue::valueOfWithClosure()
{
QJSValue obj = eng.evaluate("o = {}; (function(foo) { o.valueOf = function() { return foo; } })(123); o");
QVERIFY(obj.isObject());
- QCOMPARE(obj.toInt32(), 123);
+ QCOMPARE(obj.toInt(), 123);
}
// toString()
{
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h b/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
index 7696f61a06..b07d746139 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
+++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
@@ -86,8 +86,8 @@ private slots:
void toBoolean();
void toBool();
void toInteger();
- void toInt32();
- void toUInt32();
+ void toInt();
+ void toUInt();
void toUInt16();
void toVariant();
void toQObject_nonQObject_data();
diff --git a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp
index d8a490f694..bc42e7bc2d 100644
--- a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp
+++ b/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp
@@ -173,7 +173,7 @@ void tst_QJSValueIterator::iterateArray()
// Iterate thru array properties. Note that the QJSValueIterator doesn't guarantee
// any order on the iteration!
- int length = array.property("length").toInt32();
+ int length = array.property("length").toInt();
QCOMPARE(length, propertyNames.size());
bool iteratedThruLength = false;
@@ -187,7 +187,7 @@ void tst_QJSValueIterator::iterateArray()
const QString name = it.name();
if (name == QString::fromLatin1("length")) {
QVERIFY(it.value().isNumber());
- QCOMPARE(it.value().toInt32(), length);
+ QCOMPARE(it.value().toInt(), length);
QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration.");
iteratedThruLength = true;
continue;
@@ -220,7 +220,7 @@ void tst_QJSValueIterator::iterateArray()
const QString name = it.name();
if (name == QString::fromLatin1("length")) {
QVERIFY(it.value().isNumber());
- QCOMPARE(it.value().toInt32(), length);
+ QCOMPARE(it.value().toInt(), length);
QCOMPARE(it.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable);
QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration.");
iteratedThruLength = true;
@@ -255,7 +255,7 @@ void tst_QJSValueIterator::iterateArray()
const QString name = it2.name();
if (name == QString::fromLatin1("length")) {
QVERIFY(it2.value().isNumber());
- QCOMPARE(it2.value().toInt32(), length);
+ QCOMPARE(it2.value().toInt(), length);
QCOMPARE(it2.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable);
QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration.");
iteratedThruLength = true;
@@ -286,7 +286,7 @@ void tst_QJSValueIterator::iterateString()
QVERIFY(str.isString());
QJSValue obj = str.toObject();
QVERIFY(obj.property("length").isNumber());
- int length = obj.property("length").toInt32();
+ int length = obj.property("length").toInt();
QCOMPARE(length, 4);
QJSValueIterator it(obj);
@@ -299,7 +299,7 @@ void tst_QJSValueIterator::iterateString()
if (name == QString::fromLatin1("length")) {
QVERIFY(it.value().isNumber());
- QCOMPARE(it.value().toInt32(), length);
+ QCOMPARE(it.value().toInt(), length);
QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration.");
iteratedThruLength = true;
continue;
@@ -324,7 +324,7 @@ void tst_QJSValueIterator::iterateString()
if (name == QString::fromLatin1("length")) {
QVERIFY(it.value().isNumber());
- QCOMPARE(it.value().toInt32(), length);
+ QCOMPARE(it.value().toInt(), length);
QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration.");
iteratedThruLength = true;
continue;