253 QCOMPARE(it.name(), propertyNames.at(i)); |
253 QCOMPARE(it.name(), propertyNames.at(i)); |
254 QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); |
254 QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); |
255 QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); |
255 QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); |
256 QCOMPARE(it.value().toString(), propertyValues.at(i)); |
256 QCOMPARE(it.value().toString(), propertyValues.at(i)); |
257 } |
257 } |
258 QCOMPARE(it.hasNext(), false); |
258 QVERIFY(it.hasNext()); |
259 |
259 it.next(); |
|
260 QCOMPARE(it.name(), QString::fromLatin1("length")); |
|
261 QVERIFY(it.value().isNumber()); |
|
262 QCOMPARE(it.value().toInt32(), length); |
|
263 QCOMPARE(it.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); |
|
264 |
|
265 it.previous(); |
260 QCOMPARE(it.hasPrevious(), length > 0); |
266 QCOMPARE(it.hasPrevious(), length > 0); |
261 for (int i = length - 1; i >= 0; --i) { |
267 for (int i = length - 1; i >= 0; --i) { |
262 it.previous(); |
268 it.previous(); |
263 QCOMPARE(it.name(), propertyNames.at(i)); |
269 QCOMPARE(it.name(), propertyNames.at(i)); |
264 QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); |
270 QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); |
299 QCOMPARE(it.name(), propertyNames.at(i)); |
305 QCOMPARE(it.name(), propertyNames.at(i)); |
300 QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); |
306 QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); |
301 QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); |
307 QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); |
302 QCOMPARE(it.value().toString(), propertyValues.at(i)); |
308 QCOMPARE(it.value().toString(), propertyValues.at(i)); |
303 } |
309 } |
304 QCOMPARE(it.hasNext(), false); |
310 QCOMPARE(it.hasNext(), true); |
|
311 it.next(); |
|
312 QCOMPARE(it.name(), QString::fromLatin1("length")); |
305 } |
313 } |
306 } |
314 } |
307 |
315 |
308 void tst_QScriptValueIterator::iterateBackAndForth() |
316 void tst_QScriptValueIterator::iterateBackAndForth() |
309 { |
317 { |
418 it.next(); |
426 it.next(); |
419 QCOMPARE(it.name(), indexStr); |
427 QCOMPARE(it.name(), indexStr); |
420 QCOMPARE(it.flags(), obj.propertyFlags(indexStr)); |
428 QCOMPARE(it.flags(), obj.propertyFlags(indexStr)); |
421 QCOMPARE(it.value().strictlyEquals(obj.property(indexStr)), true); |
429 QCOMPARE(it.value().strictlyEquals(obj.property(indexStr)), true); |
422 } |
430 } |
423 QCOMPARE(it.hasNext(), false); |
431 QVERIFY(it.hasNext()); |
424 |
432 it.next(); |
425 QVERIFY(it.hasPrevious()); |
433 QCOMPARE(it.name(), QString::fromLatin1("length")); |
|
434 QVERIFY(it.value().isNumber()); |
|
435 QCOMPARE(it.value().toInt32(), length); |
|
436 QCOMPARE(it.flags(), QScriptValue::ReadOnly | QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); |
|
437 |
|
438 it.previous(); |
|
439 QCOMPARE(it.hasPrevious(), length > 0); |
426 for (int i = length - 1; i >= 0; --i) { |
440 for (int i = length - 1; i >= 0; --i) { |
427 it.previous(); |
441 it.previous(); |
428 QString indexStr = QScriptValue(&engine, i).toString(); |
442 QString indexStr = QScriptValue(&engine, i).toString(); |
429 QCOMPARE(it.name(), indexStr); |
443 QCOMPARE(it.name(), indexStr); |
430 QCOMPARE(it.flags(), obj.propertyFlags(indexStr)); |
444 QCOMPARE(it.flags(), obj.propertyFlags(indexStr)); |