Commit 0a2ca2d9 authored by eric@webkit.org's avatar eric@webkit.org

2010-06-04 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        Fix QScriptValue::equals.

        Handling for a few edge cases were added. Now comparison between
        NaN, an invalid objects should works as supposed.

        [Qt] QScriptValue::equals problems
        https://bugs.webkit.org/show_bug.cgi?id=40110

        * qt/api/qscriptvalue.cpp:
        (QScriptValue::equals):
        * qt/api/qscriptvalue_p.h:
        (QScriptValuePrivate::equals):
        * qt/tests/qscriptvalue/tst_qscriptvalue.h:
        * qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp:
        (tst_QScriptValue::equals_initData):
        (tst_QScriptValue::equals_makeData):
        (tst_QScriptValue::equals_test):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ef75a8b6
2010-06-04 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
Fix QScriptValue::equals.
Handling for a few edge cases were added. Now comparison between
NaN, an invalid objects should works as supposed.
[Qt] QScriptValue::equals problems
https://bugs.webkit.org/show_bug.cgi?id=40110
* qt/api/qscriptvalue.cpp:
(QScriptValue::equals):
* qt/api/qscriptvalue_p.h:
(QScriptValuePrivate::equals):
* qt/tests/qscriptvalue/tst_qscriptvalue.h:
* qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp:
(tst_QScriptValue::equals_initData):
(tst_QScriptValue::equals_makeData):
(tst_QScriptValue::equals_test):
2010-06-03 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
......
......@@ -556,7 +556,7 @@ QScriptValue& QScriptValue::operator=(const QScriptValue& other)
*/
bool QScriptValue::equals(const QScriptValue& other) const
{
return d_ptr == other.d_ptr || d_ptr->equals(QScriptValuePrivate::get(other));
return d_ptr->equals(QScriptValuePrivate::get(other));
}
/*!
......
......@@ -602,22 +602,29 @@ QScriptValuePrivate* QScriptValuePrivate::toObject()
bool QScriptValuePrivate::equals(QScriptValuePrivate* other)
{
if (!isValid() || !other->isValid())
if (!isValid())
return !other->isValid();
if (!other->isValid())
return false;
if ((m_state == other->m_state) && !isJSBased()) {
if (isNumberBased())
return m_number == other->m_number;
Q_ASSERT(isStringBased());
return m_string == other->m_string;
}
if (!isJSBased() && !other->isJSBased())
return false;
if (isJSBased() && !other->isJSBased()) {
if (!other->assignEngine(engine())) {
qWarning("equals(): Cannot compare to a value created in a different engine");
return false;
}
} else if (!isJSBased() && other->isJSBased()) {
if (!other->assignEngine(other->engine())) {
if (!assignEngine(other->engine())) {
qWarning("equals(): Cannot compare to a value created in a different engine");
return false;
}
......
......@@ -103,6 +103,9 @@ private slots:
void toUInt16_data();
void toUInt16();
void equals_data();
void equals();
void strictlyEquals_data();
void strictlyEquals();
......@@ -187,6 +190,10 @@ private:
void toUInt16_makeData(const char*);
void toUInt16_test(const char*, const QScriptValue&);
void equals_initData();
void equals_makeData(const char*);
void equals_test(const char*, const QScriptValue&);
void strictlyEquals_initData();
void strictlyEquals_makeData(const char*);
void strictlyEquals_test(const char*, const QScriptValue&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment