OpenCoverage

qv4arrayiterator.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4arrayiterator.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2017 Crimson AS <info@crimson.no>-
4** Copyright (C) 2018 The Qt Company Ltd.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtQml module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include <private/qv4iterator_p.h>-
42#include <private/qv4arrayiterator_p.h>-
43#include <private/qv4typedarray_p.h>-
44#include <private/qv4symbol_p.h>-
45-
46using namespace QV4;-
47-
48DEFINE_OBJECT_VTABLE(ArrayIteratorObject);-
49-
50void ArrayIteratorPrototype::init(ExecutionEngine *e)-
51{-
52 defineDefaultProperty(QStringLiteral("next"), method_next, 0);
executed 98252 times by 153 tests: return qstring_literal_temp;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
98252
53-
54 Scope scope(e);-
55 ScopedString val(scope, e->newString(QLatin1String("Array Iterator")));-
56 defineReadonlyConfigurableProperty(e->symbol_toStringTag(), val);-
57}
executed 99009 times by 153 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
99009
58-
59ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const Value *that, const Value *, int)-
60{-
61 Scope scope(b);-
62 const ArrayIteratorObject *thisObject = that->as<ArrayIteratorObject>();-
63 if (!thisObject)
!thisObjectDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 22863 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-22863
64 return scope.engine->throwTypeError(QLatin1String("Not an Array Iterator instance"));
executed 4 times by 1 test: return scope.engine->throwTypeError(QLatin1String("Not an Array Iterator instance"));
Executed by:
  • tst_ecmascripttests
4
65-
66 ScopedObject a(scope, thisObject->d()->iteratedObject);-
67 if (!a) {
!aDescription
TRUEevaluated 1067 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 21799 times by 1 test
Evaluated by:
  • tst_ecmascripttests
1067-21799
68 QV4::Value undefined = Primitive::undefinedValue();-
69 return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
executed 1067 times by 1 test: return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
Executed by:
  • tst_ecmascripttests
1067
70 }-
71-
72 quint32 index = thisObject->d()->nextIndex;-
73 IteratorKind itemKind = thisObject->d()->iterationKind;-
74-
75 Scoped<TypedArray> ta(scope, a->as<TypedArray>());-
76 quint32 len = a->getLength();-
77-
78 if (index >= len) {
index >= lenDescription
TRUEevaluated 6738 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 15155 times by 1 test
Evaluated by:
  • tst_ecmascripttests
6738-15155
79 thisObject->d()->iteratedObject.set(scope.engine, nullptr);-
80 QV4::Value undefined = Primitive::undefinedValue();-
81 return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
executed 6733 times by 1 test: return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
Executed by:
  • tst_ecmascripttests
6733
82 }-
83-
84 thisObject->d()->nextIndex = index + 1;-
85 if (itemKind == KeyIteratorKind) {
itemKind == KeyIteratorKindDescription
TRUEevaluated 160 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 15005 times by 1 test
Evaluated by:
  • tst_ecmascripttests
160-15005
86 return IteratorPrototype::createIterResultObject(scope.engine, Primitive::fromInt32(index), false);
executed 160 times by 1 test: return IteratorPrototype::createIterResultObject(scope.engine, Primitive::fromInt32(index), false);
Executed by:
  • tst_ecmascripttests
160
87 }-
88-
89 ReturnedValue elementValue = a->get(index);-
90 CHECK_EXCEPTION();
executed 4 times by 1 test: return QV4::Encode::undefined();
Executed by:
  • tst_ecmascripttests
scope.hasException()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 14970 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-14970
91-
92 if (itemKind == ValueIteratorKind) {
itemKind == ValueIteratorKindDescription
TRUEevaluated 14843 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 156 times by 1 test
Evaluated by:
  • tst_ecmascripttests
156-14843
93 return IteratorPrototype::createIterResultObject(scope.engine, Value::fromReturnedValue(elementValue), false);
executed 14853 times by 1 test: return IteratorPrototype::createIterResultObject(scope.engine, Value::fromReturnedValue(elementValue), false);
Executed by:
  • tst_ecmascripttests
14853
94 } else {-
95 Q_ASSERT(itemKind == KeyValueIteratorKind);-
96-
97 ScopedArrayObject resultArray(scope, scope.engine->newArrayObject());-
98 resultArray->arrayReserve(2);-
99 resultArray->arrayPut(0, Primitive::fromInt32(index));-
100 resultArray->arrayPut(1, Value::fromReturnedValue(elementValue));-
101 resultArray->setArrayLengthUnchecked(2);-
102-
103 return IteratorPrototype::createIterResultObject(scope.engine, resultArray, false);
executed 156 times by 1 test: return IteratorPrototype::createIterResultObject(scope.engine, resultArray, false);
Executed by:
  • tst_ecmascripttests
156
104 }-
105}-
106-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0