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#include "tst_qscriptvalue.h"
30
31
32
33void tst_QScriptValueGenerated::qscriptvalue_castQString_initData()
34{
35 QTest::addColumn<QString>(name: "expected");
36 initScriptValues();
37}
38
39static const char *qscriptvalue_castQString_tagArray[] = {
40 "QScriptValue()",
41 "QScriptValue(QScriptValue::UndefinedValue)",
42 "QScriptValue(QScriptValue::NullValue)",
43 "QScriptValue(true)",
44 "QScriptValue(false)",
45 "QScriptValue(int(122))",
46 "QScriptValue(uint(124))",
47 "QScriptValue(0)",
48 "QScriptValue(0.0)",
49 "QScriptValue(123.0)",
50 "QScriptValue(6.37e-8)",
51 "QScriptValue(-6.37e-8)",
52 "QScriptValue(0x43211234)",
53 "QScriptValue(0x10000)",
54 "QScriptValue(0x10001)",
55 "QScriptValue(qSNaN())",
56 "QScriptValue(qQNaN())",
57 "QScriptValue(qInf())",
58 "QScriptValue(-qInf())",
59 "QScriptValue(\"NaN\")",
60 "QScriptValue(\"Infinity\")",
61 "QScriptValue(\"-Infinity\")",
62 "QScriptValue(\"ciao\")",
63 "QScriptValue(QString::fromLatin1(\"ciao\"))",
64 "QScriptValue(QString(\"\"))",
65 "QScriptValue(QString())",
66 "QScriptValue(QString(\"0\"))",
67 "QScriptValue(QString(\"123\"))",
68 "QScriptValue(QString(\"12.4\"))",
69 "QScriptValue(0, QScriptValue::UndefinedValue)",
70 "QScriptValue(0, QScriptValue::NullValue)",
71 "QScriptValue(0, true)",
72 "QScriptValue(0, false)",
73 "QScriptValue(0, int(122))",
74 "QScriptValue(0, uint(124))",
75 "QScriptValue(0, 0)",
76 "QScriptValue(0, 0.0)",
77 "QScriptValue(0, 123.0)",
78 "QScriptValue(0, 6.37e-8)",
79 "QScriptValue(0, -6.37e-8)",
80 "QScriptValue(0, 0x43211234)",
81 "QScriptValue(0, 0x10000)",
82 "QScriptValue(0, 0x10001)",
83 "QScriptValue(0, qSNaN())",
84 "QScriptValue(0, qQNaN())",
85 "QScriptValue(0, qInf())",
86 "QScriptValue(0, -qInf())",
87 "QScriptValue(0, \"NaN\")",
88 "QScriptValue(0, \"Infinity\")",
89 "QScriptValue(0, \"-Infinity\")",
90 "QScriptValue(0, \"ciao\")",
91 "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
92 "QScriptValue(0, QString(\"\"))",
93 "QScriptValue(0, QString())",
94 "QScriptValue(0, QString(\"0\"))",
95 "QScriptValue(0, QString(\"123\"))",
96 "QScriptValue(0, QString(\"12.3\"))",
97 "QScriptValue(engine, QScriptValue::UndefinedValue)",
98 "QScriptValue(engine, QScriptValue::NullValue)",
99 "QScriptValue(engine, true)",
100 "QScriptValue(engine, false)",
101 "QScriptValue(engine, int(122))",
102 "QScriptValue(engine, uint(124))",
103 "QScriptValue(engine, 0)",
104 "QScriptValue(engine, 0.0)",
105 "QScriptValue(engine, 123.0)",
106 "QScriptValue(engine, 6.37e-8)",
107 "QScriptValue(engine, -6.37e-8)",
108 "QScriptValue(engine, 0x43211234)",
109 "QScriptValue(engine, 0x10000)",
110 "QScriptValue(engine, 0x10001)",
111 "QScriptValue(engine, qSNaN())",
112 "QScriptValue(engine, qQNaN())",
113 "QScriptValue(engine, qInf())",
114 "QScriptValue(engine, -qInf())",
115 "QScriptValue(engine, \"NaN\")",
116 "QScriptValue(engine, \"Infinity\")",
117 "QScriptValue(engine, \"-Infinity\")",
118 "QScriptValue(engine, \"ciao\")",
119 "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
120 "QScriptValue(engine, QString(\"\"))",
121 "QScriptValue(engine, QString())",
122 "QScriptValue(engine, QString(\"0\"))",
123 "QScriptValue(engine, QString(\"123\"))",
124 "QScriptValue(engine, QString(\"1.23\"))",
125 "engine->evaluate(\"[]\")",
126 "engine->evaluate(\"{}\")",
127 "engine->evaluate(\"Object.prototype\")",
128 "engine->evaluate(\"Date.prototype\")",
129 "engine->evaluate(\"Array.prototype\")",
130 "engine->evaluate(\"Function.prototype\")",
131 "engine->evaluate(\"Error.prototype\")",
132 "engine->evaluate(\"Object\")",
133 "engine->evaluate(\"Array\")",
134 "engine->evaluate(\"Number\")",
135 "engine->evaluate(\"Function\")",
136 "engine->evaluate(\"(function() { return 1; })\")",
137 "engine->evaluate(\"(function() { return 'ciao'; })\")",
138 "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
139 "engine->evaluate(\"/foo/\")",
140 "engine->evaluate(\"new Object()\")",
141 "engine->evaluate(\"new Array()\")",
142 "engine->evaluate(\"new Error()\")",
143 "engine->evaluate(\"new Boolean(true)\")",
144 "engine->evaluate(\"new Boolean(false)\")",
145 "engine->evaluate(\"new Number(123)\")",
146 "engine->evaluate(\"new RegExp('foo', 'gim')\")",
147 "engine->evaluate(\"new String('ciao')\")",
148 "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
149 "engine->evaluate(\"Undefined\")",
150 "engine->evaluate(\"Null\")",
151 "engine->evaluate(\"True\")",
152 "engine->evaluate(\"False\")",
153 "engine->evaluate(\"undefined\")",
154 "engine->evaluate(\"null\")",
155 "engine->evaluate(\"true\")",
156 "engine->evaluate(\"false\")",
157 "engine->evaluate(\"122\")",
158 "engine->evaluate(\"124\")",
159 "engine->evaluate(\"0\")",
160 "engine->evaluate(\"0.0\")",
161 "engine->evaluate(\"123.0\")",
162 "engine->evaluate(\"6.37e-8\")",
163 "engine->evaluate(\"-6.37e-8\")",
164 "engine->evaluate(\"0x43211234\")",
165 "engine->evaluate(\"0x10000\")",
166 "engine->evaluate(\"0x10001\")",
167 "engine->evaluate(\"NaN\")",
168 "engine->evaluate(\"Infinity\")",
169 "engine->evaluate(\"-Infinity\")",
170 "engine->evaluate(\"'ciao'\")",
171 "engine->evaluate(\"''\")",
172 "engine->evaluate(\"'0'\")",
173 "engine->evaluate(\"'123'\")",
174 "engine->evaluate(\"'12.4'\")",
175 "engine->nullValue()",
176 "engine->undefinedValue()",
177 "engine->newObject()",
178 "engine->newArray()",
179 "engine->newArray(10)",
180 "engine->newDate(QDateTime())",
181 "engine->newQMetaObject(&QObject::staticMetaObject)",
182 "engine->newRegExp(\"foo\", \"gim\")",
183 "engine->newVariant(QVariant())",
184 "engine->newVariant(QVariant(123))",
185 "engine->newVariant(QVariant(false))",
186 "engine->newQObject(0)",
187 "engine->newQObject(engine)"};
188static const char *qscriptvalue_castQString_valueArray[] = {
189 "", "",
190 "", "true",
191 "false", "122",
192 "124", "0",
193 "0", "123",
194 "6.37e-8", "-6.37e-8",
195 "1126240820", "65536",
196 "65537", "NaN",
197 "NaN", "Infinity",
198 "-Infinity", "NaN",
199 "Infinity", "-Infinity",
200 "ciao", "ciao",
201 "", "",
202 "0", "123",
203 "12.4", "",
204 "", "true",
205 "false", "122",
206 "124", "0",
207 "0", "123",
208 "6.37e-8", "-6.37e-8",
209 "1126240820", "65536",
210 "65537", "NaN",
211 "NaN", "Infinity",
212 "-Infinity", "NaN",
213 "Infinity", "-Infinity",
214 "ciao", "ciao",
215 "", "",
216 "0", "123",
217 "12.3", "",
218 "", "true",
219 "false", "122",
220 "124", "0",
221 "0", "123",
222 "6.37e-8", "-6.37e-8",
223 "1126240820", "65536",
224 "65537", "NaN",
225 "NaN", "Infinity",
226 "-Infinity", "NaN",
227 "Infinity", "-Infinity",
228 "ciao", "ciao",
229 "", "",
230 "0", "123",
231 "1.23", "",
232 "", "[object Object]",
233 "Invalid Date", "",
234 "function () {\n [native code]\n}", "Error: Unknown error",
235 "function Object() {\n [native code]\n}", "function Array() {\n [native code]\n}",
236 "function Number() {\n [native code]\n}", "function Function() {\n [native code]\n}",
237 "function () { return 1; }", "function () { return 'ciao'; }",
238 "function () { throw new Error('foo'); }", "/foo/",
239 "[object Object]", "",
240 "Error: Unknown error", "true",
241 "false", "123",
242 "/foo/gim", "ciao",
243 "22", "ReferenceError: Can't find variable: Undefined",
244 "ReferenceError: Can't find variable: Null", "ReferenceError: Can't find variable: True",
245 "ReferenceError: Can't find variable: False", "",
246 "", "true",
247 "false", "122",
248 "124", "0",
249 "0", "123",
250 "6.37e-8", "-6.37e-8",
251 "1126240820", "65536",
252 "65537", "NaN",
253 "Infinity", "-Infinity",
254 "ciao", "",
255 "0", "123",
256 "12.4", "",
257 "", "[object Object]",
258 "", ",,,,,,,,,",
259 "Invalid Date", "[object QMetaObject]",
260 "/foo/gim", "undefined",
261 "123", "false",
262 "", "QScriptEngine(name = \"\")"};
263void tst_QScriptValueGenerated::qscriptvalue_castQString_makeData(const char* expr)
264{
265 static const QHash<QString, QString> valueMap =
266 charArraysToStringHash(keys: qscriptvalue_castQString_tagArray, values: qscriptvalue_castQString_valueArray,
267 size: int(sizeof(qscriptvalue_castQString_tagArray) / sizeof(const char *)));
268 newRow(tag: expr) << valueMap.value(akey: expr);
269}
270
271void tst_QScriptValueGenerated::qscriptvalue_castQString_test(const char*, const QScriptValue& value)
272{
273 QFETCH(QString, expected);
274 QCOMPARE(qscriptvalue_cast<QString>(value), expected);
275 QCOMPARE(qscriptvalue_cast<QString>(value), expected);
276}
277
278DEFINE_TEST_FUNCTION(qscriptvalue_castQString)
279
280
281void tst_QScriptValueGenerated::qscriptvalue_castqsreal_initData()
282{
283 QTest::addColumn<qsreal>(name: "expected");
284 initScriptValues();
285}
286
287static const char *qscriptvalue_castqsreal_tagArray[] = {
288 "QScriptValue()",
289 "QScriptValue(QScriptValue::UndefinedValue)",
290 "QScriptValue(QScriptValue::NullValue)",
291 "QScriptValue(true)",
292 "QScriptValue(false)",
293 "QScriptValue(int(122))",
294 "QScriptValue(uint(124))",
295 "QScriptValue(0)",
296 "QScriptValue(0.0)",
297 "QScriptValue(123.0)",
298 "QScriptValue(6.37e-8)",
299 "QScriptValue(-6.37e-8)",
300 "QScriptValue(0x43211234)",
301 "QScriptValue(0x10000)",
302 "QScriptValue(0x10001)",
303 "QScriptValue(qSNaN())",
304 "QScriptValue(qQNaN())",
305 "QScriptValue(qInf())",
306 "QScriptValue(-qInf())",
307 "QScriptValue(\"NaN\")",
308 "QScriptValue(\"Infinity\")",
309 "QScriptValue(\"-Infinity\")",
310 "QScriptValue(\"ciao\")",
311 "QScriptValue(QString::fromLatin1(\"ciao\"))",
312 "QScriptValue(QString(\"\"))",
313 "QScriptValue(QString())",
314 "QScriptValue(QString(\"0\"))",
315 "QScriptValue(QString(\"123\"))",
316 "QScriptValue(QString(\"12.4\"))",
317 "QScriptValue(0, QScriptValue::UndefinedValue)",
318 "QScriptValue(0, QScriptValue::NullValue)",
319 "QScriptValue(0, true)",
320 "QScriptValue(0, false)",
321 "QScriptValue(0, int(122))",
322 "QScriptValue(0, uint(124))",
323 "QScriptValue(0, 0)",
324 "QScriptValue(0, 0.0)",
325 "QScriptValue(0, 123.0)",
326 "QScriptValue(0, 6.37e-8)",
327 "QScriptValue(0, -6.37e-8)",
328 "QScriptValue(0, 0x43211234)",
329 "QScriptValue(0, 0x10000)",
330 "QScriptValue(0, 0x10001)",
331 "QScriptValue(0, qSNaN())",
332 "QScriptValue(0, qQNaN())",
333 "QScriptValue(0, qInf())",
334 "QScriptValue(0, -qInf())",
335 "QScriptValue(0, \"NaN\")",
336 "QScriptValue(0, \"Infinity\")",
337 "QScriptValue(0, \"-Infinity\")",
338 "QScriptValue(0, \"ciao\")",
339 "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
340 "QScriptValue(0, QString(\"\"))",
341 "QScriptValue(0, QString())",
342 "QScriptValue(0, QString(\"0\"))",
343 "QScriptValue(0, QString(\"123\"))",
344 "QScriptValue(0, QString(\"12.3\"))",
345 "QScriptValue(engine, QScriptValue::UndefinedValue)",
346 "QScriptValue(engine, QScriptValue::NullValue)",
347 "QScriptValue(engine, true)",
348 "QScriptValue(engine, false)",
349 "QScriptValue(engine, int(122))",
350 "QScriptValue(engine, uint(124))",
351 "QScriptValue(engine, 0)",
352 "QScriptValue(engine, 0.0)",
353 "QScriptValue(engine, 123.0)",
354 "QScriptValue(engine, 6.37e-8)",
355 "QScriptValue(engine, -6.37e-8)",
356 "QScriptValue(engine, 0x43211234)",
357 "QScriptValue(engine, 0x10000)",
358 "QScriptValue(engine, 0x10001)",
359 "QScriptValue(engine, qSNaN())",
360 "QScriptValue(engine, qQNaN())",
361 "QScriptValue(engine, qInf())",
362 "QScriptValue(engine, -qInf())",
363 "QScriptValue(engine, \"NaN\")",
364 "QScriptValue(engine, \"Infinity\")",
365 "QScriptValue(engine, \"-Infinity\")",
366 "QScriptValue(engine, \"ciao\")",
367 "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
368 "QScriptValue(engine, QString(\"\"))",
369 "QScriptValue(engine, QString())",
370 "QScriptValue(engine, QString(\"0\"))",
371 "QScriptValue(engine, QString(\"123\"))",
372 "QScriptValue(engine, QString(\"1.23\"))",
373 "engine->evaluate(\"[]\")",
374 "engine->evaluate(\"{}\")",
375 "engine->evaluate(\"Object.prototype\")",
376 "engine->evaluate(\"Date.prototype\")",
377 "engine->evaluate(\"Array.prototype\")",
378 "engine->evaluate(\"Function.prototype\")",
379 "engine->evaluate(\"Error.prototype\")",
380 "engine->evaluate(\"Object\")",
381 "engine->evaluate(\"Array\")",
382 "engine->evaluate(\"Number\")",
383 "engine->evaluate(\"Function\")",
384 "engine->evaluate(\"(function() { return 1; })\")",
385 "engine->evaluate(\"(function() { return 'ciao'; })\")",
386 "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
387 "engine->evaluate(\"/foo/\")",
388 "engine->evaluate(\"new Object()\")",
389 "engine->evaluate(\"new Array()\")",
390 "engine->evaluate(\"new Error()\")",
391 "engine->evaluate(\"new Boolean(true)\")",
392 "engine->evaluate(\"new Boolean(false)\")",
393 "engine->evaluate(\"new Number(123)\")",
394 "engine->evaluate(\"new RegExp('foo', 'gim')\")",
395 "engine->evaluate(\"new String('ciao')\")",
396 "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
397 "engine->evaluate(\"Undefined\")",
398 "engine->evaluate(\"Null\")",
399 "engine->evaluate(\"True\")",
400 "engine->evaluate(\"False\")",
401 "engine->evaluate(\"undefined\")",
402 "engine->evaluate(\"null\")",
403 "engine->evaluate(\"true\")",
404 "engine->evaluate(\"false\")",
405 "engine->evaluate(\"122\")",
406 "engine->evaluate(\"124\")",
407 "engine->evaluate(\"0\")",
408 "engine->evaluate(\"0.0\")",
409 "engine->evaluate(\"123.0\")",
410 "engine->evaluate(\"6.37e-8\")",
411 "engine->evaluate(\"-6.37e-8\")",
412 "engine->evaluate(\"0x43211234\")",
413 "engine->evaluate(\"0x10000\")",
414 "engine->evaluate(\"0x10001\")",
415 "engine->evaluate(\"NaN\")",
416 "engine->evaluate(\"Infinity\")",
417 "engine->evaluate(\"-Infinity\")",
418 "engine->evaluate(\"'ciao'\")",
419 "engine->evaluate(\"''\")",
420 "engine->evaluate(\"'0'\")",
421 "engine->evaluate(\"'123'\")",
422 "engine->evaluate(\"'12.4'\")",
423 "engine->nullValue()",
424 "engine->undefinedValue()",
425 "engine->newObject()",
426 "engine->newArray()",
427 "engine->newArray(10)",
428 "engine->newDate(QDateTime())",
429 "engine->newQMetaObject(&QObject::staticMetaObject)",
430 "engine->newRegExp(\"foo\", \"gim\")",
431 "engine->newVariant(QVariant())",
432 "engine->newVariant(QVariant(123))",
433 "engine->newVariant(QVariant(false))",
434 "engine->newQObject(0)",
435 "engine->newQObject(engine)"};
436static qsreal qscriptvalue_castqsreal_valueArray[] = {
437 0, qQNaN(), 0, 1, 0, 122, 124, 0, 0, 123,
438 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(),
439 qInf(), qInf(), qQNaN(), qQNaN(), 0, 0, 0, 123, 12.4, qQNaN(),
440 0, 1, 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08,
441 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(),
442 qQNaN(), qQNaN(), 0, 0, 0, 123, 12.3, qQNaN(), 0, 1,
443 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536,
444 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(), qQNaN(), qQNaN(),
445 0, 0, 0, 123, 1.23, 0, qQNaN(), qQNaN(), qQNaN(), 0,
446 qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(),
447 qQNaN(), 0, qQNaN(), 1, 0, 123, qQNaN(), qQNaN(), 22, qQNaN(),
448 qQNaN(), qQNaN(), qQNaN(), qQNaN(), 0, 1, 0, 122, 124, 0,
449 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qInf(), qInf(),
450 qQNaN(), 0, 0, 123, 12.4, 0, qQNaN(), qQNaN(), 0, qQNaN(),
451 qQNaN(), qQNaN(), qQNaN(), qQNaN(), 123, 0, 0, qQNaN()};
452void tst_QScriptValueGenerated::qscriptvalue_castqsreal_makeData(const char* expr)
453{
454 static const QHash<QString, qsreal> value =
455 charValueArraysToHash(keys: qscriptvalue_castqsreal_tagArray, values: qscriptvalue_castqsreal_valueArray,
456 size: int(sizeof(qscriptvalue_castqsreal_tagArray) / sizeof(const char *)));
457 newRow(tag: expr) << value.value(akey: expr);
458}
459
460void tst_QScriptValueGenerated::qscriptvalue_castqsreal_test(const char*, const QScriptValue& value)
461{
462 QFETCH(qsreal, expected);
463 if (qIsNaN(d: expected)) {
464 QVERIFY(qIsNaN(qscriptvalue_cast<qsreal>(value)));
465 QVERIFY(qIsNaN(qscriptvalue_cast<qsreal>(value)));
466 return;
467 }
468 if (qIsInf(d: expected)) {
469 QVERIFY(qIsInf(qscriptvalue_cast<qsreal>(value)));
470 QVERIFY(qIsInf(qscriptvalue_cast<qsreal>(value)));
471 return;
472 }
473 QCOMPARE(qscriptvalue_cast<qsreal>(value), expected);
474 QCOMPARE(qscriptvalue_cast<qsreal>(value), expected);
475}
476
477DEFINE_TEST_FUNCTION(qscriptvalue_castqsreal)
478
479
480void tst_QScriptValueGenerated::qscriptvalue_castbool_initData()
481{
482 QTest::addColumn<bool>(name: "expected");
483 initScriptValues();
484}
485
486static const char *qscriptvalue_castbool_tagArray[] = {
487 "QScriptValue()",
488 "QScriptValue(QScriptValue::UndefinedValue)",
489 "QScriptValue(QScriptValue::NullValue)",
490 "QScriptValue(true)",
491 "QScriptValue(false)",
492 "QScriptValue(int(122))",
493 "QScriptValue(uint(124))",
494 "QScriptValue(0)",
495 "QScriptValue(0.0)",
496 "QScriptValue(123.0)",
497 "QScriptValue(6.37e-8)",
498 "QScriptValue(-6.37e-8)",
499 "QScriptValue(0x43211234)",
500 "QScriptValue(0x10000)",
501 "QScriptValue(0x10001)",
502 "QScriptValue(qSNaN())",
503 "QScriptValue(qQNaN())",
504 "QScriptValue(qInf())",
505 "QScriptValue(-qInf())",
506 "QScriptValue(\"NaN\")",
507 "QScriptValue(\"Infinity\")",
508 "QScriptValue(\"-Infinity\")",
509 "QScriptValue(\"ciao\")",
510 "QScriptValue(QString::fromLatin1(\"ciao\"))",
511 "QScriptValue(QString(\"\"))",
512 "QScriptValue(QString())",
513 "QScriptValue(QString(\"0\"))",
514 "QScriptValue(QString(\"123\"))",
515 "QScriptValue(QString(\"12.4\"))",
516 "QScriptValue(0, QScriptValue::UndefinedValue)",
517 "QScriptValue(0, QScriptValue::NullValue)",
518 "QScriptValue(0, true)",
519 "QScriptValue(0, false)",
520 "QScriptValue(0, int(122))",
521 "QScriptValue(0, uint(124))",
522 "QScriptValue(0, 0)",
523 "QScriptValue(0, 0.0)",
524 "QScriptValue(0, 123.0)",
525 "QScriptValue(0, 6.37e-8)",
526 "QScriptValue(0, -6.37e-8)",
527 "QScriptValue(0, 0x43211234)",
528 "QScriptValue(0, 0x10000)",
529 "QScriptValue(0, 0x10001)",
530 "QScriptValue(0, qSNaN())",
531 "QScriptValue(0, qQNaN())",
532 "QScriptValue(0, qInf())",
533 "QScriptValue(0, -qInf())",
534 "QScriptValue(0, \"NaN\")",
535 "QScriptValue(0, \"Infinity\")",
536 "QScriptValue(0, \"-Infinity\")",
537 "QScriptValue(0, \"ciao\")",
538 "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
539 "QScriptValue(0, QString(\"\"))",
540 "QScriptValue(0, QString())",
541 "QScriptValue(0, QString(\"0\"))",
542 "QScriptValue(0, QString(\"123\"))",
543 "QScriptValue(0, QString(\"12.3\"))",
544 "QScriptValue(engine, QScriptValue::UndefinedValue)",
545 "QScriptValue(engine, QScriptValue::NullValue)",
546 "QScriptValue(engine, true)",
547 "QScriptValue(engine, false)",
548 "QScriptValue(engine, int(122))",
549 "QScriptValue(engine, uint(124))",
550 "QScriptValue(engine, 0)",
551 "QScriptValue(engine, 0.0)",
552 "QScriptValue(engine, 123.0)",
553 "QScriptValue(engine, 6.37e-8)",
554 "QScriptValue(engine, -6.37e-8)",
555 "QScriptValue(engine, 0x43211234)",
556 "QScriptValue(engine, 0x10000)",
557 "QScriptValue(engine, 0x10001)",
558 "QScriptValue(engine, qSNaN())",
559 "QScriptValue(engine, qQNaN())",
560 "QScriptValue(engine, qInf())",
561 "QScriptValue(engine, -qInf())",
562 "QScriptValue(engine, \"NaN\")",
563 "QScriptValue(engine, \"Infinity\")",
564 "QScriptValue(engine, \"-Infinity\")",
565 "QScriptValue(engine, \"ciao\")",
566 "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
567 "QScriptValue(engine, QString(\"\"))",
568 "QScriptValue(engine, QString())",
569 "QScriptValue(engine, QString(\"0\"))",
570 "QScriptValue(engine, QString(\"123\"))",
571 "QScriptValue(engine, QString(\"1.23\"))",
572 "engine->evaluate(\"[]\")",
573 "engine->evaluate(\"{}\")",
574 "engine->evaluate(\"Object.prototype\")",
575 "engine->evaluate(\"Date.prototype\")",
576 "engine->evaluate(\"Array.prototype\")",
577 "engine->evaluate(\"Function.prototype\")",
578 "engine->evaluate(\"Error.prototype\")",
579 "engine->evaluate(\"Object\")",
580 "engine->evaluate(\"Array\")",
581 "engine->evaluate(\"Number\")",
582 "engine->evaluate(\"Function\")",
583 "engine->evaluate(\"(function() { return 1; })\")",
584 "engine->evaluate(\"(function() { return 'ciao'; })\")",
585 "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
586 "engine->evaluate(\"/foo/\")",
587 "engine->evaluate(\"new Object()\")",
588 "engine->evaluate(\"new Array()\")",
589 "engine->evaluate(\"new Error()\")",
590 "engine->evaluate(\"new Boolean(true)\")",
591 "engine->evaluate(\"new Boolean(false)\")",
592 "engine->evaluate(\"new Number(123)\")",
593 "engine->evaluate(\"new RegExp('foo', 'gim')\")",
594 "engine->evaluate(\"new String('ciao')\")",
595 "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
596 "engine->evaluate(\"Undefined\")",
597 "engine->evaluate(\"Null\")",
598 "engine->evaluate(\"True\")",
599 "engine->evaluate(\"False\")",
600 "engine->evaluate(\"undefined\")",
601 "engine->evaluate(\"null\")",
602 "engine->evaluate(\"true\")",
603 "engine->evaluate(\"false\")",
604 "engine->evaluate(\"122\")",
605 "engine->evaluate(\"124\")",
606 "engine->evaluate(\"0\")",
607 "engine->evaluate(\"0.0\")",
608 "engine->evaluate(\"123.0\")",
609 "engine->evaluate(\"6.37e-8\")",
610 "engine->evaluate(\"-6.37e-8\")",
611 "engine->evaluate(\"0x43211234\")",
612 "engine->evaluate(\"0x10000\")",
613 "engine->evaluate(\"0x10001\")",
614 "engine->evaluate(\"NaN\")",
615 "engine->evaluate(\"Infinity\")",
616 "engine->evaluate(\"-Infinity\")",
617 "engine->evaluate(\"'ciao'\")",
618 "engine->evaluate(\"''\")",
619 "engine->evaluate(\"'0'\")",
620 "engine->evaluate(\"'123'\")",
621 "engine->evaluate(\"'12.4'\")",
622 "engine->nullValue()",
623 "engine->undefinedValue()",
624 "engine->newObject()",
625 "engine->newArray()",
626 "engine->newArray(10)",
627 "engine->newDate(QDateTime())",
628 "engine->newQMetaObject(&QObject::staticMetaObject)",
629 "engine->newRegExp(\"foo\", \"gim\")",
630 "engine->newVariant(QVariant())",
631 "engine->newVariant(QVariant(123))",
632 "engine->newVariant(QVariant(false))",
633 "engine->newQObject(0)",
634 "engine->newQObject(engine)"};
635static bool qscriptvalue_castbool_valueArray[] = {
636 false, false,
637 false, true,
638 false, true,
639 true, false,
640 false, true,
641 true, true,
642 true, true,
643 true, false,
644 false, true,
645 true, true,
646 true, true,
647 true, true,
648 false, false,
649 true, true,
650 true, false,
651 false, true,
652 false, true,
653 true, false,
654 false, true,
655 true, true,
656 true, true,
657 true, false,
658 false, true,
659 true, true,
660 true, true,
661 true, true,
662 false, false,
663 true, true,
664 true, false,
665 false, true,
666 false, true,
667 true, false,
668 false, true,
669 true, true,
670 true, true,
671 true, false,
672 false, true,
673 true, true,
674 true, true,
675 true, true,
676 false, false,
677 true, true,
678 true, true,
679 false, true,
680 true, true,
681 true, true,
682 true, true,
683 true, true,
684 true, true,
685 true, true,
686 true, true,
687 true, true,
688 true, true,
689 true, true,
690 true, true,
691 true, true,
692 true, false,
693 false, true,
694 false, true,
695 true, false,
696 false, true,
697 true, true,
698 true, true,
699 true, false,
700 true, true,
701 true, false,
702 true, true,
703 true, false,
704 false, true,
705 true, true,
706 true, true,
707 true, true,
708 true, true,
709 false, true};
710void tst_QScriptValueGenerated::qscriptvalue_castbool_makeData(const char* expr)
711{
712 static const QHash<QString, bool> value =
713 charValueArraysToHash(keys: qscriptvalue_castbool_tagArray, values: qscriptvalue_castbool_valueArray,
714 size: int(sizeof(qscriptvalue_castqsreal_tagArray) / sizeof(const char *)));
715 newRow(tag: expr) << value.value(akey: expr);
716}
717
718void tst_QScriptValueGenerated::qscriptvalue_castbool_test(const char*, const QScriptValue& value)
719{
720 QFETCH(bool, expected);
721 QCOMPARE(qscriptvalue_cast<bool>(value), expected);
722 QCOMPARE(qscriptvalue_cast<bool>(value), expected);
723}
724
725DEFINE_TEST_FUNCTION(qscriptvalue_castbool)
726
727
728void tst_QScriptValueGenerated::qscriptvalue_castqint32_initData()
729{
730 QTest::addColumn<qint32>(name: "expected");
731 initScriptValues();
732}
733
734static const char *qscriptvalue_castqint32_tagArray[] = {
735 "QScriptValue()",
736 "QScriptValue(QScriptValue::UndefinedValue)",
737 "QScriptValue(QScriptValue::NullValue)",
738 "QScriptValue(true)",
739 "QScriptValue(false)",
740 "QScriptValue(int(122))",
741 "QScriptValue(uint(124))",
742 "QScriptValue(0)",
743 "QScriptValue(0.0)",
744 "QScriptValue(123.0)",
745 "QScriptValue(6.37e-8)",
746 "QScriptValue(-6.37e-8)",
747 "QScriptValue(0x43211234)",
748 "QScriptValue(0x10000)",
749 "QScriptValue(0x10001)",
750 "QScriptValue(qSNaN())",
751 "QScriptValue(qQNaN())",
752 "QScriptValue(qInf())",
753 "QScriptValue(-qInf())",
754 "QScriptValue(\"NaN\")",
755 "QScriptValue(\"Infinity\")",
756 "QScriptValue(\"-Infinity\")",
757 "QScriptValue(\"ciao\")",
758 "QScriptValue(QString::fromLatin1(\"ciao\"))",
759 "QScriptValue(QString(\"\"))",
760 "QScriptValue(QString())",
761 "QScriptValue(QString(\"0\"))",
762 "QScriptValue(QString(\"123\"))",
763 "QScriptValue(QString(\"12.4\"))",
764 "QScriptValue(0, QScriptValue::UndefinedValue)",
765 "QScriptValue(0, QScriptValue::NullValue)",
766 "QScriptValue(0, true)",
767 "QScriptValue(0, false)",
768 "QScriptValue(0, int(122))",
769 "QScriptValue(0, uint(124))",
770 "QScriptValue(0, 0)",
771 "QScriptValue(0, 0.0)",
772 "QScriptValue(0, 123.0)",
773 "QScriptValue(0, 6.37e-8)",
774 "QScriptValue(0, -6.37e-8)",
775 "QScriptValue(0, 0x43211234)",
776 "QScriptValue(0, 0x10000)",
777 "QScriptValue(0, 0x10001)",
778 "QScriptValue(0, qSNaN())",
779 "QScriptValue(0, qQNaN())",
780 "QScriptValue(0, qInf())",
781 "QScriptValue(0, -qInf())",
782 "QScriptValue(0, \"NaN\")",
783 "QScriptValue(0, \"Infinity\")",
784 "QScriptValue(0, \"-Infinity\")",
785 "QScriptValue(0, \"ciao\")",
786 "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
787 "QScriptValue(0, QString(\"\"))",
788 "QScriptValue(0, QString())",
789 "QScriptValue(0, QString(\"0\"))",
790 "QScriptValue(0, QString(\"123\"))",
791 "QScriptValue(0, QString(\"12.3\"))",
792 "QScriptValue(engine, QScriptValue::UndefinedValue)",
793 "QScriptValue(engine, QScriptValue::NullValue)",
794 "QScriptValue(engine, true)",
795 "QScriptValue(engine, false)",
796 "QScriptValue(engine, int(122))",
797 "QScriptValue(engine, uint(124))",
798 "QScriptValue(engine, 0)",
799 "QScriptValue(engine, 0.0)",
800 "QScriptValue(engine, 123.0)",
801 "QScriptValue(engine, 6.37e-8)",
802 "QScriptValue(engine, -6.37e-8)",
803 "QScriptValue(engine, 0x43211234)",
804 "QScriptValue(engine, 0x10000)",
805 "QScriptValue(engine, 0x10001)",
806 "QScriptValue(engine, qSNaN())",
807 "QScriptValue(engine, qQNaN())",
808 "QScriptValue(engine, qInf())",
809 "QScriptValue(engine, -qInf())",
810 "QScriptValue(engine, \"NaN\")",
811 "QScriptValue(engine, \"Infinity\")",
812 "QScriptValue(engine, \"-Infinity\")",
813 "QScriptValue(engine, \"ciao\")",
814 "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
815 "QScriptValue(engine, QString(\"\"))",
816 "QScriptValue(engine, QString())",
817 "QScriptValue(engine, QString(\"0\"))",
818 "QScriptValue(engine, QString(\"123\"))",
819 "QScriptValue(engine, QString(\"1.23\"))",
820 "engine->evaluate(\"[]\")",
821 "engine->evaluate(\"{}\")",
822 "engine->evaluate(\"Object.prototype\")",
823 "engine->evaluate(\"Date.prototype\")",
824 "engine->evaluate(\"Array.prototype\")",
825 "engine->evaluate(\"Function.prototype\")",
826 "engine->evaluate(\"Error.prototype\")",
827 "engine->evaluate(\"Object\")",
828 "engine->evaluate(\"Array\")",
829 "engine->evaluate(\"Number\")",
830 "engine->evaluate(\"Function\")",
831 "engine->evaluate(\"(function() { return 1; })\")",
832 "engine->evaluate(\"(function() { return 'ciao'; })\")",
833 "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
834 "engine->evaluate(\"/foo/\")",
835 "engine->evaluate(\"new Object()\")",
836 "engine->evaluate(\"new Array()\")",
837 "engine->evaluate(\"new Error()\")",
838 "engine->evaluate(\"new Boolean(true)\")",
839 "engine->evaluate(\"new Boolean(false)\")",
840 "engine->evaluate(\"new Number(123)\")",
841 "engine->evaluate(\"new RegExp('foo', 'gim')\")",
842 "engine->evaluate(\"new String('ciao')\")",
843 "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
844 "engine->evaluate(\"Undefined\")",
845 "engine->evaluate(\"Null\")",
846 "engine->evaluate(\"True\")",
847 "engine->evaluate(\"False\")",
848 "engine->evaluate(\"undefined\")",
849 "engine->evaluate(\"null\")",
850 "engine->evaluate(\"true\")",
851 "engine->evaluate(\"false\")",
852 "engine->evaluate(\"122\")",
853 "engine->evaluate(\"124\")",
854 "engine->evaluate(\"0\")",
855 "engine->evaluate(\"0.0\")",
856 "engine->evaluate(\"123.0\")",
857 "engine->evaluate(\"6.37e-8\")",
858 "engine->evaluate(\"-6.37e-8\")",
859 "engine->evaluate(\"0x43211234\")",
860 "engine->evaluate(\"0x10000\")",
861 "engine->evaluate(\"0x10001\")",
862 "engine->evaluate(\"NaN\")",
863 "engine->evaluate(\"Infinity\")",
864 "engine->evaluate(\"-Infinity\")",
865 "engine->evaluate(\"'ciao'\")",
866 "engine->evaluate(\"''\")",
867 "engine->evaluate(\"'0'\")",
868 "engine->evaluate(\"'123'\")",
869 "engine->evaluate(\"'12.4'\")",
870 "engine->nullValue()",
871 "engine->undefinedValue()",
872 "engine->newObject()",
873 "engine->newArray()",
874 "engine->newArray(10)",
875 "engine->newDate(QDateTime())",
876 "engine->newQMetaObject(&QObject::staticMetaObject)",
877 "engine->newRegExp(\"foo\", \"gim\")",
878 "engine->newVariant(QVariant())",
879 "engine->newVariant(QVariant(123))",
880 "engine->newVariant(QVariant(false))",
881 "engine->newQObject(0)",
882 "engine->newQObject(engine)"};
883static qint32 qscriptvalue_castqint32_valueArray[] = {
884 0, 0,
885 0, 1,
886 0, 122,
887 124, 0,
888 0, 123,
889 0, 0,
890 1126240820, 65536,
891 65537, 0,
892 0, 0,
893 0, 0,
894 0, 0,
895 0, 0,
896 0, 0,
897 0, 123,
898 12, 0,
899 0, 1,
900 0, 122,
901 124, 0,
902 0, 123,
903 0, 0,
904 1126240820, 65536,
905 65537, 0,
906 0, 0,
907 0, 0,
908 0, 0,
909 0, 0,
910 0, 0,
911 0, 123,
912 12, 0,
913 0, 1,
914 0, 122,
915 124, 0,
916 0, 123,
917 0, 0,
918 1126240820, 65536,
919 65537, 0,
920 0, 0,
921 0, 0,
922 0, 0,
923 0, 0,
924 0, 0,
925 0, 123,
926 1, 0,
927 0, 0,
928 0, 0,
929 0, 0,
930 0, 0,
931 0, 0,
932 0, 0,
933 0, 0,
934 0, 0,
935 0, 1,
936 0, 123,
937 0, 0,
938 22, 0,
939 0, 0,
940 0, 0,
941 0, 1,
942 0, 122,
943 124, 0,
944 0, 123,
945 0, 0,
946 1126240820, 65536,
947 65537, 0,
948 0, 0,
949 0, 0,
950 0, 123,
951 12, 0,
952 0, 0,
953 0, 0,
954 0, 0,
955 0, 0,
956 123, 0,
957 0, 0};
958void tst_QScriptValueGenerated::qscriptvalue_castqint32_makeData(const char* expr)
959{
960 static const QHash<QString, qint32> value =
961 charValueArraysToHash(keys: qscriptvalue_castqint32_tagArray, values: qscriptvalue_castqint32_valueArray,
962 size: int(sizeof(qscriptvalue_castqint32_tagArray) / sizeof(const char *)));
963 newRow(tag: expr) << value.value(akey: expr);
964}
965
966void tst_QScriptValueGenerated::qscriptvalue_castqint32_test(const char*, const QScriptValue& value)
967{
968 QFETCH(qint32, expected);
969 QCOMPARE(qscriptvalue_cast<qint32>(value), expected);
970 QCOMPARE(qscriptvalue_cast<qint32>(value), expected);
971}
972
973DEFINE_TEST_FUNCTION(qscriptvalue_castqint32)
974
975
976void tst_QScriptValueGenerated::qscriptvalue_castquint32_initData()
977{
978 QTest::addColumn<quint32>(name: "expected");
979 initScriptValues();
980}
981
982static const char *qscriptvalue_castquint32_tagArray[] = {
983 "QScriptValue()",
984 "QScriptValue(QScriptValue::UndefinedValue)",
985 "QScriptValue(QScriptValue::NullValue)",
986 "QScriptValue(true)",
987 "QScriptValue(false)",
988 "QScriptValue(int(122))",
989 "QScriptValue(uint(124))",
990 "QScriptValue(0)",
991 "QScriptValue(0.0)",
992 "QScriptValue(123.0)",
993 "QScriptValue(6.37e-8)",
994 "QScriptValue(-6.37e-8)",
995 "QScriptValue(0x43211234)",
996 "QScriptValue(0x10000)",
997 "QScriptValue(0x10001)",
998 "QScriptValue(qSNaN())",
999 "QScriptValue(qQNaN())",
1000 "QScriptValue(qInf())",
1001 "QScriptValue(-qInf())",
1002 "QScriptValue(\"NaN\")",
1003 "QScriptValue(\"Infinity\")",
1004 "QScriptValue(\"-Infinity\")",
1005 "QScriptValue(\"ciao\")",
1006 "QScriptValue(QString::fromLatin1(\"ciao\"))",
1007 "QScriptValue(QString(\"\"))",
1008 "QScriptValue(QString())",
1009 "QScriptValue(QString(\"0\"))",
1010 "QScriptValue(QString(\"123\"))",
1011 "QScriptValue(QString(\"12.4\"))",
1012 "QScriptValue(0, QScriptValue::UndefinedValue)",
1013 "QScriptValue(0, QScriptValue::NullValue)",
1014 "QScriptValue(0, true)",
1015 "QScriptValue(0, false)",
1016 "QScriptValue(0, int(122))",
1017 "QScriptValue(0, uint(124))",
1018 "QScriptValue(0, 0)",
1019 "QScriptValue(0, 0.0)",
1020 "QScriptValue(0, 123.0)",
1021 "QScriptValue(0, 6.37e-8)",
1022 "QScriptValue(0, -6.37e-8)",
1023 "QScriptValue(0, 0x43211234)",
1024 "QScriptValue(0, 0x10000)",
1025 "QScriptValue(0, 0x10001)",
1026 "QScriptValue(0, qSNaN())",
1027 "QScriptValue(0, qQNaN())",
1028 "QScriptValue(0, qInf())",
1029 "QScriptValue(0, -qInf())",
1030 "QScriptValue(0, \"NaN\")",
1031 "QScriptValue(0, \"Infinity\")",
1032 "QScriptValue(0, \"-Infinity\")",
1033 "QScriptValue(0, \"ciao\")",
1034 "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
1035 "QScriptValue(0, QString(\"\"))",
1036 "QScriptValue(0, QString())",
1037 "QScriptValue(0, QString(\"0\"))",
1038 "QScriptValue(0, QString(\"123\"))",
1039 "QScriptValue(0, QString(\"12.3\"))",
1040 "QScriptValue(engine, QScriptValue::UndefinedValue)",
1041 "QScriptValue(engine, QScriptValue::NullValue)",
1042 "QScriptValue(engine, true)",
1043 "QScriptValue(engine, false)",
1044 "QScriptValue(engine, int(122))",
1045 "QScriptValue(engine, uint(124))",
1046 "QScriptValue(engine, 0)",
1047 "QScriptValue(engine, 0.0)",
1048 "QScriptValue(engine, 123.0)",
1049 "QScriptValue(engine, 6.37e-8)",
1050 "QScriptValue(engine, -6.37e-8)",
1051 "QScriptValue(engine, 0x43211234)",
1052 "QScriptValue(engine, 0x10000)",
1053 "QScriptValue(engine, 0x10001)",
1054 "QScriptValue(engine, qSNaN())",
1055 "QScriptValue(engine, qQNaN())",
1056 "QScriptValue(engine, qInf())",
1057 "QScriptValue(engine, -qInf())",
1058 "QScriptValue(engine, \"NaN\")",
1059 "QScriptValue(engine, \"Infinity\")",
1060 "QScriptValue(engine, \"-Infinity\")",
1061 "QScriptValue(engine, \"ciao\")",
1062 "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
1063 "QScriptValue(engine, QString(\"\"))",
1064 "QScriptValue(engine, QString())",
1065 "QScriptValue(engine, QString(\"0\"))",
1066 "QScriptValue(engine, QString(\"123\"))",
1067 "QScriptValue(engine, QString(\"1.23\"))",
1068 "engine->evaluate(\"[]\")",
1069 "engine->evaluate(\"{}\")",
1070 "engine->evaluate(\"Object.prototype\")",
1071 "engine->evaluate(\"Date.prototype\")",
1072 "engine->evaluate(\"Array.prototype\")",
1073 "engine->evaluate(\"Function.prototype\")",
1074 "engine->evaluate(\"Error.prototype\")",
1075 "engine->evaluate(\"Object\")",
1076 "engine->evaluate(\"Array\")",
1077 "engine->evaluate(\"Number\")",
1078 "engine->evaluate(\"Function\")",
1079 "engine->evaluate(\"(function() { return 1; })\")",
1080 "engine->evaluate(\"(function() { return 'ciao'; })\")",
1081 "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
1082 "engine->evaluate(\"/foo/\")",
1083 "engine->evaluate(\"new Object()\")",
1084 "engine->evaluate(\"new Array()\")",
1085 "engine->evaluate(\"new Error()\")",
1086 "engine->evaluate(\"new Boolean(true)\")",
1087 "engine->evaluate(\"new Boolean(false)\")",
1088 "engine->evaluate(\"new Number(123)\")",
1089 "engine->evaluate(\"new RegExp('foo', 'gim')\")",
1090 "engine->evaluate(\"new String('ciao')\")",
1091 "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
1092 "engine->evaluate(\"Undefined\")",
1093 "engine->evaluate(\"Null\")",
1094 "engine->evaluate(\"True\")",
1095 "engine->evaluate(\"False\")",
1096 "engine->evaluate(\"undefined\")",
1097 "engine->evaluate(\"null\")",
1098 "engine->evaluate(\"true\")",
1099 "engine->evaluate(\"false\")",
1100 "engine->evaluate(\"122\")",
1101 "engine->evaluate(\"124\")",
1102 "engine->evaluate(\"0\")",
1103 "engine->evaluate(\"0.0\")",
1104 "engine->evaluate(\"123.0\")",
1105 "engine->evaluate(\"6.37e-8\")",
1106 "engine->evaluate(\"-6.37e-8\")",
1107 "engine->evaluate(\"0x43211234\")",
1108 "engine->evaluate(\"0x10000\")",
1109 "engine->evaluate(\"0x10001\")",
1110 "engine->evaluate(\"NaN\")",
1111 "engine->evaluate(\"Infinity\")",
1112 "engine->evaluate(\"-Infinity\")",
1113 "engine->evaluate(\"'ciao'\")",
1114 "engine->evaluate(\"''\")",
1115 "engine->evaluate(\"'0'\")",
1116 "engine->evaluate(\"'123'\")",
1117 "engine->evaluate(\"'12.4'\")",
1118 "engine->nullValue()",
1119 "engine->undefinedValue()",
1120 "engine->newObject()",
1121 "engine->newArray()",
1122 "engine->newArray(10)",
1123 "engine->newDate(QDateTime())",
1124 "engine->newQMetaObject(&QObject::staticMetaObject)",
1125 "engine->newRegExp(\"foo\", \"gim\")",
1126 "engine->newVariant(QVariant())",
1127 "engine->newVariant(QVariant(123))",
1128 "engine->newVariant(QVariant(false))",
1129 "engine->newQObject(0)",
1130 "engine->newQObject(engine)"};
1131static quint32 qscriptvalue_castquint32_valueArray[] = {
1132 0, 0,
1133 0, 1,
1134 0, 122,
1135 124, 0,
1136 0, 123,
1137 0, 0,
1138 1126240820, 65536,
1139 65537, 0,
1140 0, 0,
1141 0, 0,
1142 0, 0,
1143 0, 0,
1144 0, 0,
1145 0, 123,
1146 12, 0,
1147 0, 1,
1148 0, 122,
1149 124, 0,
1150 0, 123,
1151 0, 0,
1152 1126240820, 65536,
1153 65537, 0,
1154 0, 0,
1155 0, 0,
1156 0, 0,
1157 0, 0,
1158 0, 0,
1159 0, 123,
1160 12, 0,
1161 0, 1,
1162 0, 122,
1163 124, 0,
1164 0, 123,
1165 0, 0,
1166 1126240820, 65536,
1167 65537, 0,
1168 0, 0,
1169 0, 0,
1170 0, 0,
1171 0, 0,
1172 0, 0,
1173 0, 123,
1174 1, 0,
1175 0, 0,
1176 0, 0,
1177 0, 0,
1178 0, 0,
1179 0, 0,
1180 0, 0,
1181 0, 0,
1182 0, 0,
1183 0, 1,
1184 0, 123,
1185 0, 0,
1186 22, 0,
1187 0, 0,
1188 0, 0,
1189 0, 1,
1190 0, 122,
1191 124, 0,
1192 0, 123,
1193 0, 0,
1194 1126240820, 65536,
1195 65537, 0,
1196 0, 0,
1197 0, 0,
1198 0, 123,
1199 12, 0,
1200 0, 0,
1201 0, 0,
1202 0, 0,
1203 0, 0,
1204 123, 0,
1205 0, 0};
1206void tst_QScriptValueGenerated::qscriptvalue_castquint32_makeData(const char* expr)
1207{
1208 static const QHash<QString, quint32> value =
1209 charValueArraysToHash(keys: qscriptvalue_castquint32_tagArray, values: qscriptvalue_castquint32_valueArray,
1210 size: int(sizeof(qscriptvalue_castquint32_tagArray) / sizeof(const char *)));
1211 newRow(tag: expr) << value.value(akey: expr);
1212}
1213
1214void tst_QScriptValueGenerated::qscriptvalue_castquint32_test(const char*, const QScriptValue& value)
1215{
1216 QFETCH(quint32, expected);
1217 QCOMPARE(qscriptvalue_cast<quint32>(value), expected);
1218 QCOMPARE(qscriptvalue_cast<quint32>(value), expected);
1219}
1220
1221DEFINE_TEST_FUNCTION(qscriptvalue_castquint32)
1222
1223
1224void tst_QScriptValueGenerated::qscriptvalue_castquint16_initData()
1225{
1226 QTest::addColumn<quint16>(name: "expected");
1227 initScriptValues();
1228}
1229
1230static const char *qscriptvalue_castquint16_tagArray[] = {
1231 "QScriptValue()",
1232 "QScriptValue(QScriptValue::UndefinedValue)",
1233 "QScriptValue(QScriptValue::NullValue)",
1234 "QScriptValue(true)",
1235 "QScriptValue(false)",
1236 "QScriptValue(int(122))",
1237 "QScriptValue(uint(124))",
1238 "QScriptValue(0)",
1239 "QScriptValue(0.0)",
1240 "QScriptValue(123.0)",
1241 "QScriptValue(6.37e-8)",
1242 "QScriptValue(-6.37e-8)",
1243 "QScriptValue(0x43211234)",
1244 "QScriptValue(0x10000)",
1245 "QScriptValue(0x10001)",
1246 "QScriptValue(qSNaN())",
1247 "QScriptValue(qQNaN())",
1248 "QScriptValue(qInf())",
1249 "QScriptValue(-qInf())",
1250 "QScriptValue(\"NaN\")",
1251 "QScriptValue(\"Infinity\")",
1252 "QScriptValue(\"-Infinity\")",
1253 "QScriptValue(\"ciao\")",
1254 "QScriptValue(QString::fromLatin1(\"ciao\"))",
1255 "QScriptValue(QString(\"\"))",
1256 "QScriptValue(QString())",
1257 "QScriptValue(QString(\"0\"))",
1258 "QScriptValue(QString(\"123\"))",
1259 "QScriptValue(QString(\"12.4\"))",
1260 "QScriptValue(0, QScriptValue::UndefinedValue)",
1261 "QScriptValue(0, QScriptValue::NullValue)",
1262 "QScriptValue(0, true)",
1263 "QScriptValue(0, false)",
1264 "QScriptValue(0, int(122))",
1265 "QScriptValue(0, uint(124))",
1266 "QScriptValue(0, 0)",
1267 "QScriptValue(0, 0.0)",
1268 "QScriptValue(0, 123.0)",
1269 "QScriptValue(0, 6.37e-8)",
1270 "QScriptValue(0, -6.37e-8)",
1271 "QScriptValue(0, 0x43211234)",
1272 "QScriptValue(0, 0x10000)",
1273 "QScriptValue(0, 0x10001)",
1274 "QScriptValue(0, qSNaN())",
1275 "QScriptValue(0, qQNaN())",
1276 "QScriptValue(0, qInf())",
1277 "QScriptValue(0, -qInf())",
1278 "QScriptValue(0, \"NaN\")",
1279 "QScriptValue(0, \"Infinity\")",
1280 "QScriptValue(0, \"-Infinity\")",
1281 "QScriptValue(0, \"ciao\")",
1282 "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
1283 "QScriptValue(0, QString(\"\"))",
1284 "QScriptValue(0, QString())",
1285 "QScriptValue(0, QString(\"0\"))",
1286 "QScriptValue(0, QString(\"123\"))",
1287 "QScriptValue(0, QString(\"12.3\"))",
1288 "QScriptValue(engine, QScriptValue::UndefinedValue)",
1289 "QScriptValue(engine, QScriptValue::NullValue)",
1290 "QScriptValue(engine, true)",
1291 "QScriptValue(engine, false)",
1292 "QScriptValue(engine, int(122))",
1293 "QScriptValue(engine, uint(124))",
1294 "QScriptValue(engine, 0)",
1295 "QScriptValue(engine, 0.0)",
1296 "QScriptValue(engine, 123.0)",
1297 "QScriptValue(engine, 6.37e-8)",
1298 "QScriptValue(engine, -6.37e-8)",
1299 "QScriptValue(engine, 0x43211234)",
1300 "QScriptValue(engine, 0x10000)",
1301 "QScriptValue(engine, 0x10001)",
1302 "QScriptValue(engine, qSNaN())",
1303 "QScriptValue(engine, qQNaN())",
1304 "QScriptValue(engine, qInf())",
1305 "QScriptValue(engine, -qInf())",
1306 "QScriptValue(engine, \"NaN\")",
1307 "QScriptValue(engine, \"Infinity\")",
1308 "QScriptValue(engine, \"-Infinity\")",
1309 "QScriptValue(engine, \"ciao\")",
1310 "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
1311 "QScriptValue(engine, QString(\"\"))",
1312 "QScriptValue(engine, QString())",
1313 "QScriptValue(engine, QString(\"0\"))",
1314 "QScriptValue(engine, QString(\"123\"))",
1315 "QScriptValue(engine, QString(\"1.23\"))",
1316 "engine->evaluate(\"[]\")",
1317 "engine->evaluate(\"{}\")",
1318 "engine->evaluate(\"Object.prototype\")",
1319 "engine->evaluate(\"Date.prototype\")",
1320 "engine->evaluate(\"Array.prototype\")",
1321 "engine->evaluate(\"Function.prototype\")",
1322 "engine->evaluate(\"Error.prototype\")",
1323 "engine->evaluate(\"Object\")",
1324 "engine->evaluate(\"Array\")",
1325 "engine->evaluate(\"Number\")",
1326 "engine->evaluate(\"Function\")",
1327 "engine->evaluate(\"(function() { return 1; })\")",
1328 "engine->evaluate(\"(function() { return 'ciao'; })\")",
1329 "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
1330 "engine->evaluate(\"/foo/\")",
1331 "engine->evaluate(\"new Object()\")",
1332 "engine->evaluate(\"new Array()\")",
1333 "engine->evaluate(\"new Error()\")",
1334 "engine->evaluate(\"new Boolean(true)\")",
1335 "engine->evaluate(\"new Boolean(false)\")",
1336 "engine->evaluate(\"new Number(123)\")",
1337 "engine->evaluate(\"new RegExp('foo', 'gim')\")",
1338 "engine->evaluate(\"new String('ciao')\")",
1339 "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
1340 "engine->evaluate(\"Undefined\")",
1341 "engine->evaluate(\"Null\")",
1342 "engine->evaluate(\"True\")",
1343 "engine->evaluate(\"False\")",
1344 "engine->evaluate(\"undefined\")",
1345 "engine->evaluate(\"null\")",
1346 "engine->evaluate(\"true\")",
1347 "engine->evaluate(\"false\")",
1348 "engine->evaluate(\"122\")",
1349 "engine->evaluate(\"124\")",
1350 "engine->evaluate(\"0\")",
1351 "engine->evaluate(\"0.0\")",
1352 "engine->evaluate(\"123.0\")",
1353 "engine->evaluate(\"6.37e-8\")",
1354 "engine->evaluate(\"-6.37e-8\")",
1355 "engine->evaluate(\"0x43211234\")",
1356 "engine->evaluate(\"0x10000\")",
1357 "engine->evaluate(\"0x10001\")",
1358 "engine->evaluate(\"NaN\")",
1359 "engine->evaluate(\"Infinity\")",
1360 "engine->evaluate(\"-Infinity\")",
1361 "engine->evaluate(\"'ciao'\")",
1362 "engine->evaluate(\"''\")",
1363 "engine->evaluate(\"'0'\")",
1364 "engine->evaluate(\"'123'\")",
1365 "engine->evaluate(\"'12.4'\")",
1366 "engine->nullValue()",
1367 "engine->undefinedValue()",
1368 "engine->newObject()",
1369 "engine->newArray()",
1370 "engine->newArray(10)",
1371 "engine->newDate(QDateTime())",
1372 "engine->newQMetaObject(&QObject::staticMetaObject)",
1373 "engine->newRegExp(\"foo\", \"gim\")",
1374 "engine->newVariant(QVariant())",
1375 "engine->newVariant(QVariant(123))",
1376 "engine->newVariant(QVariant(false))",
1377 "engine->newQObject(0)",
1378 "engine->newQObject(engine)"};
1379static quint16 qscriptvalue_castquint16_valueArray[] = {
1380 0, 0,
1381 0, 1,
1382 0, 122,
1383 124, 0,
1384 0, 123,
1385 0, 0,
1386 4660, 0,
1387 1, 0,
1388 0, 0,
1389 0, 0,
1390 0, 0,
1391 0, 0,
1392 0, 0,
1393 0, 123,
1394 12, 0,
1395 0, 1,
1396 0, 122,
1397 124, 0,
1398 0, 123,
1399 0, 0,
1400 4660, 0,
1401 1, 0,
1402 0, 0,
1403 0, 0,
1404 0, 0,
1405 0, 0,
1406 0, 0,
1407 0, 123,
1408 12, 0,
1409 0, 1,
1410 0, 122,
1411 124, 0,
1412 0, 123,
1413 0, 0,
1414 4660, 0,
1415 1, 0,
1416 0, 0,
1417 0, 0,
1418 0, 0,
1419 0, 0,
1420 0, 0,
1421 0, 123,
1422 1, 0,
1423 0, 0,
1424 0, 0,
1425 0, 0,
1426 0, 0,
1427 0, 0,
1428 0, 0,
1429 0, 0,
1430 0, 0,
1431 0, 1,
1432 0, 123,
1433 0, 0,
1434 22, 0,
1435 0, 0,
1436 0, 0,
1437 0, 1,
1438 0, 122,
1439 124, 0,
1440 0, 123,
1441 0, 0,
1442 4660, 0,
1443 1, 0,
1444 0, 0,
1445 0, 0,
1446 0, 123,
1447 12, 0,
1448 0, 0,
1449 0, 0,
1450 0, 0,
1451 0, 0,
1452 123, 0,
1453 0, 0};
1454void tst_QScriptValueGenerated::qscriptvalue_castquint16_makeData(const char* expr)
1455{
1456 static const QHash<QString, quint16> value =
1457 charValueArraysToHash(keys: qscriptvalue_castquint16_tagArray, values: qscriptvalue_castquint16_valueArray,
1458 size: int(sizeof(qscriptvalue_castquint16_tagArray) / sizeof(const char *)));
1459 newRow(tag: expr) << value.value(akey: expr);
1460}
1461
1462void tst_QScriptValueGenerated::qscriptvalue_castquint16_test(const char*, const QScriptValue& value)
1463{
1464 QFETCH(quint16, expected);
1465 QCOMPARE(qscriptvalue_cast<quint16>(value), expected);
1466 QCOMPARE(qscriptvalue_cast<quint16>(value), expected);
1467}
1468
1469DEFINE_TEST_FUNCTION(qscriptvalue_castquint16)
1470

source code of qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue_generated_cast.cpp