Changeset 60585 in webkit
- Timestamp:
- Jun 2, 2010 6:19:59 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r60583 r60585 1 2010-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 1 25 2010-06-02 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> 2 26 -
trunk/JavaScriptCore/qt/api/qscriptvalue.cpp
r59503 r60585 584 584 bool QScriptValue::strictlyEquals(const QScriptValue& other) const 585 585 { 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 109 109 110 110 inline bool equals(QScriptValuePrivate* other); 111 inline bool strictlyEquals( const QScriptValuePrivate* other) const;111 inline bool strictlyEquals(QScriptValuePrivate* other); 112 112 inline bool assignEngine(QScriptEnginePrivate* engine); 113 113 … … 622 622 } 623 623 624 bool QScriptValuePrivate::strictlyEquals(const QScriptValuePrivate* other) const 625 { 626 if (m_state != other->m_state) 627 return false; 624 bool QScriptValuePrivate::strictlyEquals(QScriptValuePrivate* other) 625 { 628 626 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 } 629 633 if (other->engine() != engine()) { 630 634 qWarning("strictlyEquals(): Cannot compare to a value created in a different engine"); … … 633 637 return JSValueIsStrictEqual(context(), value(), other->value()); 634 638 } 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; 641 659 } 642 660 -
trunk/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro
r59930 r60585 8 8 tst_qscriptvalue.cpp \ 9 9 tst_qscriptvalue_generated_init.cpp \ 10 tst_qscriptvalue_generated_comparison.cpp \ 10 11 tst_qscriptvalue_generated_istype.cpp \ 11 12 tst_qscriptvalue_generated_totype.cpp \ -
trunk/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h
r59930 r60585 104 104 void toUInt16(); 105 105 106 void strictlyEquals_data(); 107 void strictlyEquals(); 108 106 109 private: 107 110 typedef void (tst_QScriptValue::*InitDataFunction)(); … … 185 188 void toUInt16_test(const char*, const QScriptValue&); 186 189 190 void strictlyEquals_initData(); 191 void strictlyEquals_makeData(const char*); 192 void strictlyEquals_test(const char*, const QScriptValue&); 193 187 194 private: 188 195 QScriptEngine* engine;
Note: See TracChangeset
for help on using the changeset viewer.