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
{
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
{
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
{
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);
}
}
{
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);
}
}
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());
}
{
QScriptValue ret = obj.property("foo");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
QVERIFY(!obj.property("bar").isValid());
{
QScriptValue ret = obj.property("bar");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 456);
+ QCOMPARE(ret.toInt(), 456);
}
QVERIFY(!obj.property("baz").isValid());
{
QScriptValue ret = obj.property("baz");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 789);
+ QCOMPARE(ret.toInt(), 789);
}
{
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)
static void fooFromScriptValueV2(const QJSValue &value, Foo &foo)
{
- foo.x = value.toInt32();
+ foo.x = value.toInt();
}
Q_DECLARE_METATYPE(QLinkedList<QString>)
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);
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);
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);
}
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);
{
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);
}
}
// 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;
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
{
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)");
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");
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");
{
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
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");
{
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);
}
{
case EventReceiver3::Number:
QVERIFY(!eng.hasUncaughtException());
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 1234);
+ QCOMPARE(ret.toInt(), 1234);
break;
case EventReceiver3::String:
QVERIFY(!eng.hasUncaughtException());
case EventReceiver3::Number:
QVERIFY(!eng.hasUncaughtException());
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 1234);
+ QCOMPARE(ret.toInt(), 1234);
break;
case EventReceiver3::String:
QVERIFY(!eng.hasUncaughtException());
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);
}
}
}
{
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());
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;
// 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());
}
}
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
// 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);
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());
{
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"));
}
}
" }\n"
"}; j");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
// for - switch - case - default - continue
{
" }\n"
"}; j");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 3);
+ QCOMPARE(ret.toInt(), 3);
}
// switch - for - continue
{
" }\n"
"}; i\n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 100000);
+ QCOMPARE(ret.toInt(), 100000);
}
// switch - switch - continue
{
" }\n"
"}; j");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 1);
+ QCOMPARE(ret.toInt(), 1);
}
// switch - for - switch - continue
{
" }\n"
"}; i\n");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 100000);
+ QCOMPARE(ret.toInt(), 100000);
}
}
// 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());
}
" }"
"}");
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
QVERIFY(eng.hasUncaughtException());
}
{
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);
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()
{
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);
}
}
{
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);
}
{
QScriptValue ret = fun.call();
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 456);
+ QCOMPARE(ret.toInt(), 456);
}
scope = scope.scope();
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;
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++; })");
}
QScriptValue ret = cnt.call();
QVERIFY(ret.isNumber());
QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue);
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
}
{
{
QScriptValue ret = cnt.call();
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
}
QScriptValue ret = eng.evaluate(program);
QVERIFY(!ret.isError());
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
}
}
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();
}
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
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 {
{
QJSValue v(int(0x43211234));
QVERIFY(v.isNumber());
- QCOMPARE(v.toInt32(), 0x43211234);
+ QCOMPARE(v.toInt(), 0x43211234);
}
{
QJSValue v(int(1));
{
QJSValue v(uint(0x43211234));
QVERIFY(v.isNumber());
- QCOMPARE(v.toUInt32(), uint(0x43211234));
+ QCOMPARE(v.toUInt(), uint(0x43211234));
}
{
QJSValue v(uint(1));
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));
}
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();
// 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
{
QJSValue tmp = eng.toObject(number);
QVERIFY(tmp.isObject());
- QCOMPARE(tmp.toInt32(), number.toInt32());
+ QCOMPARE(tmp.toInt(), number.toInt());
}
QVERIFY(number.isNumber());
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
}
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);
}
{
QJSValue ret = object2.property("foo", QJSValue::ResolveScope);
QVERIFY(ret.isNumber());
- QCOMPARE(ret.toInt32(), 123);
+ QCOMPARE(ret.toInt(), 123);
}
QJSValue inv;
QVERIFY(fun.isFunction());
QJSValue result = fun.call();
QVERIFY(result.isNumber());
- QCOMPARE(result.toInt32(), 1);
+ QCOMPARE(result.toInt(), 1);
}
void tst_QJSValue::call_object()
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()
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
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()
QJSValue ret = fun.construct();
QVERIFY(ret.isObject());
QVERIFY(!ret.instanceOf(fun));
- QCOMPARE(ret.property("bar").toInt32(), 456);
+ QCOMPARE(ret.property("bar").toInt(), 456);
}
#endif
{
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()
{