1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2018 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef TST_QSCRIPTVALUE_H |
30 | #define TST_QSCRIPTVALUE_H |
31 | |
32 | #include <QtCore/qobject.h> |
33 | #include <QtCore/qnumeric.h> |
34 | #include <QtScript/qscriptclass.h> |
35 | #include <QtScript/qscriptengine.h> |
36 | #include <QtScript/qscriptvalue.h> |
37 | #include <QtTest/QtTest> |
38 | |
39 | Q_DECLARE_METATYPE(QVariant) |
40 | Q_DECLARE_METATYPE(QScriptValue) |
41 | |
42 | class tst_QScriptValue : public QObject |
43 | { |
44 | Q_OBJECT |
45 | |
46 | public: |
47 | tst_QScriptValue(); |
48 | virtual ~tst_QScriptValue(); |
49 | |
50 | private slots: |
51 | void toObject(); |
52 | |
53 | void ctor_invalid(); |
54 | void ctor_undefinedWithEngine(); |
55 | void ctor_undefined(); |
56 | void ctor_nullWithEngine(); |
57 | void ctor_null(); |
58 | void ctor_boolWithEngine(); |
59 | void ctor_bool(); |
60 | void ctor_intWithEngine(); |
61 | void ctor_int(); |
62 | void ctor_uintWithEngine(); |
63 | void ctor_uint(); |
64 | void ctor_floatWithEngine(); |
65 | void ctor_float(); |
66 | void ctor_stringWithEngine(); |
67 | void ctor_string(); |
68 | void ctor_copyAndAssignWithEngine(); |
69 | void ctor_copyAndAssign(); |
70 | void ctor_nullEngine(); |
71 | |
72 | void toString(); |
73 | void toNumber(); |
74 | void toBoolean(); |
75 | void toBool(); |
76 | void toInteger(); |
77 | void toInt32(); |
78 | void toUInt32(); |
79 | void toUInt16(); |
80 | void toVariant(); |
81 | void toQObject_nonQObject_data(); |
82 | void toQObject_nonQObject(); |
83 | void toQObject(); |
84 | void toDateTime(); |
85 | void toRegExp(); |
86 | void instanceOf_twoEngines(); |
87 | void instanceOf(); |
88 | void isArray_data(); |
89 | void isArray(); |
90 | void isDate(); |
91 | void isDate_data(); |
92 | void isError_propertiesOfGlobalObject(); |
93 | void isError_data(); |
94 | void isError(); |
95 | void isRegExp_data(); |
96 | void isRegExp(); |
97 | |
98 | void lessThan(); |
99 | void equals(); |
100 | void strictlyEquals(); |
101 | |
102 | void getSetPrototype_cyclicPrototype(); |
103 | void getSetPrototype_evalCyclicPrototype(); |
104 | void getSetPrototype_eval(); |
105 | void getSetPrototype_invalidPrototype(); |
106 | void getSetPrototype_twoEngines(); |
107 | void getSetPrototype_null(); |
108 | void getSetPrototype_notObjectOrNull(); |
109 | void getSetPrototype(); |
110 | void getSetScope(); |
111 | void getSetProperty_HooliganTask162051(); |
112 | void getSetProperty_HooliganTask183072(); |
113 | void getSetProperty_propertyRemoval(); |
114 | void getSetProperty_resolveMode(); |
115 | void getSetProperty_twoEngines(); |
116 | void getSetProperty_gettersAndSetters(); |
117 | void getSetProperty_gettersAndSettersThrowErrorNative(); |
118 | void getSetProperty_gettersAndSettersThrowErrorJS(); |
119 | void getSetProperty_gettersAndSettersOnNative(); |
120 | void getSetProperty_gettersAndSettersOnGlobalObject(); |
121 | void getSetProperty_gettersAndSettersChange(); |
122 | void getSetProperty_array(); |
123 | void getSetProperty(); |
124 | void arrayElementGetterSetter(); |
125 | void getSetData_objects_data(); |
126 | void getSetData_objects(); |
127 | void getSetData_nonObjects_data(); |
128 | void getSetData_nonObjects(); |
129 | void setData_QTBUG15144(); |
130 | void getSetScriptClass_emptyClass_data(); |
131 | void getSetScriptClass_emptyClass(); |
132 | void getSetScriptClass_JSObjectFromCpp(); |
133 | void getSetScriptClass_JSObjectFromJS(); |
134 | void getSetScriptClass_QVariant(); |
135 | void getSetScriptClass_QObject(); |
136 | void call_function(); |
137 | void call_object(); |
138 | void call_newObjects(); |
139 | void call_this(); |
140 | void call_arguments(); |
141 | void call(); |
142 | void call_invalidArguments(); |
143 | void call_invalidReturn(); |
144 | void call_twoEngines(); |
145 | void call_array(); |
146 | void call_nonFunction_data(); |
147 | void call_nonFunction(); |
148 | void construct_nonFunction_data(); |
149 | void construct_nonFunction(); |
150 | void construct_simple(); |
151 | void construct_newObjectJS(); |
152 | void construct_undefined(); |
153 | void construct_newObjectCpp(); |
154 | void construct_arg(); |
155 | void construct_proto(); |
156 | void construct_returnInt(); |
157 | void construct_throw(); |
158 | void construct(); |
159 | void construct_twoEngines(); |
160 | void construct_constructorThrowsPrimitive(); |
161 | void castToPointer(); |
162 | void prettyPrinter_data(); |
163 | void prettyPrinter(); |
164 | void engineDeleted(); |
165 | void valueOfWithClosure(); |
166 | void objectId(); |
167 | void nestedObjectToVariant_data(); |
168 | void nestedObjectToVariant(); |
169 | void propertyFlags_data(); |
170 | void propertyFlags(); |
171 | |
172 | |
173 | private: |
174 | void newEngine() |
175 | { |
176 | if (engine) |
177 | delete engine; |
178 | engine = new QScriptEngine(); |
179 | } |
180 | QScriptEngine *engine; |
181 | }; |
182 | |
183 | #endif |
184 | |