Changeset 60585 in webkit


Ignore:
Timestamp:
Jun 2, 2010 6:19:59 PM (14 years ago)
Author:
eric@webkit.org
Message:

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

Reviewed by Kenneth Rohde Christiansen.

Fix the QScriptValue::strictlyEquals function.

Handling for a few edge cases was added.

New autotest that covers the QScriptValue::strictlyEquals function.

[Qt] QScriptValue::strictlyEquals is broken
https://bugs.webkit.org/show_bug.cgi?id=36600

  • qt/api/qscriptvalue.cpp: (QScriptValue::strictlyEquals):
  • qt/api/qscriptvalue_p.h: (QScriptValuePrivate::strictlyEquals):
  • qt/tests/qscriptvalue/qscriptvalue.pro:
  • qt/tests/qscriptvalue/tst_qscriptvalue.h:
  • qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp: Added. (tst_QScriptValue::strictlyEquals_initData): (tst_QScriptValue::strictlyEquals_makeData): (tst_QScriptValue::strictlyEquals_test):
Location:
trunk/JavaScriptCore
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r60583 r60585  
     12010-06-02  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Fix the QScriptValue::strictlyEquals function.
     6
     7        Handling for a few edge cases was added.
     8
     9        New autotest that covers the QScriptValue::strictlyEquals function.
     10
     11        [Qt] QScriptValue::strictlyEquals is broken
     12        https://bugs.webkit.org/show_bug.cgi?id=36600
     13
     14        * qt/api/qscriptvalue.cpp:
     15        (QScriptValue::strictlyEquals):
     16        * qt/api/qscriptvalue_p.h:
     17        (QScriptValuePrivate::strictlyEquals):
     18        * qt/tests/qscriptvalue/qscriptvalue.pro:
     19        * qt/tests/qscriptvalue/tst_qscriptvalue.h:
     20        * qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp: Added.
     21        (tst_QScriptValue::strictlyEquals_initData):
     22        (tst_QScriptValue::strictlyEquals_makeData):
     23        (tst_QScriptValue::strictlyEquals_test):
     24
    1252010-06-02  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>
    226
  • trunk/JavaScriptCore/qt/api/qscriptvalue.cpp

    r59503 r60585  
    584584bool QScriptValue::strictlyEquals(const QScriptValue& other) const
    585585{
    586     return d_ptr == other.d_ptr || d_ptr->strictlyEquals(QScriptValuePrivate::get(other));
    587 }
     586    return d_ptr->strictlyEquals(QScriptValuePrivate::get(other));
     587}
  • trunk/JavaScriptCore/qt/api/qscriptvalue_p.h

    r59503 r60585  
    109109
    110110    inline bool equals(QScriptValuePrivate* other);
    111     inline bool strictlyEquals(const QScriptValuePrivate* other) const;
     111    inline bool strictlyEquals(QScriptValuePrivate* other);
    112112    inline bool assignEngine(QScriptEnginePrivate* engine);
    113113
     
    622622}
    623623
    624 bool QScriptValuePrivate::strictlyEquals(const QScriptValuePrivate* other) const
    625 {
    626     if (m_state != other->m_state)
    627         return false;
     624bool QScriptValuePrivate::strictlyEquals(QScriptValuePrivate* other)
     625{
    628626    if (isJSBased()) {
     627        // We can't compare these two values without binding to the same engine.
     628        if (!other->isJSBased()) {
     629            if (other->assignEngine(engine()))
     630                return JSValueIsStrictEqual(context(), value(), other->value());
     631            return false;
     632        }
    629633        if (other->engine() != engine()) {
    630634            qWarning("strictlyEquals(): Cannot compare to a value created in a different engine");
     
    633637        return JSValueIsStrictEqual(context(), value(), other->value());
    634638    }
    635     if (isStringBased())
    636         return m_string == other->m_string;
    637     if (isNumberBased())
    638         return m_number == other->m_number;
    639 
    640     return false; // Invalid state.
     639    if (isStringBased()) {
     640        if (other->isStringBased())
     641            return m_string == other->m_string;
     642        if (other->isJSBased()) {
     643            assignEngine(other->engine());
     644            return JSValueIsStrictEqual(context(), value(), other->value());
     645        }
     646    }
     647    if (isNumberBased()) {
     648        if (other->isNumberBased())
     649            return m_number == other->m_number;
     650        if (other->isJSBased()) {
     651            assignEngine(other->engine());
     652            return JSValueIsStrictEqual(context(), value(), other->value());
     653        }
     654    }
     655    if (!isValid() && !other->isValid())
     656        return true;
     657
     658    return false;
    641659}
    642660
  • trunk/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro

    r59930 r60585  
    88    tst_qscriptvalue.cpp \
    99    tst_qscriptvalue_generated_init.cpp \
     10    tst_qscriptvalue_generated_comparison.cpp \
    1011    tst_qscriptvalue_generated_istype.cpp \
    1112    tst_qscriptvalue_generated_totype.cpp \
  • trunk/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h

    r59930 r60585  
    104104    void toUInt16();
    105105
     106    void strictlyEquals_data();
     107    void strictlyEquals();
     108
    106109private:
    107110    typedef void (tst_QScriptValue::*InitDataFunction)();
     
    185188    void toUInt16_test(const char*, const QScriptValue&);
    186189
     190    void strictlyEquals_initData();
     191    void strictlyEquals_makeData(const char*);
     192    void strictlyEquals_test(const char*, const QScriptValue&);
     193
    187194private:
    188195    QScriptEngine* engine;
Note: See TracChangeset for help on using the changeset viewer.