[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
eric at webkit.org
eric at webkit.org
Wed Mar 17 18:14:42 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 74428b6644089630acf4d718f22189a1d93b04ba
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Mar 4 05:02:07 2010 +0000
2010-03-03 Jedrzej Nowacki <jedrzej.nowacki at nokia.com>
Reviewed by Simon Hausmann.
QScriptValue::isObject fix.
Fix broken internal state evaluation from JSValue to JSNative / JSObject.
New function was introduced which should take care about promoting
JSValue state inside QScriptValuePrivate. It should be used instead of a
direct JSC C API call.
The bug exposed a weakness in autotest suite, as the QScriptValuePrivate
is based on state machine with lazy state evaluation, there is a possibility
that serial sequencial calls to the same public const function could return
different results. The patch fix the issue.
[Qt] Sometimes QScriptValue::isObject returns an incorrect value
https://bugs.webkit.org/show_bug.cgi?id=35387
* qt/api/qscriptvalue_p.h:
(QScriptValuePrivate::isBool):
(QScriptValuePrivate::isNumber):
(QScriptValuePrivate::isNull):
(QScriptValuePrivate::isString):
(QScriptValuePrivate::isUndefined):
(QScriptValuePrivate::isError):
(QScriptValuePrivate::isObject):
(QScriptValuePrivate::isFunction):
(QScriptValuePrivate::call):
(QScriptValuePrivate::refineJSValue):
* qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp:
(tst_QScriptValue::initScriptValues):
(tst_QScriptValue::isValid_makeData):
(tst_QScriptValue::isValid_test):
(tst_QScriptValue::isBool_makeData):
(tst_QScriptValue::isBool_test):
(tst_QScriptValue::isBoolean_makeData):
(tst_QScriptValue::isBoolean_test):
(tst_QScriptValue::isNumber_makeData):
(tst_QScriptValue::isNumber_test):
(tst_QScriptValue::isFunction_test):
(tst_QScriptValue::isNull_makeData):
(tst_QScriptValue::isNull_test):
(tst_QScriptValue::isString_makeData):
(tst_QScriptValue::isString_test):
(tst_QScriptValue::isUndefined_makeData):
(tst_QScriptValue::isUndefined_test):
(tst_QScriptValue::isObject_makeData):
(tst_QScriptValue::isObject_test):
(tst_QScriptValue::toString_makeData):
(tst_QScriptValue::toString_test):
(tst_QScriptValue::toNumber_makeData):
(tst_QScriptValue::toNumber_test):
(tst_QScriptValue::toBool_makeData):
(tst_QScriptValue::toBool_test):
(tst_QScriptValue::toBoolean_makeData):
(tst_QScriptValue::toBoolean_test):
(tst_QScriptValue::toInteger_makeData):
(tst_QScriptValue::toInteger_test):
(tst_QScriptValue::toInt32_makeData):
(tst_QScriptValue::toInt32_test):
(tst_QScriptValue::toUInt32_makeData):
(tst_QScriptValue::toUInt32_test):
(tst_QScriptValue::toUInt16_makeData):
(tst_QScriptValue::toUInt16_test):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55502 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index fdee5ea..ddde2a8 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,69 @@
+2010-03-03 Jedrzej Nowacki <jedrzej.nowacki at nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ QScriptValue::isObject fix.
+
+ Fix broken internal state evaluation from JSValue to JSNative / JSObject.
+ New function was introduced which should take care about promoting
+ JSValue state inside QScriptValuePrivate. It should be used instead of a
+ direct JSC C API call.
+
+ The bug exposed a weakness in autotest suite, as the QScriptValuePrivate
+ is based on state machine with lazy state evaluation, there is a possibility
+ that serial sequencial calls to the same public const function could return
+ different results. The patch fix the issue.
+
+ [Qt] Sometimes QScriptValue::isObject returns an incorrect value
+ https://bugs.webkit.org/show_bug.cgi?id=35387
+
+ * qt/api/qscriptvalue_p.h:
+ (QScriptValuePrivate::isBool):
+ (QScriptValuePrivate::isNumber):
+ (QScriptValuePrivate::isNull):
+ (QScriptValuePrivate::isString):
+ (QScriptValuePrivate::isUndefined):
+ (QScriptValuePrivate::isError):
+ (QScriptValuePrivate::isObject):
+ (QScriptValuePrivate::isFunction):
+ (QScriptValuePrivate::call):
+ (QScriptValuePrivate::refineJSValue):
+ * qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp:
+ (tst_QScriptValue::initScriptValues):
+ (tst_QScriptValue::isValid_makeData):
+ (tst_QScriptValue::isValid_test):
+ (tst_QScriptValue::isBool_makeData):
+ (tst_QScriptValue::isBool_test):
+ (tst_QScriptValue::isBoolean_makeData):
+ (tst_QScriptValue::isBoolean_test):
+ (tst_QScriptValue::isNumber_makeData):
+ (tst_QScriptValue::isNumber_test):
+ (tst_QScriptValue::isFunction_test):
+ (tst_QScriptValue::isNull_makeData):
+ (tst_QScriptValue::isNull_test):
+ (tst_QScriptValue::isString_makeData):
+ (tst_QScriptValue::isString_test):
+ (tst_QScriptValue::isUndefined_makeData):
+ (tst_QScriptValue::isUndefined_test):
+ (tst_QScriptValue::isObject_makeData):
+ (tst_QScriptValue::isObject_test):
+ (tst_QScriptValue::toString_makeData):
+ (tst_QScriptValue::toString_test):
+ (tst_QScriptValue::toNumber_makeData):
+ (tst_QScriptValue::toNumber_test):
+ (tst_QScriptValue::toBool_makeData):
+ (tst_QScriptValue::toBool_test):
+ (tst_QScriptValue::toBoolean_makeData):
+ (tst_QScriptValue::toBoolean_test):
+ (tst_QScriptValue::toInteger_makeData):
+ (tst_QScriptValue::toInteger_test):
+ (tst_QScriptValue::toInt32_makeData):
+ (tst_QScriptValue::toInt32_test):
+ (tst_QScriptValue::toUInt32_makeData):
+ (tst_QScriptValue::toUInt32_test):
+ (tst_QScriptValue::toUInt16_makeData):
+ (tst_QScriptValue::toUInt16_test):
+
2010-03-03 Chao-ying Fu <fu at mips.com>
Reviewed by Gavin Barraclough.
diff --git a/JavaScriptCore/qt/api/qscriptvalue_p.h b/JavaScriptCore/qt/api/qscriptvalue_p.h
index f528e5b..182f603 100644
--- a/JavaScriptCore/qt/api/qscriptvalue_p.h
+++ b/JavaScriptCore/qt/api/qscriptvalue_p.h
@@ -136,6 +136,7 @@ private:
inline void setValue(JSValueRef);
inline bool inherits(const char*);
+ inline States refinedJSValue();
inline bool isJSBased() const;
inline bool isNumberBased() const;
@@ -325,7 +326,7 @@ bool QScriptValuePrivate::isBool()
case CBool:
return true;
case JSValue:
- if (isObject())
+ if (refinedJSValue() != JSNative)
return false;
// Fall-through.
case JSNative:
@@ -341,7 +342,7 @@ bool QScriptValuePrivate::isNumber()
case CNumber:
return true;
case JSValue:
- if (isObject())
+ if (refinedJSValue() != JSNative)
return false;
// Fall-through.
case JSNative:
@@ -357,7 +358,7 @@ bool QScriptValuePrivate::isNull()
case CSpecial:
return m_number == static_cast<int>(QScriptValue::NullValue);
case JSValue:
- if (isObject())
+ if (refinedJSValue() != JSNative)
return false;
// Fall-through.
case JSNative:
@@ -373,7 +374,7 @@ bool QScriptValuePrivate::isString()
case CString:
return true;
case JSValue:
- if (isObject())
+ if (refinedJSValue() != JSNative)
return false;
// Fall-through.
case JSNative:
@@ -389,7 +390,7 @@ bool QScriptValuePrivate::isUndefined()
case CSpecial:
return m_number == static_cast<int>(QScriptValue::UndefinedValue);
case JSValue:
- if (isObject())
+ if (refinedJSValue() != JSNative)
return false;
// Fall-through.
case JSNative:
@@ -403,7 +404,7 @@ bool QScriptValuePrivate::isError()
{
switch (m_state) {
case JSValue:
- if (!isObject())
+ if (refinedJSValue() != JSObject)
return false;
// Fall-through.
case JSObject:
@@ -416,14 +417,11 @@ bool QScriptValuePrivate::isError()
bool QScriptValuePrivate::isObject()
{
switch (m_state) {
- case JSObject:
- return true;
case JSValue:
- m_object = JSValueToObject(context(), value(), /* exception */ 0);
- if (!m_object)
- return false;
- m_state = JSObject;
+ return refinedJSValue() == JSObject;
+ case JSObject:
return true;
+
default:
return false;
}
@@ -433,10 +431,8 @@ bool QScriptValuePrivate::isFunction()
{
switch (m_state) {
case JSValue:
- m_object = JSValueToObject(context(), value(), /* exception */ 0);
- if (!m_object)
+ if (refinedJSValue() != JSObject)
return false;
- m_state = JSObject;
// Fall-through.
case JSObject:
return JSObjectIsFunction(context(), object());
@@ -640,12 +636,8 @@ QScriptValuePrivate* QScriptValuePrivate::call(const QScriptValuePrivate*, const
{
switch (m_state) {
case JSValue:
- m_object = JSValueToObject(context(), value(), /* exception */ 0);
- if (!object()) {
- m_state = JSValue;
+ if (refinedJSValue() != JSObject)
return new QScriptValuePrivate;
- }
- m_state = JSObject;
// Fall-through.
case JSObject:
{
@@ -725,6 +717,24 @@ bool QScriptValuePrivate::inherits(const char* name)
/*!
\internal
+ Refines the state of this QScriptValuePrivate. Returns the new state.
+*/
+QScriptValuePrivate::States QScriptValuePrivate::refinedJSValue()
+{
+ Q_ASSERT(m_state == JSValue);
+ if (!JSValueIsObject(context(), value())) {
+ m_state = JSNative;
+ } else {
+ m_state = JSObject;
+ // We are sure that value is an JSObject, so we can const_cast safely without
+ // calling JSC C API (JSValueToObject(context(), value(), /* exceptions */ 0)).
+ m_object = const_cast<JSObjectRef>(m_value);
+ }
+ return m_state;
+}
+
+/*!
+ \internal
Returns true if QSV have an engine associated.
*/
bool QScriptValuePrivate::isJSBased() const { return m_state >= JSValue; }
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp
index b66cac2..970c960 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp
@@ -130,6 +130,35 @@ void tst_QScriptValue::initScriptValues()
DEFINE_TEST_VALUE(engine->evaluate("new Object()"));
DEFINE_TEST_VALUE(engine->evaluate("new Array()"));
DEFINE_TEST_VALUE(engine->evaluate("new Error()"));
+ DEFINE_TEST_VALUE(engine->evaluate("a = new Object(); a.foo = 22; a.foo"));
+ DEFINE_TEST_VALUE(engine->evaluate("Undefined"));
+ DEFINE_TEST_VALUE(engine->evaluate("Null"));
+ DEFINE_TEST_VALUE(engine->evaluate("True"));
+ DEFINE_TEST_VALUE(engine->evaluate("False"));
+ DEFINE_TEST_VALUE(engine->evaluate("undefined"));
+ DEFINE_TEST_VALUE(engine->evaluate("null"));
+ DEFINE_TEST_VALUE(engine->evaluate("true"));
+ DEFINE_TEST_VALUE(engine->evaluate("false"));
+ DEFINE_TEST_VALUE(engine->evaluate("122"));
+ DEFINE_TEST_VALUE(engine->evaluate("124"));
+ DEFINE_TEST_VALUE(engine->evaluate("0"));
+ DEFINE_TEST_VALUE(engine->evaluate("0.0"));
+ DEFINE_TEST_VALUE(engine->evaluate("123.0"));
+ DEFINE_TEST_VALUE(engine->evaluate("6.37e-8"));
+ DEFINE_TEST_VALUE(engine->evaluate("-6.37e-8"));
+ DEFINE_TEST_VALUE(engine->evaluate("0x43211234"));
+ DEFINE_TEST_VALUE(engine->evaluate("0x10000"));
+ DEFINE_TEST_VALUE(engine->evaluate("0x10001"));
+ DEFINE_TEST_VALUE(engine->evaluate("NaN"));
+ DEFINE_TEST_VALUE(engine->evaluate("Infinity"));
+ DEFINE_TEST_VALUE(engine->evaluate("-Infinity"));
+ DEFINE_TEST_VALUE(engine->evaluate("'ciao'"));
+ DEFINE_TEST_VALUE(engine->evaluate("''"));
+ DEFINE_TEST_VALUE(engine->evaluate("'0'"));
+ DEFINE_TEST_VALUE(engine->evaluate("'123'"));
+ DEFINE_TEST_VALUE(engine->evaluate("'12.4'"));
+ DEFINE_TEST_VALUE(engine->nullValue());
+ DEFINE_TEST_VALUE(engine->undefinedValue());
}
@@ -244,7 +273,36 @@ void tst_QScriptValue::isValid_makeData(const char* expr)
<< "engine->evaluate(\"/foo/\")"
<< "engine->evaluate(\"new Object()\")"
<< "engine->evaluate(\"new Array()\")"
- << "engine->evaluate(\"new Error()\")";
+ << "engine->evaluate(\"new Error()\")"
+ << "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()";
}
newRow(expr) << isValid.contains(expr);
}
@@ -253,6 +311,7 @@ void tst_QScriptValue::isValid_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isValid(), expected);
+ QCOMPARE(value.isValid(), expected);
}
DEFINE_TEST_FUNCTION(isValid)
@@ -273,7 +332,9 @@ void tst_QScriptValue::isBool_makeData(const char* expr)
<< "QScriptValue(0, true)"
<< "QScriptValue(0, false)"
<< "QScriptValue(engine, true)"
- << "QScriptValue(engine, false)";
+ << "QScriptValue(engine, false)"
+ << "engine->evaluate(\"true\")"
+ << "engine->evaluate(\"false\")";
}
newRow(expr) << isBool.contains(expr);
}
@@ -282,6 +343,7 @@ void tst_QScriptValue::isBool_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isBool(), expected);
+ QCOMPARE(value.isBool(), expected);
}
DEFINE_TEST_FUNCTION(isBool)
@@ -302,7 +364,9 @@ void tst_QScriptValue::isBoolean_makeData(const char* expr)
<< "QScriptValue(0, true)"
<< "QScriptValue(0, false)"
<< "QScriptValue(engine, true)"
- << "QScriptValue(engine, false)";
+ << "QScriptValue(engine, false)"
+ << "engine->evaluate(\"true\")"
+ << "engine->evaluate(\"false\")";
}
newRow(expr) << isBoolean.contains(expr);
}
@@ -311,10 +375,12 @@ void tst_QScriptValue::isBoolean_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isBoolean(), expected);
+ QCOMPARE(value.isBoolean(), expected);
}
DEFINE_TEST_FUNCTION(isBoolean)
+
void tst_QScriptValue::isNumber_initData()
{
QTest::addColumn<bool>("expected");
@@ -366,7 +432,21 @@ void tst_QScriptValue::isNumber_makeData(const char* expr)
<< "QScriptValue(engine, qSNaN())"
<< "QScriptValue(engine, qQNaN())"
<< "QScriptValue(engine, qInf())"
- << "QScriptValue(engine, -qInf())";
+ << "QScriptValue(engine, -qInf())"
+ << "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")"
+ << "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\")";
}
newRow(expr) << isNumber.contains(expr);
}
@@ -375,6 +455,7 @@ void tst_QScriptValue::isNumber_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isNumber(), expected);
+ QCOMPARE(value.isNumber(), expected);
}
DEFINE_TEST_FUNCTION(isNumber)
@@ -407,6 +488,7 @@ void tst_QScriptValue::isFunction_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isFunction(), expected);
+ QCOMPARE(value.isFunction(), expected);
}
DEFINE_TEST_FUNCTION(isFunction)
@@ -424,7 +506,9 @@ void tst_QScriptValue::isNull_makeData(const char* expr)
if (isNull.isEmpty()) {
isNull << "QScriptValue(QScriptValue::NullValue)"
<< "QScriptValue(0, QScriptValue::NullValue)"
- << "QScriptValue(engine, QScriptValue::NullValue)";
+ << "QScriptValue(engine, QScriptValue::NullValue)"
+ << "engine->evaluate(\"null\")"
+ << "engine->nullValue()";
}
newRow(expr) << isNull.contains(expr);
}
@@ -433,6 +517,7 @@ void tst_QScriptValue::isNull_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isNull(), expected);
+ QCOMPARE(value.isNull(), expected);
}
DEFINE_TEST_FUNCTION(isNull)
@@ -477,7 +562,12 @@ void tst_QScriptValue::isString_makeData(const char* expr)
<< "QScriptValue(engine, QString())"
<< "QScriptValue(engine, QString(\"0\"))"
<< "QScriptValue(engine, QString(\"123\"))"
- << "QScriptValue(engine, QString(\"1.23\"))";
+ << "QScriptValue(engine, QString(\"1.23\"))"
+ << "engine->evaluate(\"'ciao'\")"
+ << "engine->evaluate(\"''\")"
+ << "engine->evaluate(\"'0'\")"
+ << "engine->evaluate(\"'123'\")"
+ << "engine->evaluate(\"'12.4'\")";
}
newRow(expr) << isString.contains(expr);
}
@@ -486,6 +576,7 @@ void tst_QScriptValue::isString_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isString(), expected);
+ QCOMPARE(value.isString(), expected);
}
DEFINE_TEST_FUNCTION(isString)
@@ -504,7 +595,9 @@ void tst_QScriptValue::isUndefined_makeData(const char* expr)
isUndefined << "QScriptValue(QScriptValue::UndefinedValue)"
<< "QScriptValue(0, QScriptValue::UndefinedValue)"
<< "QScriptValue(engine, QScriptValue::UndefinedValue)"
- << "engine->evaluate(\"{}\")";
+ << "engine->evaluate(\"{}\")"
+ << "engine->evaluate(\"undefined\")"
+ << "engine->undefinedValue()";
}
newRow(expr) << isUndefined.contains(expr);
}
@@ -513,10 +606,15 @@ void tst_QScriptValue::isUndefined_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isUndefined(), expected);
+ QCOMPARE(value.isUndefined(), expected);
}
DEFINE_TEST_FUNCTION(isUndefined)
+
+
+
+
void tst_QScriptValue::isObject_initData()
{
QTest::addColumn<bool>("expected");
@@ -543,7 +641,11 @@ void tst_QScriptValue::isObject_makeData(const char* expr)
<< "engine->evaluate(\"/foo/\")"
<< "engine->evaluate(\"new Object()\")"
<< "engine->evaluate(\"new Array()\")"
- << "engine->evaluate(\"new Error()\")";
+ << "engine->evaluate(\"new Error()\")"
+ << "engine->evaluate(\"Undefined\")"
+ << "engine->evaluate(\"Null\")"
+ << "engine->evaluate(\"True\")"
+ << "engine->evaluate(\"False\")";
}
newRow(expr) << isObject.contains(expr);
}
@@ -552,10 +654,12 @@ void tst_QScriptValue::isObject_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.isObject(), expected);
+ QCOMPARE(value.isObject(), expected);
}
DEFINE_TEST_FUNCTION(isObject)
+
void tst_QScriptValue::toString_initData()
{
QTest::addColumn<QString>("expected");
@@ -669,6 +773,35 @@ void tst_QScriptValue::toString_makeData(const char* expr)
toString.insert("engine->evaluate(\"new Object()\")", "[object Object]");
toString.insert("engine->evaluate(\"new Array()\")", "");
toString.insert("engine->evaluate(\"new Error()\")", "Error: Unknown error");
+ toString.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", "22");
+ toString.insert("engine->evaluate(\"Undefined\")", "ReferenceError: Can't find variable: Undefined");
+ toString.insert("engine->evaluate(\"Null\")", "ReferenceError: Can't find variable: Null");
+ toString.insert("engine->evaluate(\"True\")", "ReferenceError: Can't find variable: True");
+ toString.insert("engine->evaluate(\"False\")", "ReferenceError: Can't find variable: False");
+ toString.insert("engine->evaluate(\"undefined\")", "undefined");
+ toString.insert("engine->evaluate(\"null\")", "null");
+ toString.insert("engine->evaluate(\"true\")", "true");
+ toString.insert("engine->evaluate(\"false\")", "false");
+ toString.insert("engine->evaluate(\"122\")", "122");
+ toString.insert("engine->evaluate(\"124\")", "124");
+ toString.insert("engine->evaluate(\"0\")", "0");
+ toString.insert("engine->evaluate(\"0.0\")", "0");
+ toString.insert("engine->evaluate(\"123.0\")", "123");
+ toString.insert("engine->evaluate(\"6.37e-8\")", "6.37e-8");
+ toString.insert("engine->evaluate(\"-6.37e-8\")", "-6.37e-8");
+ toString.insert("engine->evaluate(\"0x43211234\")", "1126240820");
+ toString.insert("engine->evaluate(\"0x10000\")", "65536");
+ toString.insert("engine->evaluate(\"0x10001\")", "65537");
+ toString.insert("engine->evaluate(\"NaN\")", "NaN");
+ toString.insert("engine->evaluate(\"Infinity\")", "Infinity");
+ toString.insert("engine->evaluate(\"-Infinity\")", "-Infinity");
+ toString.insert("engine->evaluate(\"'ciao'\")", "ciao");
+ toString.insert("engine->evaluate(\"''\")", "");
+ toString.insert("engine->evaluate(\"'0'\")", "0");
+ toString.insert("engine->evaluate(\"'123'\")", "123");
+ toString.insert("engine->evaluate(\"'12.4'\")", "12.4");
+ toString.insert("engine->nullValue()", "null");
+ toString.insert("engine->undefinedValue()", "undefined");
}
newRow(expr) << toString.value(expr);
}
@@ -677,10 +810,12 @@ void tst_QScriptValue::toString_test(const char*, const QScriptValue& value)
{
QFETCH(QString, expected);
QCOMPARE(value.toString(), expected);
+ QCOMPARE(value.toString(), expected);
}
DEFINE_TEST_FUNCTION(toString)
+
void tst_QScriptValue::toNumber_initData()
{
QTest::addColumn<qsreal>("expected");
@@ -794,6 +929,35 @@ void tst_QScriptValue::toNumber_makeData(const char* expr)
toNumber.insert("engine->evaluate(\"new Object()\")", qQNaN());
toNumber.insert("engine->evaluate(\"new Array()\")", 0);
toNumber.insert("engine->evaluate(\"new Error()\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
+ toNumber.insert("engine->evaluate(\"Undefined\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"Null\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"True\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"False\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"undefined\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"null\")", 0);
+ toNumber.insert("engine->evaluate(\"true\")", 1);
+ toNumber.insert("engine->evaluate(\"false\")", 0);
+ toNumber.insert("engine->evaluate(\"122\")", 122);
+ toNumber.insert("engine->evaluate(\"124\")", 124);
+ toNumber.insert("engine->evaluate(\"0\")", 0);
+ toNumber.insert("engine->evaluate(\"0.0\")", 0);
+ toNumber.insert("engine->evaluate(\"123.0\")", 123);
+ toNumber.insert("engine->evaluate(\"6.37e-8\")", 6.369999999999999e-08);
+ toNumber.insert("engine->evaluate(\"-6.37e-8\")", -6.369999999999999e-08);
+ toNumber.insert("engine->evaluate(\"0x43211234\")", 1126240820);
+ toNumber.insert("engine->evaluate(\"0x10000\")", 65536);
+ toNumber.insert("engine->evaluate(\"0x10001\")", 65537);
+ toNumber.insert("engine->evaluate(\"NaN\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"Infinity\")", qInf());
+ toNumber.insert("engine->evaluate(\"-Infinity\")", qInf());
+ toNumber.insert("engine->evaluate(\"'ciao'\")", qQNaN());
+ toNumber.insert("engine->evaluate(\"''\")", 0);
+ toNumber.insert("engine->evaluate(\"'0'\")", 0);
+ toNumber.insert("engine->evaluate(\"'123'\")", 123);
+ toNumber.insert("engine->evaluate(\"'12.4'\")", 12.4);
+ toNumber.insert("engine->nullValue()", 0);
+ toNumber.insert("engine->undefinedValue()", qQNaN());
}
newRow(expr) << toNumber.value(expr);
}
@@ -807,9 +971,11 @@ void tst_QScriptValue::toNumber_test(const char*, const QScriptValue& value)
}
if (qIsInf(expected)) {
QVERIFY(qIsInf(value.toNumber()));
+ QVERIFY(qIsInf(value.toNumber()));
return;
}
QCOMPARE(value.toNumber(), expected);
+ QCOMPARE(value.toNumber(), expected);
}
DEFINE_TEST_FUNCTION(toNumber)
@@ -928,6 +1094,35 @@ void tst_QScriptValue::toBool_makeData(const char* expr)
toBool.insert("engine->evaluate(\"new Object()\")", true);
toBool.insert("engine->evaluate(\"new Array()\")", true);
toBool.insert("engine->evaluate(\"new Error()\")", true);
+ toBool.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", true);
+ toBool.insert("engine->evaluate(\"Undefined\")", true);
+ toBool.insert("engine->evaluate(\"Null\")", true);
+ toBool.insert("engine->evaluate(\"True\")", true);
+ toBool.insert("engine->evaluate(\"False\")", true);
+ toBool.insert("engine->evaluate(\"undefined\")", false);
+ toBool.insert("engine->evaluate(\"null\")", false);
+ toBool.insert("engine->evaluate(\"true\")", true);
+ toBool.insert("engine->evaluate(\"false\")", false);
+ toBool.insert("engine->evaluate(\"122\")", true);
+ toBool.insert("engine->evaluate(\"124\")", true);
+ toBool.insert("engine->evaluate(\"0\")", false);
+ toBool.insert("engine->evaluate(\"0.0\")", false);
+ toBool.insert("engine->evaluate(\"123.0\")", true);
+ toBool.insert("engine->evaluate(\"6.37e-8\")", true);
+ toBool.insert("engine->evaluate(\"-6.37e-8\")", true);
+ toBool.insert("engine->evaluate(\"0x43211234\")", true);
+ toBool.insert("engine->evaluate(\"0x10000\")", true);
+ toBool.insert("engine->evaluate(\"0x10001\")", true);
+ toBool.insert("engine->evaluate(\"NaN\")", false);
+ toBool.insert("engine->evaluate(\"Infinity\")", true);
+ toBool.insert("engine->evaluate(\"-Infinity\")", true);
+ toBool.insert("engine->evaluate(\"'ciao'\")", true);
+ toBool.insert("engine->evaluate(\"''\")", false);
+ toBool.insert("engine->evaluate(\"'0'\")", true);
+ toBool.insert("engine->evaluate(\"'123'\")", true);
+ toBool.insert("engine->evaluate(\"'12.4'\")", true);
+ toBool.insert("engine->nullValue()", false);
+ toBool.insert("engine->undefinedValue()", false);
}
newRow(expr) << toBool.value(expr);
}
@@ -936,6 +1131,7 @@ void tst_QScriptValue::toBool_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.toBool(), expected);
+ QCOMPARE(value.toBool(), expected);
}
DEFINE_TEST_FUNCTION(toBool)
@@ -1054,6 +1250,35 @@ void tst_QScriptValue::toBoolean_makeData(const char* expr)
toBoolean.insert("engine->evaluate(\"new Object()\")", true);
toBoolean.insert("engine->evaluate(\"new Array()\")", true);
toBoolean.insert("engine->evaluate(\"new Error()\")", true);
+ toBoolean.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", true);
+ toBoolean.insert("engine->evaluate(\"Undefined\")", true);
+ toBoolean.insert("engine->evaluate(\"Null\")", true);
+ toBoolean.insert("engine->evaluate(\"True\")", true);
+ toBoolean.insert("engine->evaluate(\"False\")", true);
+ toBoolean.insert("engine->evaluate(\"undefined\")", false);
+ toBoolean.insert("engine->evaluate(\"null\")", false);
+ toBoolean.insert("engine->evaluate(\"true\")", true);
+ toBoolean.insert("engine->evaluate(\"false\")", false);
+ toBoolean.insert("engine->evaluate(\"122\")", true);
+ toBoolean.insert("engine->evaluate(\"124\")", true);
+ toBoolean.insert("engine->evaluate(\"0\")", false);
+ toBoolean.insert("engine->evaluate(\"0.0\")", false);
+ toBoolean.insert("engine->evaluate(\"123.0\")", true);
+ toBoolean.insert("engine->evaluate(\"6.37e-8\")", true);
+ toBoolean.insert("engine->evaluate(\"-6.37e-8\")", true);
+ toBoolean.insert("engine->evaluate(\"0x43211234\")", true);
+ toBoolean.insert("engine->evaluate(\"0x10000\")", true);
+ toBoolean.insert("engine->evaluate(\"0x10001\")", true);
+ toBoolean.insert("engine->evaluate(\"NaN\")", false);
+ toBoolean.insert("engine->evaluate(\"Infinity\")", true);
+ toBoolean.insert("engine->evaluate(\"-Infinity\")", true);
+ toBoolean.insert("engine->evaluate(\"'ciao'\")", true);
+ toBoolean.insert("engine->evaluate(\"''\")", false);
+ toBoolean.insert("engine->evaluate(\"'0'\")", true);
+ toBoolean.insert("engine->evaluate(\"'123'\")", true);
+ toBoolean.insert("engine->evaluate(\"'12.4'\")", true);
+ toBoolean.insert("engine->nullValue()", false);
+ toBoolean.insert("engine->undefinedValue()", false);
}
newRow(expr) << toBoolean.value(expr);
}
@@ -1062,6 +1287,7 @@ void tst_QScriptValue::toBoolean_test(const char*, const QScriptValue& value)
{
QFETCH(bool, expected);
QCOMPARE(value.toBoolean(), expected);
+ QCOMPARE(value.toBoolean(), expected);
}
DEFINE_TEST_FUNCTION(toBoolean)
@@ -1180,6 +1406,35 @@ void tst_QScriptValue::toInteger_makeData(const char* expr)
toInteger.insert("engine->evaluate(\"new Object()\")", 0);
toInteger.insert("engine->evaluate(\"new Array()\")", 0);
toInteger.insert("engine->evaluate(\"new Error()\")", 0);
+ toInteger.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
+ toInteger.insert("engine->evaluate(\"Undefined\")", 0);
+ toInteger.insert("engine->evaluate(\"Null\")", 0);
+ toInteger.insert("engine->evaluate(\"True\")", 0);
+ toInteger.insert("engine->evaluate(\"False\")", 0);
+ toInteger.insert("engine->evaluate(\"undefined\")", 0);
+ toInteger.insert("engine->evaluate(\"null\")", 0);
+ toInteger.insert("engine->evaluate(\"true\")", 1);
+ toInteger.insert("engine->evaluate(\"false\")", 0);
+ toInteger.insert("engine->evaluate(\"122\")", 122);
+ toInteger.insert("engine->evaluate(\"124\")", 124);
+ toInteger.insert("engine->evaluate(\"0\")", 0);
+ toInteger.insert("engine->evaluate(\"0.0\")", 0);
+ toInteger.insert("engine->evaluate(\"123.0\")", 123);
+ toInteger.insert("engine->evaluate(\"6.37e-8\")", 0);
+ toInteger.insert("engine->evaluate(\"-6.37e-8\")", 0);
+ toInteger.insert("engine->evaluate(\"0x43211234\")", 1126240820);
+ toInteger.insert("engine->evaluate(\"0x10000\")", 65536);
+ toInteger.insert("engine->evaluate(\"0x10001\")", 65537);
+ toInteger.insert("engine->evaluate(\"NaN\")", 0);
+ toInteger.insert("engine->evaluate(\"Infinity\")", qInf());
+ toInteger.insert("engine->evaluate(\"-Infinity\")", qInf());
+ toInteger.insert("engine->evaluate(\"'ciao'\")", 0);
+ toInteger.insert("engine->evaluate(\"''\")", 0);
+ toInteger.insert("engine->evaluate(\"'0'\")", 0);
+ toInteger.insert("engine->evaluate(\"'123'\")", 123);
+ toInteger.insert("engine->evaluate(\"'12.4'\")", 12);
+ toInteger.insert("engine->nullValue()", 0);
+ toInteger.insert("engine->undefinedValue()", 0);
}
newRow(expr) << toInteger.value(expr);
}
@@ -1189,9 +1444,11 @@ void tst_QScriptValue::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)
@@ -1310,6 +1567,35 @@ void tst_QScriptValue::toInt32_makeData(const char* expr)
toInt32.insert("engine->evaluate(\"new Object()\")", 0);
toInt32.insert("engine->evaluate(\"new Array()\")", 0);
toInt32.insert("engine->evaluate(\"new Error()\")", 0);
+ toInt32.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
+ toInt32.insert("engine->evaluate(\"Undefined\")", 0);
+ toInt32.insert("engine->evaluate(\"Null\")", 0);
+ toInt32.insert("engine->evaluate(\"True\")", 0);
+ toInt32.insert("engine->evaluate(\"False\")", 0);
+ toInt32.insert("engine->evaluate(\"undefined\")", 0);
+ toInt32.insert("engine->evaluate(\"null\")", 0);
+ toInt32.insert("engine->evaluate(\"true\")", 1);
+ toInt32.insert("engine->evaluate(\"false\")", 0);
+ toInt32.insert("engine->evaluate(\"122\")", 122);
+ toInt32.insert("engine->evaluate(\"124\")", 124);
+ toInt32.insert("engine->evaluate(\"0\")", 0);
+ toInt32.insert("engine->evaluate(\"0.0\")", 0);
+ toInt32.insert("engine->evaluate(\"123.0\")", 123);
+ toInt32.insert("engine->evaluate(\"6.37e-8\")", 0);
+ toInt32.insert("engine->evaluate(\"-6.37e-8\")", 0);
+ toInt32.insert("engine->evaluate(\"0x43211234\")", 1126240820);
+ toInt32.insert("engine->evaluate(\"0x10000\")", 65536);
+ toInt32.insert("engine->evaluate(\"0x10001\")", 65537);
+ toInt32.insert("engine->evaluate(\"NaN\")", 0);
+ toInt32.insert("engine->evaluate(\"Infinity\")", 0);
+ toInt32.insert("engine->evaluate(\"-Infinity\")", 0);
+ toInt32.insert("engine->evaluate(\"'ciao'\")", 0);
+ toInt32.insert("engine->evaluate(\"''\")", 0);
+ toInt32.insert("engine->evaluate(\"'0'\")", 0);
+ toInt32.insert("engine->evaluate(\"'123'\")", 123);
+ toInt32.insert("engine->evaluate(\"'12.4'\")", 12);
+ toInt32.insert("engine->nullValue()", 0);
+ toInt32.insert("engine->undefinedValue()", 0);
}
newRow(expr) << toInt32.value(expr);
}
@@ -1318,6 +1604,7 @@ void tst_QScriptValue::toInt32_test(const char*, const QScriptValue& value)
{
QFETCH(qint32, expected);
QCOMPARE(value.toInt32(), expected);
+ QCOMPARE(value.toInt32(), expected);
}
DEFINE_TEST_FUNCTION(toInt32)
@@ -1436,6 +1723,35 @@ void tst_QScriptValue::toUInt32_makeData(const char* expr)
toUInt32.insert("engine->evaluate(\"new Object()\")", 0);
toUInt32.insert("engine->evaluate(\"new Array()\")", 0);
toUInt32.insert("engine->evaluate(\"new Error()\")", 0);
+ toUInt32.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
+ toUInt32.insert("engine->evaluate(\"Undefined\")", 0);
+ toUInt32.insert("engine->evaluate(\"Null\")", 0);
+ toUInt32.insert("engine->evaluate(\"True\")", 0);
+ toUInt32.insert("engine->evaluate(\"False\")", 0);
+ toUInt32.insert("engine->evaluate(\"undefined\")", 0);
+ toUInt32.insert("engine->evaluate(\"null\")", 0);
+ toUInt32.insert("engine->evaluate(\"true\")", 1);
+ toUInt32.insert("engine->evaluate(\"false\")", 0);
+ toUInt32.insert("engine->evaluate(\"122\")", 122);
+ toUInt32.insert("engine->evaluate(\"124\")", 124);
+ toUInt32.insert("engine->evaluate(\"0\")", 0);
+ toUInt32.insert("engine->evaluate(\"0.0\")", 0);
+ toUInt32.insert("engine->evaluate(\"123.0\")", 123);
+ toUInt32.insert("engine->evaluate(\"6.37e-8\")", 0);
+ toUInt32.insert("engine->evaluate(\"-6.37e-8\")", 0);
+ toUInt32.insert("engine->evaluate(\"0x43211234\")", 1126240820);
+ toUInt32.insert("engine->evaluate(\"0x10000\")", 65536);
+ toUInt32.insert("engine->evaluate(\"0x10001\")", 65537);
+ toUInt32.insert("engine->evaluate(\"NaN\")", 0);
+ toUInt32.insert("engine->evaluate(\"Infinity\")", 0);
+ toUInt32.insert("engine->evaluate(\"-Infinity\")", 0);
+ toUInt32.insert("engine->evaluate(\"'ciao'\")", 0);
+ toUInt32.insert("engine->evaluate(\"''\")", 0);
+ toUInt32.insert("engine->evaluate(\"'0'\")", 0);
+ toUInt32.insert("engine->evaluate(\"'123'\")", 123);
+ toUInt32.insert("engine->evaluate(\"'12.4'\")", 12);
+ toUInt32.insert("engine->nullValue()", 0);
+ toUInt32.insert("engine->undefinedValue()", 0);
}
newRow(expr) << toUInt32.value(expr);
}
@@ -1444,6 +1760,7 @@ void tst_QScriptValue::toUInt32_test(const char*, const QScriptValue& value)
{
QFETCH(quint32, expected);
QCOMPARE(value.toUInt32(), expected);
+ QCOMPARE(value.toUInt32(), expected);
}
DEFINE_TEST_FUNCTION(toUInt32)
@@ -1562,6 +1879,35 @@ void tst_QScriptValue::toUInt16_makeData(const char* expr)
toUInt16.insert("engine->evaluate(\"new Object()\")", 0);
toUInt16.insert("engine->evaluate(\"new Array()\")", 0);
toUInt16.insert("engine->evaluate(\"new Error()\")", 0);
+ toUInt16.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
+ toUInt16.insert("engine->evaluate(\"Undefined\")", 0);
+ toUInt16.insert("engine->evaluate(\"Null\")", 0);
+ toUInt16.insert("engine->evaluate(\"True\")", 0);
+ toUInt16.insert("engine->evaluate(\"False\")", 0);
+ toUInt16.insert("engine->evaluate(\"undefined\")", 0);
+ toUInt16.insert("engine->evaluate(\"null\")", 0);
+ toUInt16.insert("engine->evaluate(\"true\")", 1);
+ toUInt16.insert("engine->evaluate(\"false\")", 0);
+ toUInt16.insert("engine->evaluate(\"122\")", 122);
+ toUInt16.insert("engine->evaluate(\"124\")", 124);
+ toUInt16.insert("engine->evaluate(\"0\")", 0);
+ toUInt16.insert("engine->evaluate(\"0.0\")", 0);
+ toUInt16.insert("engine->evaluate(\"123.0\")", 123);
+ toUInt16.insert("engine->evaluate(\"6.37e-8\")", 0);
+ toUInt16.insert("engine->evaluate(\"-6.37e-8\")", 0);
+ toUInt16.insert("engine->evaluate(\"0x43211234\")", 4660);
+ toUInt16.insert("engine->evaluate(\"0x10000\")", 0);
+ toUInt16.insert("engine->evaluate(\"0x10001\")", 1);
+ toUInt16.insert("engine->evaluate(\"NaN\")", 0);
+ toUInt16.insert("engine->evaluate(\"Infinity\")", 0);
+ toUInt16.insert("engine->evaluate(\"-Infinity\")", 0);
+ toUInt16.insert("engine->evaluate(\"'ciao'\")", 0);
+ toUInt16.insert("engine->evaluate(\"''\")", 0);
+ toUInt16.insert("engine->evaluate(\"'0'\")", 0);
+ toUInt16.insert("engine->evaluate(\"'123'\")", 123);
+ toUInt16.insert("engine->evaluate(\"'12.4'\")", 12);
+ toUInt16.insert("engine->nullValue()", 0);
+ toUInt16.insert("engine->undefinedValue()", 0);
}
newRow(expr) << toUInt16.value(expr);
}
@@ -1570,6 +1916,7 @@ void tst_QScriptValue::toUInt16_test(const char*, const QScriptValue& value)
{
QFETCH(quint16, expected);
QCOMPARE(value.toUInt16(), expected);
+ QCOMPARE(value.toUInt16(), expected);
}
DEFINE_TEST_FUNCTION(toUInt16)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list