1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef TST_QSCRIPTVALUE_H
#define TST_QSCRIPTVALUE_H
#include <QtCore/qobject.h>
#include <QtCore/qnumeric.h>
#include <QtScript/qscriptclass.h>
#include <QtScript/qscriptengine.h>
#include <QtScript/qscriptvalue.h>
#include <QtTest/QtTest>
Q_DECLARE_METATYPE(QVariant)
Q_DECLARE_METATYPE(QScriptValue)
class tst_QScriptValue : public QObject
{
Q_OBJECT
public:
tst_QScriptValue();
virtual ~tst_QScriptValue();
private slots:
// Generated test functions
void isArray_data();
void isArray();
void isBool_data();
void isBool();
void isBoolean_data();
void isBoolean();
void isDate_data();
void isDate();
void isError_data();
void isError();
void isFunction_data();
void isFunction();
void isNull_data();
void isNull();
void isNumber_data();
void isNumber();
void isObject_data();
void isObject();
// void isQMetaObject_data();
// void isQMetaObject();
// void isQObject_data();
// void isQObject();
void isRegExp_data();
void isRegExp();
void isString_data();
void isString();
void isUndefined_data();
void isUndefined();
void isValid_data();
void isValid();
// void isVariant_data();
// void isVariant();
void toBool_data();
void toBool();
void toBoolean_data();
void toBoolean();
// void toDateTime_data();
// void toDateTime();
void toInt32_data();
void toInt32();
void toInteger_data();
void toInteger();
void toNumber_data();
void toNumber();
// void toQMetaObject_data();
// void toQMetaObject();
// void toQObject_data();
// void toQObject();
// void toRegExp_data();
// void toRegExp();
void toString_data();
void toString();
void toUInt16_data();
void toUInt16();
void toUInt32_data();
void toUInt32();
// void toVariant_data();
// void toVariant();
void equals_data();
void equals();
void strictlyEquals_data();
void strictlyEquals();
void lessThan_data();
void lessThan();
void instanceOf_data();
void instanceOf();
void assignAndCopyConstruct_data();
void assignAndCopyConstruct();
void qscriptvalue_castQString_data();
void qscriptvalue_castQString();
void qscriptvalue_castqsreal_data();
void qscriptvalue_castqsreal();
void qscriptvalue_castbool_data();
void qscriptvalue_castbool();
void qscriptvalue_castqint32_data();
void qscriptvalue_castqint32();
void qscriptvalue_castquint32_data();
void qscriptvalue_castquint32();
void qscriptvalue_castquint16_data();
void qscriptvalue_castquint16();
// Non-generated test functions
void toObject();
void ctor();
void toString_old();
void toNumber_old();
void toBoolean_old();
void toBool_old();
void toInteger_old();
void toInt32_old();
void toUInt32_old();
void toUInt16_old();
void toVariant_old();
void toQObject_old();
void toDateTime_old();
void toRegExp_old();
void instanceOf_old();
void isArray_old();
void isDate_old();
void isError_old();
void isRegExp_old();
void lessThan_old();
void equals_old();
void strictlyEquals_old();
void getSetPrototype();
void getSetScope();
void getSetProperty();
void arrayElementGetterSetter();
void getSetData();
void getSetScriptClass();
void call();
void construct();
void castToPointer();
void prettyPrinter_data();
void prettyPrinter();
void engineDeleted();
void valueOfWithClosure();
void objectId();
private:
typedef void (tst_QScriptValue::*InitDataFunction)();
typedef void (tst_QScriptValue::*DefineDataFunction)(const char *);
void dataHelper(InitDataFunction init, DefineDataFunction define);
QTestData &newRow(const char *tag);
typedef void (tst_QScriptValue::*TestFunction)(const char *, const QScriptValue &);
void testHelper(TestFunction fun);
// Generated functions
void initScriptValues();
void isArray_initData();
void isArray_makeData(const char *expr);
void isArray_test(const char *expr, const QScriptValue &value);
void isBool_initData();
void isBool_makeData(const char *expr);
void isBool_test(const char *expr, const QScriptValue &value);
void isBoolean_initData();
void isBoolean_makeData(const char *expr);
void isBoolean_test(const char *expr, const QScriptValue &value);
void isDate_initData();
void isDate_makeData(const char *expr);
void isDate_test(const char *expr, const QScriptValue &value);
void isError_initData();
void isError_makeData(const char *expr);
void isError_test(const char *expr, const QScriptValue &value);
void isFunction_initData();
void isFunction_makeData(const char *expr);
void isFunction_test(const char *expr, const QScriptValue &value);
void isNull_initData();
void isNull_makeData(const char *expr);
void isNull_test(const char *expr, const QScriptValue &value);
void isNumber_initData();
void isNumber_makeData(const char *expr);
void isNumber_test(const char *expr, const QScriptValue &value);
void isObject_initData();
void isObject_makeData(const char *expr);
void isObject_test(const char *expr, const QScriptValue &value);
void isQMetaObject_initData();
void isQMetaObject_makeData(const char *expr);
void isQMetaObject_test(const char *expr, const QScriptValue &value);
void isQObject_initData();
void isQObject_makeData(const char *expr);
void isQObject_test(const char *expr, const QScriptValue &value);
void isRegExp_initData();
void isRegExp_makeData(const char *expr);
void isRegExp_test(const char *expr, const QScriptValue &value);
void isString_initData();
void isString_makeData(const char *expr);
void isString_test(const char *expr, const QScriptValue &value);
void isUndefined_initData();
void isUndefined_makeData(const char *expr);
void isUndefined_test(const char *expr, const QScriptValue &value);
void isValid_initData();
void isValid_makeData(const char *expr);
void isValid_test(const char *expr, const QScriptValue &value);
void isVariant_initData();
void isVariant_makeData(const char *expr);
void isVariant_test(const char *expr, const QScriptValue &value);
void toBool_initData();
void toBool_makeData(const char *);
void toBool_test(const char *, const QScriptValue &value);
void toBoolean_initData();
void toBoolean_makeData(const char *);
void toBoolean_test(const char *, const QScriptValue &value);
void toDateTime_initData();
void toDateTime_makeData(const char *);
void toDateTime_test(const char *, const QScriptValue &value);
void toInt32_initData();
void toInt32_makeData(const char *);
void toInt32_test(const char *, const QScriptValue &value);
void toInteger_initData();
void toInteger_makeData(const char *);
void toInteger_test(const char *, const QScriptValue &value);
void toNumber_initData();
void toNumber_makeData(const char *);
void toNumber_test(const char *, const QScriptValue &value);
void toQMetaObject_initData();
void toQMetaObject_makeData(const char *);
void toQMetaObject_test(const char *, const QScriptValue &value);
void toQObject_initData();
void toQObject_makeData(const char *);
void toQObject_test(const char *, const QScriptValue &value);
void toRegExp_initData();
void toRegExp_makeData(const char *);
void toRegExp_test(const char *, const QScriptValue &value);
void toString_initData();
void toString_makeData(const char *);
void toString_test(const char *, const QScriptValue &value);
void toUInt16_initData();
void toUInt16_makeData(const char *);
void toUInt16_test(const char *, const QScriptValue &value);
void toUInt32_initData();
void toUInt32_makeData(const char *);
void toUInt32_test(const char *, const QScriptValue &value);
void toVariant_initData();
void toVariant_makeData(const char *);
void toVariant_test(const char *, const QScriptValue &value);
void equals_initData();
void equals_makeData(const char *);
void equals_test(const char *, const QScriptValue &value);
void strictlyEquals_initData();
void strictlyEquals_makeData(const char *);
void strictlyEquals_test(const char *, const QScriptValue &value);
void lessThan_initData();
void lessThan_makeData(const char *);
void lessThan_test(const char *, const QScriptValue &value);
void instanceOf_initData();
void instanceOf_makeData(const char *);
void instanceOf_test(const char *, const QScriptValue &value);
void assignAndCopyConstruct_initData();
void assignAndCopyConstruct_makeData(const char *);
void assignAndCopyConstruct_test(const char *, const QScriptValue &value);
void qscriptvalue_castQString_initData();
void qscriptvalue_castQString_makeData(const char *);
void qscriptvalue_castQString_test(const char *, const QScriptValue &value);
void qscriptvalue_castqsreal_initData();
void qscriptvalue_castqsreal_makeData(const char *);
void qscriptvalue_castqsreal_test(const char *, const QScriptValue &value);
void qscriptvalue_castbool_initData();
void qscriptvalue_castbool_makeData(const char *);
void qscriptvalue_castbool_test(const char *, const QScriptValue &value);
void qscriptvalue_castqint32_initData();
void qscriptvalue_castqint32_makeData(const char *);
void qscriptvalue_castqint32_test(const char *, const QScriptValue &value);
void qscriptvalue_castquint32_initData();
void qscriptvalue_castquint32_makeData(const char *);
void qscriptvalue_castquint32_test(const char *, const QScriptValue &value);
void qscriptvalue_castquint16_initData();
void qscriptvalue_castquint16_makeData(const char *);
void qscriptvalue_castquint16_test(const char *, const QScriptValue &value);
private:
QScriptEngine *engine;
QHash<QString, QScriptValue> m_values;
QString m_currentExpression;
};
#define DEFINE_TEST_FUNCTION(name) \
void tst_QScriptValue::name##_data() { dataHelper(&tst_QScriptValue::name##_initData, &tst_QScriptValue::name##_makeData); } \
void tst_QScriptValue::name() { testHelper(&tst_QScriptValue::name##_test); }
#endif
|