| 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 | |
| 33 | void tst_QScriptValueGenerated::toString_initData() |
| 34 | { |
| 35 | QTest::addColumn<QString>(name: "expected" ); |
| 36 | initScriptValues(); |
| 37 | } |
| 38 | |
| 39 | static const char *toString_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)" }; |
| 188 | |
| 189 | static const char *toString_valueArray[] = { |
| 190 | "" , "undefined" , |
| 191 | "null" , "true" , |
| 192 | "false" , "122" , |
| 193 | "124" , "0" , |
| 194 | "0" , "123" , |
| 195 | "6.37e-8" , "-6.37e-8" , |
| 196 | "1126240820" , "65536" , |
| 197 | "65537" , "NaN" , |
| 198 | "NaN" , "Infinity" , |
| 199 | "-Infinity" , "NaN" , |
| 200 | "Infinity" , "-Infinity" , |
| 201 | "ciao" , "ciao" , |
| 202 | "" , "" , |
| 203 | "0" , "123" , |
| 204 | "12.4" , "undefined" , |
| 205 | "null" , "true" , |
| 206 | "false" , "122" , |
| 207 | "124" , "0" , |
| 208 | "0" , "123" , |
| 209 | "6.37e-8" , "-6.37e-8" , |
| 210 | "1126240820" , "65536" , |
| 211 | "65537" , "NaN" , |
| 212 | "NaN" , "Infinity" , |
| 213 | "-Infinity" , "NaN" , |
| 214 | "Infinity" , "-Infinity" , |
| 215 | "ciao" , "ciao" , |
| 216 | "" , "" , |
| 217 | "0" , "123" , |
| 218 | "12.3" , "undefined" , |
| 219 | "null" , "true" , |
| 220 | "false" , "122" , |
| 221 | "124" , "0" , |
| 222 | "0" , "123" , |
| 223 | "6.37e-8" , "-6.37e-8" , |
| 224 | "1126240820" , "65536" , |
| 225 | "65537" , "NaN" , |
| 226 | "NaN" , "Infinity" , |
| 227 | "-Infinity" , "NaN" , |
| 228 | "Infinity" , "-Infinity" , |
| 229 | "ciao" , "ciao" , |
| 230 | "" , "" , |
| 231 | "0" , "123" , |
| 232 | "1.23" , "" , |
| 233 | "undefined" , "[object Object]" , |
| 234 | "Invalid Date" , "" , |
| 235 | "function () {\n [native code]\n}" , "Error: Unknown error" , |
| 236 | "function Object() {\n [native code]\n}" , "function Array() {\n [native code]\n}" , |
| 237 | "function Number() {\n [native code]\n}" , "function Function() {\n [native code]\n}" , |
| 238 | "function () { return 1; }" , "function () { return 'ciao'; }" , |
| 239 | "function () { throw new Error('foo'); }" , "/foo/" , |
| 240 | "[object Object]" , "" , |
| 241 | "Error: Unknown error" , "true" , |
| 242 | "false" , "123" , |
| 243 | "/foo/gim" , "ciao" , |
| 244 | "22" , "ReferenceError: Can't find variable: Undefined" , |
| 245 | "ReferenceError: Can't find variable: Null" , "ReferenceError: Can't find variable: True" , |
| 246 | "ReferenceError: Can't find variable: False" , "undefined" , |
| 247 | "null" , "true" , |
| 248 | "false" , "122" , |
| 249 | "124" , "0" , |
| 250 | "0" , "123" , |
| 251 | "6.37e-8" , "-6.37e-8" , |
| 252 | "1126240820" , "65536" , |
| 253 | "65537" , "NaN" , |
| 254 | "Infinity" , "-Infinity" , |
| 255 | "ciao" , "" , |
| 256 | "0" , "123" , |
| 257 | "12.4" , "null" , |
| 258 | "undefined" , "[object Object]" , |
| 259 | "" , ",,,,,,,,," , |
| 260 | "Invalid Date" , "[object QMetaObject]" , |
| 261 | "/foo/gim" , "undefined" , |
| 262 | "123" , "false" , |
| 263 | "null" , "QScriptEngine(name = \"\")" }; |
| 264 | |
| 265 | void tst_QScriptValueGenerated::toString_makeData(const char* expr) |
| 266 | { |
| 267 | static const QHash<QString, QString> toString = |
| 268 | charArraysToStringHash(keys: toString_tagArray, values: toString_valueArray, |
| 269 | size: int(sizeof(toString_tagArray) / sizeof(const char *))); |
| 270 | newRow(tag: expr) << toString.value(akey: expr); |
| 271 | } |
| 272 | |
| 273 | void tst_QScriptValueGenerated::toString_test(const char*, const QScriptValue& value) |
| 274 | { |
| 275 | QFETCH(QString, expected); |
| 276 | QCOMPARE(value.toString(), expected); |
| 277 | QCOMPARE(value.toString(), expected); |
| 278 | } |
| 279 | |
| 280 | DEFINE_TEST_FUNCTION(toString) |
| 281 | |
| 282 | |
| 283 | void tst_QScriptValueGenerated::toNumber_initData() |
| 284 | { |
| 285 | QTest::addColumn<qsreal>(name: "expected" ); |
| 286 | initScriptValues(); |
| 287 | } |
| 288 | |
| 289 | static const char *toNumber_tagArray[] = { |
| 290 | "QScriptValue()" , |
| 291 | "QScriptValue(QScriptValue::UndefinedValue)" , |
| 292 | "QScriptValue(QScriptValue::NullValue)" , |
| 293 | "QScriptValue(true)" , |
| 294 | "QScriptValue(false)" , |
| 295 | "QScriptValue(int(122))" , |
| 296 | "QScriptValue(uint(124))" , |
| 297 | "QScriptValue(0)" , |
| 298 | "QScriptValue(0.0)" , |
| 299 | "QScriptValue(123.0)" , |
| 300 | "QScriptValue(6.37e-8)" , |
| 301 | "QScriptValue(-6.37e-8)" , |
| 302 | "QScriptValue(0x43211234)" , |
| 303 | "QScriptValue(0x10000)" , |
| 304 | "QScriptValue(0x10001)" , |
| 305 | "QScriptValue(qSNaN())" , |
| 306 | "QScriptValue(qQNaN())" , |
| 307 | "QScriptValue(qInf())" , |
| 308 | "QScriptValue(-qInf())" , |
| 309 | "QScriptValue(\"NaN\")" , |
| 310 | "QScriptValue(\"Infinity\")" , |
| 311 | "QScriptValue(\"-Infinity\")" , |
| 312 | "QScriptValue(\"ciao\")" , |
| 313 | "QScriptValue(QString::fromLatin1(\"ciao\"))" , |
| 314 | "QScriptValue(QString(\"\"))" , |
| 315 | "QScriptValue(QString())" , |
| 316 | "QScriptValue(QString(\"0\"))" , |
| 317 | "QScriptValue(QString(\"123\"))" , |
| 318 | "QScriptValue(QString(\"12.4\"))" , |
| 319 | "QScriptValue(0, QScriptValue::UndefinedValue)" , |
| 320 | "QScriptValue(0, QScriptValue::NullValue)" , |
| 321 | "QScriptValue(0, true)" , |
| 322 | "QScriptValue(0, false)" , |
| 323 | "QScriptValue(0, int(122))" , |
| 324 | "QScriptValue(0, uint(124))" , |
| 325 | "QScriptValue(0, 0)" , |
| 326 | "QScriptValue(0, 0.0)" , |
| 327 | "QScriptValue(0, 123.0)" , |
| 328 | "QScriptValue(0, 6.37e-8)" , |
| 329 | "QScriptValue(0, -6.37e-8)" , |
| 330 | "QScriptValue(0, 0x43211234)" , |
| 331 | "QScriptValue(0, 0x10000)" , |
| 332 | "QScriptValue(0, 0x10001)" , |
| 333 | "QScriptValue(0, qSNaN())" , |
| 334 | "QScriptValue(0, qQNaN())" , |
| 335 | "QScriptValue(0, qInf())" , |
| 336 | "QScriptValue(0, -qInf())" , |
| 337 | "QScriptValue(0, \"NaN\")" , |
| 338 | "QScriptValue(0, \"Infinity\")" , |
| 339 | "QScriptValue(0, \"-Infinity\")" , |
| 340 | "QScriptValue(0, \"ciao\")" , |
| 341 | "QScriptValue(0, QString::fromLatin1(\"ciao\"))" , |
| 342 | "QScriptValue(0, QString(\"\"))" , |
| 343 | "QScriptValue(0, QString())" , |
| 344 | "QScriptValue(0, QString(\"0\"))" , |
| 345 | "QScriptValue(0, QString(\"123\"))" , |
| 346 | "QScriptValue(0, QString(\"12.3\"))" , |
| 347 | "QScriptValue(engine, QScriptValue::UndefinedValue)" , |
| 348 | "QScriptValue(engine, QScriptValue::NullValue)" , |
| 349 | "QScriptValue(engine, true)" , |
| 350 | "QScriptValue(engine, false)" , |
| 351 | "QScriptValue(engine, int(122))" , |
| 352 | "QScriptValue(engine, uint(124))" , |
| 353 | "QScriptValue(engine, 0)" , |
| 354 | "QScriptValue(engine, 0.0)" , |
| 355 | "QScriptValue(engine, 123.0)" , |
| 356 | "QScriptValue(engine, 6.37e-8)" , |
| 357 | "QScriptValue(engine, -6.37e-8)" , |
| 358 | "QScriptValue(engine, 0x43211234)" , |
| 359 | "QScriptValue(engine, 0x10000)" , |
| 360 | "QScriptValue(engine, 0x10001)" , |
| 361 | "QScriptValue(engine, qSNaN())" , |
| 362 | "QScriptValue(engine, qQNaN())" , |
| 363 | "QScriptValue(engine, qInf())" , |
| 364 | "QScriptValue(engine, -qInf())" , |
| 365 | "QScriptValue(engine, \"NaN\")" , |
| 366 | "QScriptValue(engine, \"Infinity\")" , |
| 367 | "QScriptValue(engine, \"-Infinity\")" , |
| 368 | "QScriptValue(engine, \"ciao\")" , |
| 369 | "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" , |
| 370 | "QScriptValue(engine, QString(\"\"))" , |
| 371 | "QScriptValue(engine, QString())" , |
| 372 | "QScriptValue(engine, QString(\"0\"))" , |
| 373 | "QScriptValue(engine, QString(\"123\"))" , |
| 374 | "QScriptValue(engine, QString(\"1.23\"))" , |
| 375 | "engine->evaluate(\"[]\")" , |
| 376 | "engine->evaluate(\"{}\")" , |
| 377 | "engine->evaluate(\"Object.prototype\")" , |
| 378 | "engine->evaluate(\"Date.prototype\")" , |
| 379 | "engine->evaluate(\"Array.prototype\")" , |
| 380 | "engine->evaluate(\"Function.prototype\")" , |
| 381 | "engine->evaluate(\"Error.prototype\")" , |
| 382 | "engine->evaluate(\"Object\")" , |
| 383 | "engine->evaluate(\"Array\")" , |
| 384 | "engine->evaluate(\"Number\")" , |
| 385 | "engine->evaluate(\"Function\")" , |
| 386 | "engine->evaluate(\"(function() { return 1; })\")" , |
| 387 | "engine->evaluate(\"(function() { return 'ciao'; })\")" , |
| 388 | "engine->evaluate(\"(function() { throw new Error('foo'); })\")" , |
| 389 | "engine->evaluate(\"/foo/\")" , |
| 390 | "engine->evaluate(\"new Object()\")" , |
| 391 | "engine->evaluate(\"new Array()\")" , |
| 392 | "engine->evaluate(\"new Error()\")" , |
| 393 | "engine->evaluate(\"new Boolean(true)\")" , |
| 394 | "engine->evaluate(\"new Boolean(false)\")" , |
| 395 | "engine->evaluate(\"new Number(123)\")" , |
| 396 | "engine->evaluate(\"new RegExp('foo', 'gim')\")" , |
| 397 | "engine->evaluate(\"new String('ciao')\")" , |
| 398 | "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" , |
| 399 | "engine->evaluate(\"Undefined\")" , |
| 400 | "engine->evaluate(\"Null\")" , |
| 401 | "engine->evaluate(\"True\")" , |
| 402 | "engine->evaluate(\"False\")" , |
| 403 | "engine->evaluate(\"undefined\")" , |
| 404 | "engine->evaluate(\"null\")" , |
| 405 | "engine->evaluate(\"true\")" , |
| 406 | "engine->evaluate(\"false\")" , |
| 407 | "engine->evaluate(\"122\")" , |
| 408 | "engine->evaluate(\"124\")" , |
| 409 | "engine->evaluate(\"0\")" , |
| 410 | "engine->evaluate(\"0.0\")" , |
| 411 | "engine->evaluate(\"123.0\")" , |
| 412 | "engine->evaluate(\"6.37e-8\")" , |
| 413 | "engine->evaluate(\"-6.37e-8\")" , |
| 414 | "engine->evaluate(\"0x43211234\")" , |
| 415 | "engine->evaluate(\"0x10000\")" , |
| 416 | "engine->evaluate(\"0x10001\")" , |
| 417 | "engine->evaluate(\"NaN\")" , |
| 418 | "engine->evaluate(\"Infinity\")" , |
| 419 | "engine->evaluate(\"-Infinity\")" , |
| 420 | "engine->evaluate(\"'ciao'\")" , |
| 421 | "engine->evaluate(\"''\")" , |
| 422 | "engine->evaluate(\"'0'\")" , |
| 423 | "engine->evaluate(\"'123'\")" , |
| 424 | "engine->evaluate(\"'12.4'\")" , |
| 425 | "engine->nullValue()" , |
| 426 | "engine->undefinedValue()" , |
| 427 | "engine->newObject()" , |
| 428 | "engine->newArray()" , |
| 429 | "engine->newArray(10)" , |
| 430 | "engine->newDate(QDateTime())" , |
| 431 | "engine->newQMetaObject(&QObject::staticMetaObject)" , |
| 432 | "engine->newRegExp(\"foo\", \"gim\")" , |
| 433 | "engine->newVariant(QVariant())" , |
| 434 | "engine->newVariant(QVariant(123))" , |
| 435 | "engine->newVariant(QVariant(false))" , |
| 436 | "engine->newQObject(0)" , |
| 437 | "engine->newQObject(engine)" }; |
| 438 | static qsreal toNumber_valueArray[] = { |
| 439 | 0, qQNaN(), 0, 1, 0, 122, 124, 0, 0, 123, |
| 440 | 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), |
| 441 | qInf(), qInf(), qQNaN(), qQNaN(), 0, 0, 0, 123, 12.4, qQNaN(), |
| 442 | 0, 1, 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, |
| 443 | 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(), |
| 444 | qQNaN(), qQNaN(), 0, 0, 0, 123, 12.3, qQNaN(), 0, 1, |
| 445 | 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, |
| 446 | 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(), qQNaN(), qQNaN(), |
| 447 | 0, 0, 0, 123, 1.23, 0, qQNaN(), qQNaN(), qQNaN(), 0, |
| 448 | qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), |
| 449 | qQNaN(), 0, qQNaN(), 1, 0, 123, qQNaN(), qQNaN(), 22, qQNaN(), |
| 450 | qQNaN(), qQNaN(), qQNaN(), qQNaN(), 0, 1, 0, 122, 124, 0, |
| 451 | 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qInf(), qInf(), |
| 452 | qQNaN(), 0, 0, 123, 12.4, 0, qQNaN(), qQNaN(), 0, qQNaN(), |
| 453 | qQNaN(), qQNaN(), qQNaN(), qQNaN(), 123, 0, 0, qQNaN()}; |
| 454 | void tst_QScriptValueGenerated::toNumber_makeData(const char* expr) |
| 455 | { |
| 456 | static const QHash<QString, qsreal> toNumber = |
| 457 | charValueArraysToHash(keys: toNumber_tagArray, values: toNumber_valueArray, |
| 458 | size: int(sizeof(toNumber_tagArray) / sizeof(const char *))); |
| 459 | newRow(tag: expr) << toNumber.value(akey: expr); |
| 460 | } |
| 461 | |
| 462 | void tst_QScriptValueGenerated::toNumber_test(const char*, const QScriptValue& value) |
| 463 | { |
| 464 | QFETCH(qsreal, expected); |
| 465 | if (qIsNaN(d: expected)) { |
| 466 | QVERIFY(qIsNaN(value.toNumber())); |
| 467 | return; |
| 468 | } |
| 469 | if (qIsInf(d: expected)) { |
| 470 | QVERIFY(qIsInf(value.toNumber())); |
| 471 | QVERIFY(qIsInf(value.toNumber())); |
| 472 | return; |
| 473 | } |
| 474 | QCOMPARE(value.toNumber(), expected); |
| 475 | QCOMPARE(value.toNumber(), expected); |
| 476 | } |
| 477 | |
| 478 | DEFINE_TEST_FUNCTION(toNumber) |
| 479 | |
| 480 | |
| 481 | void tst_QScriptValueGenerated::toBool_initData() |
| 482 | { |
| 483 | QTest::addColumn<bool>(name: "expected" ); |
| 484 | initScriptValues(); |
| 485 | } |
| 486 | |
| 487 | static const char *toBool_tagArray[] = { |
| 488 | "QScriptValue()" , |
| 489 | "QScriptValue(QScriptValue::UndefinedValue)" , |
| 490 | "QScriptValue(QScriptValue::NullValue)" , |
| 491 | "QScriptValue(true)" , |
| 492 | "QScriptValue(false)" , |
| 493 | "QScriptValue(int(122))" , |
| 494 | "QScriptValue(uint(124))" , |
| 495 | "QScriptValue(0)" , |
| 496 | "QScriptValue(0.0)" , |
| 497 | "QScriptValue(123.0)" , |
| 498 | "QScriptValue(6.37e-8)" , |
| 499 | "QScriptValue(-6.37e-8)" , |
| 500 | "QScriptValue(0x43211234)" , |
| 501 | "QScriptValue(0x10000)" , |
| 502 | "QScriptValue(0x10001)" , |
| 503 | "QScriptValue(qSNaN())" , |
| 504 | "QScriptValue(qQNaN())" , |
| 505 | "QScriptValue(qInf())" , |
| 506 | "QScriptValue(-qInf())" , |
| 507 | "QScriptValue(\"NaN\")" , |
| 508 | "QScriptValue(\"Infinity\")" , |
| 509 | "QScriptValue(\"-Infinity\")" , |
| 510 | "QScriptValue(\"ciao\")" , |
| 511 | "QScriptValue(QString::fromLatin1(\"ciao\"))" , |
| 512 | "QScriptValue(QString(\"\"))" , |
| 513 | "QScriptValue(QString())" , |
| 514 | "QScriptValue(QString(\"0\"))" , |
| 515 | "QScriptValue(QString(\"123\"))" , |
| 516 | "QScriptValue(QString(\"12.4\"))" , |
| 517 | "QScriptValue(0, QScriptValue::UndefinedValue)" , |
| 518 | "QScriptValue(0, QScriptValue::NullValue)" , |
| 519 | "QScriptValue(0, true)" , |
| 520 | "QScriptValue(0, false)" , |
| 521 | "QScriptValue(0, int(122))" , |
| 522 | "QScriptValue(0, uint(124))" , |
| 523 | "QScriptValue(0, 0)" , |
| 524 | "QScriptValue(0, 0.0)" , |
| 525 | "QScriptValue(0, 123.0)" , |
| 526 | "QScriptValue(0, 6.37e-8)" , |
| 527 | "QScriptValue(0, -6.37e-8)" , |
| 528 | "QScriptValue(0, 0x43211234)" , |
| 529 | "QScriptValue(0, 0x10000)" , |
| 530 | "QScriptValue(0, 0x10001)" , |
| 531 | "QScriptValue(0, qSNaN())" , |
| 532 | "QScriptValue(0, qQNaN())" , |
| 533 | "QScriptValue(0, qInf())" , |
| 534 | "QScriptValue(0, -qInf())" , |
| 535 | "QScriptValue(0, \"NaN\")" , |
| 536 | "QScriptValue(0, \"Infinity\")" , |
| 537 | "QScriptValue(0, \"-Infinity\")" , |
| 538 | "QScriptValue(0, \"ciao\")" , |
| 539 | "QScriptValue(0, QString::fromLatin1(\"ciao\"))" , |
| 540 | "QScriptValue(0, QString(\"\"))" , |
| 541 | "QScriptValue(0, QString())" , |
| 542 | "QScriptValue(0, QString(\"0\"))" , |
| 543 | "QScriptValue(0, QString(\"123\"))" , |
| 544 | "QScriptValue(0, QString(\"12.3\"))" , |
| 545 | "QScriptValue(engine, QScriptValue::UndefinedValue)" , |
| 546 | "QScriptValue(engine, QScriptValue::NullValue)" , |
| 547 | "QScriptValue(engine, true)" , |
| 548 | "QScriptValue(engine, false)" , |
| 549 | "QScriptValue(engine, int(122))" , |
| 550 | "QScriptValue(engine, uint(124))" , |
| 551 | "QScriptValue(engine, 0)" , |
| 552 | "QScriptValue(engine, 0.0)" , |
| 553 | "QScriptValue(engine, 123.0)" , |
| 554 | "QScriptValue(engine, 6.37e-8)" , |
| 555 | "QScriptValue(engine, -6.37e-8)" , |
| 556 | "QScriptValue(engine, 0x43211234)" , |
| 557 | "QScriptValue(engine, 0x10000)" , |
| 558 | "QScriptValue(engine, 0x10001)" , |
| 559 | "QScriptValue(engine, qSNaN())" , |
| 560 | "QScriptValue(engine, qQNaN())" , |
| 561 | "QScriptValue(engine, qInf())" , |
| 562 | "QScriptValue(engine, -qInf())" , |
| 563 | "QScriptValue(engine, \"NaN\")" , |
| 564 | "QScriptValue(engine, \"Infinity\")" , |
| 565 | "QScriptValue(engine, \"-Infinity\")" , |
| 566 | "QScriptValue(engine, \"ciao\")" , |
| 567 | "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" , |
| 568 | "QScriptValue(engine, QString(\"\"))" , |
| 569 | "QScriptValue(engine, QString())" , |
| 570 | "QScriptValue(engine, QString(\"0\"))" , |
| 571 | "QScriptValue(engine, QString(\"123\"))" , |
| 572 | "QScriptValue(engine, QString(\"1.23\"))" , |
| 573 | "engine->evaluate(\"[]\")" , |
| 574 | "engine->evaluate(\"{}\")" , |
| 575 | "engine->evaluate(\"Object.prototype\")" , |
| 576 | "engine->evaluate(\"Date.prototype\")" , |
| 577 | "engine->evaluate(\"Array.prototype\")" , |
| 578 | "engine->evaluate(\"Function.prototype\")" , |
| 579 | "engine->evaluate(\"Error.prototype\")" , |
| 580 | "engine->evaluate(\"Object\")" , |
| 581 | "engine->evaluate(\"Array\")" , |
| 582 | "engine->evaluate(\"Number\")" , |
| 583 | "engine->evaluate(\"Function\")" , |
| 584 | "engine->evaluate(\"(function() { return 1; })\")" , |
| 585 | "engine->evaluate(\"(function() { return 'ciao'; })\")" , |
| 586 | "engine->evaluate(\"(function() { throw new Error('foo'); })\")" , |
| 587 | "engine->evaluate(\"/foo/\")" , |
| 588 | "engine->evaluate(\"new Object()\")" , |
| 589 | "engine->evaluate(\"new Array()\")" , |
| 590 | "engine->evaluate(\"new Error()\")" , |
| 591 | "engine->evaluate(\"new Boolean(true)\")" , |
| 592 | "engine->evaluate(\"new Boolean(false)\")" , |
| 593 | "engine->evaluate(\"new Number(123)\")" , |
| 594 | "engine->evaluate(\"new RegExp('foo', 'gim')\")" , |
| 595 | "engine->evaluate(\"new String('ciao')\")" , |
| 596 | "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" , |
| 597 | "engine->evaluate(\"Undefined\")" , |
| 598 | "engine->evaluate(\"Null\")" , |
| 599 | "engine->evaluate(\"True\")" , |
| 600 | "engine->evaluate(\"False\")" , |
| 601 | "engine->evaluate(\"undefined\")" , |
| 602 | "engine->evaluate(\"null\")" , |
| 603 | "engine->evaluate(\"true\")" , |
| 604 | "engine->evaluate(\"false\")" , |
| 605 | "engine->evaluate(\"122\")" , |
| 606 | "engine->evaluate(\"124\")" , |
| 607 | "engine->evaluate(\"0\")" , |
| 608 | "engine->evaluate(\"0.0\")" , |
| 609 | "engine->evaluate(\"123.0\")" , |
| 610 | "engine->evaluate(\"6.37e-8\")" , |
| 611 | "engine->evaluate(\"-6.37e-8\")" , |
| 612 | "engine->evaluate(\"0x43211234\")" , |
| 613 | "engine->evaluate(\"0x10000\")" , |
| 614 | "engine->evaluate(\"0x10001\")" , |
| 615 | "engine->evaluate(\"NaN\")" , |
| 616 | "engine->evaluate(\"Infinity\")" , |
| 617 | "engine->evaluate(\"-Infinity\")" , |
| 618 | "engine->evaluate(\"'ciao'\")" , |
| 619 | "engine->evaluate(\"''\")" , |
| 620 | "engine->evaluate(\"'0'\")" , |
| 621 | "engine->evaluate(\"'123'\")" , |
| 622 | "engine->evaluate(\"'12.4'\")" , |
| 623 | "engine->nullValue()" , |
| 624 | "engine->undefinedValue()" , |
| 625 | "engine->newObject()" , |
| 626 | "engine->newArray()" , |
| 627 | "engine->newArray(10)" , |
| 628 | "engine->newDate(QDateTime())" , |
| 629 | "engine->newQMetaObject(&QObject::staticMetaObject)" , |
| 630 | "engine->newRegExp(\"foo\", \"gim\")" , |
| 631 | "engine->newVariant(QVariant())" , |
| 632 | "engine->newVariant(QVariant(123))" , |
| 633 | "engine->newVariant(QVariant(false))" , |
| 634 | "engine->newQObject(0)" , |
| 635 | "engine->newQObject(engine)" }; |
| 636 | |
| 637 | static bool toBool_valueArray[] = { |
| 638 | false, false, |
| 639 | false, true, |
| 640 | false, true, |
| 641 | true, false, |
| 642 | false, true, |
| 643 | true, true, |
| 644 | true, true, |
| 645 | true, false, |
| 646 | false, true, |
| 647 | true, true, |
| 648 | true, true, |
| 649 | true, true, |
| 650 | false, false, |
| 651 | true, true, |
| 652 | true, false, |
| 653 | false, true, |
| 654 | false, true, |
| 655 | true, false, |
| 656 | false, true, |
| 657 | true, true, |
| 658 | true, true, |
| 659 | true, false, |
| 660 | false, true, |
| 661 | true, true, |
| 662 | true, true, |
| 663 | true, true, |
| 664 | false, false, |
| 665 | true, true, |
| 666 | true, false, |
| 667 | false, true, |
| 668 | false, true, |
| 669 | true, false, |
| 670 | false, true, |
| 671 | true, true, |
| 672 | true, true, |
| 673 | true, false, |
| 674 | false, true, |
| 675 | true, true, |
| 676 | true, true, |
| 677 | true, true, |
| 678 | false, false, |
| 679 | true, true, |
| 680 | true, true, |
| 681 | false, 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, true, |
| 693 | true, true, |
| 694 | true, false, |
| 695 | false, true, |
| 696 | false, true, |
| 697 | true, false, |
| 698 | false, true, |
| 699 | true, true, |
| 700 | true, true, |
| 701 | true, false, |
| 702 | true, true, |
| 703 | true, false, |
| 704 | true, true, |
| 705 | true, false, |
| 706 | false, true, |
| 707 | true, true, |
| 708 | true, true, |
| 709 | true, true, |
| 710 | true, true, |
| 711 | false, true}; |
| 712 | |
| 713 | void tst_QScriptValueGenerated::toBool_makeData(const char* expr) |
| 714 | { |
| 715 | static const QHash<QString, bool> toBool = |
| 716 | charValueArraysToHash(keys: toBool_tagArray, values: toBool_valueArray, |
| 717 | size: int(sizeof(toBool_tagArray) / sizeof(const char *))); |
| 718 | newRow(tag: expr) << toBool.value(akey: expr); |
| 719 | } |
| 720 | |
| 721 | void tst_QScriptValueGenerated::toBool_test(const char*, const QScriptValue& value) |
| 722 | { |
| 723 | QFETCH(bool, expected); |
| 724 | QCOMPARE(value.toBool(), expected); |
| 725 | QCOMPARE(value.toBool(), expected); |
| 726 | } |
| 727 | |
| 728 | DEFINE_TEST_FUNCTION(toBool) |
| 729 | |
| 730 | |
| 731 | void tst_QScriptValueGenerated::toBoolean_initData() |
| 732 | { |
| 733 | QTest::addColumn<bool>(name: "expected" ); |
| 734 | initScriptValues(); |
| 735 | } |
| 736 | |
| 737 | static const char *toBoolean_tagArray[] = { |
| 738 | "QScriptValue()" , |
| 739 | "QScriptValue(QScriptValue::UndefinedValue)" , |
| 740 | "QScriptValue(QScriptValue::NullValue)" , |
| 741 | "QScriptValue(true)" , |
| 742 | "QScriptValue(false)" , |
| 743 | "QScriptValue(int(122))" , |
| 744 | "QScriptValue(uint(124))" , |
| 745 | "QScriptValue(0)" , |
| 746 | "QScriptValue(0.0)" , |
| 747 | "QScriptValue(123.0)" , |
| 748 | "QScriptValue(6.37e-8)" , |
| 749 | "QScriptValue(-6.37e-8)" , |
| 750 | "QScriptValue(0x43211234)" , |
| 751 | "QScriptValue(0x10000)" , |
| 752 | "QScriptValue(0x10001)" , |
| 753 | "QScriptValue(qSNaN())" , |
| 754 | "QScriptValue(qQNaN())" , |
| 755 | "QScriptValue(qInf())" , |
| 756 | "QScriptValue(-qInf())" , |
| 757 | "QScriptValue(\"NaN\")" , |
| 758 | "QScriptValue(\"Infinity\")" , |
| 759 | "QScriptValue(\"-Infinity\")" , |
| 760 | "QScriptValue(\"ciao\")" , |
| 761 | "QScriptValue(QString::fromLatin1(\"ciao\"))" , |
| 762 | "QScriptValue(QString(\"\"))" , |
| 763 | "QScriptValue(QString())" , |
| 764 | "QScriptValue(QString(\"0\"))" , |
| 765 | "QScriptValue(QString(\"123\"))" , |
| 766 | "QScriptValue(QString(\"12.4\"))" , |
| 767 | "QScriptValue(0, QScriptValue::UndefinedValue)" , |
| 768 | "QScriptValue(0, QScriptValue::NullValue)" , |
| 769 | "QScriptValue(0, true)" , |
| 770 | "QScriptValue(0, false)" , |
| 771 | "QScriptValue(0, int(122))" , |
| 772 | "QScriptValue(0, uint(124))" , |
| 773 | "QScriptValue(0, 0)" , |
| 774 | "QScriptValue(0, 0.0)" , |
| 775 | "QScriptValue(0, 123.0)" , |
| 776 | "QScriptValue(0, 6.37e-8)" , |
| 777 | "QScriptValue(0, -6.37e-8)" , |
| 778 | "QScriptValue(0, 0x43211234)" , |
| 779 | "QScriptValue(0, 0x10000)" , |
| 780 | "QScriptValue(0, 0x10001)" , |
| 781 | "QScriptValue(0, qSNaN())" , |
| 782 | "QScriptValue(0, qQNaN())" , |
| 783 | "QScriptValue(0, qInf())" , |
| 784 | "QScriptValue(0, -qInf())" , |
| 785 | "QScriptValue(0, \"NaN\")" , |
| 786 | "QScriptValue(0, \"Infinity\")" , |
| 787 | "QScriptValue(0, \"-Infinity\")" , |
| 788 | "QScriptValue(0, \"ciao\")" , |
| 789 | "QScriptValue(0, QString::fromLatin1(\"ciao\"))" , |
| 790 | "QScriptValue(0, QString(\"\"))" , |
| 791 | "QScriptValue(0, QString())" , |
| 792 | "QScriptValue(0, QString(\"0\"))" , |
| 793 | "QScriptValue(0, QString(\"123\"))" , |
| 794 | "QScriptValue(0, QString(\"12.3\"))" , |
| 795 | "QScriptValue(engine, QScriptValue::UndefinedValue)" , |
| 796 | "QScriptValue(engine, QScriptValue::NullValue)" , |
| 797 | "QScriptValue(engine, true)" , |
| 798 | "QScriptValue(engine, false)" , |
| 799 | "QScriptValue(engine, int(122))" , |
| 800 | "QScriptValue(engine, uint(124))" , |
| 801 | "QScriptValue(engine, 0)" , |
| 802 | "QScriptValue(engine, 0.0)" , |
| 803 | "QScriptValue(engine, 123.0)" , |
| 804 | "QScriptValue(engine, 6.37e-8)" , |
| 805 | "QScriptValue(engine, -6.37e-8)" , |
| 806 | "QScriptValue(engine, 0x43211234)" , |
| 807 | "QScriptValue(engine, 0x10000)" , |
| 808 | "QScriptValue(engine, 0x10001)" , |
| 809 | "QScriptValue(engine, qSNaN())" , |
| 810 | "QScriptValue(engine, qQNaN())" , |
| 811 | "QScriptValue(engine, qInf())" , |
| 812 | "QScriptValue(engine, -qInf())" , |
| 813 | "QScriptValue(engine, \"NaN\")" , |
| 814 | "QScriptValue(engine, \"Infinity\")" , |
| 815 | "QScriptValue(engine, \"-Infinity\")" , |
| 816 | "QScriptValue(engine, \"ciao\")" , |
| 817 | "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" , |
| 818 | "QScriptValue(engine, QString(\"\"))" , |
| 819 | "QScriptValue(engine, QString())" , |
| 820 | "QScriptValue(engine, QString(\"0\"))" , |
| 821 | "QScriptValue(engine, QString(\"123\"))" , |
| 822 | "QScriptValue(engine, QString(\"1.23\"))" , |
| 823 | "engine->evaluate(\"[]\")" , |
| 824 | "engine->evaluate(\"{}\")" , |
| 825 | "engine->evaluate(\"Object.prototype\")" , |
| 826 | "engine->evaluate(\"Date.prototype\")" , |
| 827 | "engine->evaluate(\"Array.prototype\")" , |
| 828 | "engine->evaluate(\"Function.prototype\")" , |
| 829 | "engine->evaluate(\"Error.prototype\")" , |
| 830 | "engine->evaluate(\"Object\")" , |
| 831 | "engine->evaluate(\"Array\")" , |
| 832 | "engine->evaluate(\"Number\")" , |
| 833 | "engine->evaluate(\"Function\")" , |
| 834 | "engine->evaluate(\"(function() { return 1; })\")" , |
| 835 | "engine->evaluate(\"(function() { return 'ciao'; })\")" , |
| 836 | "engine->evaluate(\"(function() { throw new Error('foo'); })\")" , |
| 837 | "engine->evaluate(\"/foo/\")" , |
| 838 | "engine->evaluate(\"new Object()\")" , |
| 839 | "engine->evaluate(\"new Array()\")" , |
| 840 | "engine->evaluate(\"new Error()\")" , |
| 841 | "engine->evaluate(\"new Boolean(true)\")" , |
| 842 | "engine->evaluate(\"new Boolean(false)\")" , |
| 843 | "engine->evaluate(\"new Number(123)\")" , |
| 844 | "engine->evaluate(\"new RegExp('foo', 'gim')\")" , |
| 845 | "engine->evaluate(\"new String('ciao')\")" , |
| 846 | "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" , |
| 847 | "engine->evaluate(\"Undefined\")" , |
| 848 | "engine->evaluate(\"Null\")" , |
| 849 | "engine->evaluate(\"True\")" , |
| 850 | "engine->evaluate(\"False\")" , |
| 851 | "engine->evaluate(\"undefined\")" , |
| 852 | "engine->evaluate(\"null\")" , |
| 853 | "engine->evaluate(\"true\")" , |
| 854 | "engine->evaluate(\"false\")" , |
| 855 | "engine->evaluate(\"122\")" , |
| 856 | "engine->evaluate(\"124\")" , |
| 857 | "engine->evaluate(\"0\")" , |
| 858 | "engine->evaluate(\"0.0\")" , |
| 859 | "engine->evaluate(\"123.0\")" , |
| 860 | "engine->evaluate(\"6.37e-8\")" , |
| 861 | "engine->evaluate(\"-6.37e-8\")" , |
| 862 | "engine->evaluate(\"0x43211234\")" , |
| 863 | "engine->evaluate(\"0x10000\")" , |
| 864 | "engine->evaluate(\"0x10001\")" , |
| 865 | "engine->evaluate(\"NaN\")" , |
| 866 | "engine->evaluate(\"Infinity\")" , |
| 867 | "engine->evaluate(\"-Infinity\")" , |
| 868 | "engine->evaluate(\"'ciao'\")" , |
| 869 | "engine->evaluate(\"''\")" , |
| 870 | "engine->evaluate(\"'0'\")" , |
| 871 | "engine->evaluate(\"'123'\")" , |
| 872 | "engine->evaluate(\"'12.4'\")" , |
| 873 | "engine->nullValue()" , |
| 874 | "engine->undefinedValue()" , |
| 875 | "engine->newObject()" , |
| 876 | "engine->newArray()" , |
| 877 | "engine->newArray(10)" , |
| 878 | "engine->newDate(QDateTime())" , |
| 879 | "engine->newQMetaObject(&QObject::staticMetaObject)" , |
| 880 | "engine->newRegExp(\"foo\", \"gim\")" , |
| 881 | "engine->newVariant(QVariant())" , |
| 882 | "engine->newVariant(QVariant(123))" , |
| 883 | "engine->newVariant(QVariant(false))" , |
| 884 | "engine->newQObject(0)" , |
| 885 | "engine->newQObject(engine)" }; |
| 886 | |
| 887 | static bool toBoolean_valueArray[] = { |
| 888 | false, false, |
| 889 | false, true, |
| 890 | false, true, |
| 891 | true, false, |
| 892 | false, true, |
| 893 | true, true, |
| 894 | true, true, |
| 895 | true, false, |
| 896 | false, true, |
| 897 | true, true, |
| 898 | true, true, |
| 899 | true, true, |
| 900 | false, false, |
| 901 | true, true, |
| 902 | true, false, |
| 903 | false, true, |
| 904 | false, true, |
| 905 | true, false, |
| 906 | false, true, |
| 907 | true, true, |
| 908 | true, true, |
| 909 | true, false, |
| 910 | false, true, |
| 911 | true, true, |
| 912 | true, true, |
| 913 | true, true, |
| 914 | false, false, |
| 915 | true, true, |
| 916 | true, false, |
| 917 | false, true, |
| 918 | false, true, |
| 919 | true, false, |
| 920 | false, true, |
| 921 | true, true, |
| 922 | true, true, |
| 923 | true, false, |
| 924 | false, true, |
| 925 | true, true, |
| 926 | true, true, |
| 927 | true, true, |
| 928 | false, false, |
| 929 | true, true, |
| 930 | true, true, |
| 931 | false, true, |
| 932 | true, true, |
| 933 | true, true, |
| 934 | true, true, |
| 935 | true, true, |
| 936 | true, true, |
| 937 | true, true, |
| 938 | true, true, |
| 939 | true, true, |
| 940 | true, true, |
| 941 | true, true, |
| 942 | true, true, |
| 943 | true, true, |
| 944 | true, false, |
| 945 | false, true, |
| 946 | false, true, |
| 947 | true, false, |
| 948 | false, true, |
| 949 | true, true, |
| 950 | true, true, |
| 951 | true, false, |
| 952 | true, true, |
| 953 | true, false, |
| 954 | true, true, |
| 955 | true, false, |
| 956 | false, true, |
| 957 | true, true, |
| 958 | true, true, |
| 959 | true, true, |
| 960 | true, true, |
| 961 | false, true}; |
| 962 | |
| 963 | void tst_QScriptValueGenerated::toBoolean_makeData(const char* expr) |
| 964 | { |
| 965 | static const QHash<QString, bool> toBoolean = |
| 966 | charValueArraysToHash(keys: toBoolean_tagArray, values: toBoolean_valueArray, |
| 967 | size: int(sizeof(toBoolean_tagArray) / sizeof(const char *))); |
| 968 | newRow(tag: expr) << toBoolean.value(akey: expr); |
| 969 | } |
| 970 | |
| 971 | void tst_QScriptValueGenerated::toBoolean_test(const char*, const QScriptValue& value) |
| 972 | { |
| 973 | QFETCH(bool, expected); |
| 974 | QCOMPARE(value.toBoolean(), expected); |
| 975 | QCOMPARE(value.toBoolean(), expected); |
| 976 | } |
| 977 | |
| 978 | DEFINE_TEST_FUNCTION(toBoolean) |
| 979 | |
| 980 | |
| 981 | void tst_QScriptValueGenerated::toInteger_initData() |
| 982 | { |
| 983 | QTest::addColumn<qsreal>(name: "expected" ); |
| 984 | initScriptValues(); |
| 985 | } |
| 986 | |
| 987 | static const char *toInteger_tagArray[] = { |
| 988 | "QScriptValue()" , |
| 989 | "QScriptValue(QScriptValue::UndefinedValue)" , |
| 990 | "QScriptValue(QScriptValue::NullValue)" , |
| 991 | "QScriptValue(true)" , |
| 992 | "QScriptValue(false)" , |
| 993 | "QScriptValue(int(122))" , |
| 994 | "QScriptValue(uint(124))" , |
| 995 | "QScriptValue(0)" , |
| 996 | "QScriptValue(0.0)" , |
| 997 | "QScriptValue(123.0)" , |
| 998 | "QScriptValue(6.37e-8)" , |
| 999 | "QScriptValue(-6.37e-8)" , |
| 1000 | "QScriptValue(0x43211234)" , |
| 1001 | "QScriptValue(0x10000)" , |
| 1002 | "QScriptValue(0x10001)" , |
| 1003 | "QScriptValue(qSNaN())" , |
| 1004 | "QScriptValue(qQNaN())" , |
| 1005 | "QScriptValue(qInf())" , |
| 1006 | "QScriptValue(-qInf())" , |
| 1007 | "QScriptValue(\"NaN\")" , |
| 1008 | "QScriptValue(\"Infinity\")" , |
| 1009 | "QScriptValue(\"-Infinity\")" , |
| 1010 | "QScriptValue(\"ciao\")" , |
| 1011 | "QScriptValue(QString::fromLatin1(\"ciao\"))" , |
| 1012 | "QScriptValue(QString(\"\"))" , |
| 1013 | "QScriptValue(QString())" , |
| 1014 | "QScriptValue(QString(\"0\"))" , |
| 1015 | "QScriptValue(QString(\"123\"))" , |
| 1016 | "QScriptValue(QString(\"12.4\"))" , |
| 1017 | "QScriptValue(0, QScriptValue::UndefinedValue)" , |
| 1018 | "QScriptValue(0, QScriptValue::NullValue)" , |
| 1019 | "QScriptValue(0, true)" , |
| 1020 | "QScriptValue(0, false)" , |
| 1021 | "QScriptValue(0, int(122))" , |
| 1022 | "QScriptValue(0, uint(124))" , |
| 1023 | "QScriptValue(0, 0)" , |
| 1024 | "QScriptValue(0, 0.0)" , |
| 1025 | "QScriptValue(0, 123.0)" , |
| 1026 | "QScriptValue(0, 6.37e-8)" , |
| 1027 | "QScriptValue(0, -6.37e-8)" , |
| 1028 | "QScriptValue(0, 0x43211234)" , |
| 1029 | "QScriptValue(0, 0x10000)" , |
| 1030 | "QScriptValue(0, 0x10001)" , |
| 1031 | "QScriptValue(0, qSNaN())" , |
| 1032 | "QScriptValue(0, qQNaN())" , |
| 1033 | "QScriptValue(0, qInf())" , |
| 1034 | "QScriptValue(0, -qInf())" , |
| 1035 | "QScriptValue(0, \"NaN\")" , |
| 1036 | "QScriptValue(0, \"Infinity\")" , |
| 1037 | "QScriptValue(0, \"-Infinity\")" , |
| 1038 | "QScriptValue(0, \"ciao\")" , |
| 1039 | "QScriptValue(0, QString::fromLatin1(\"ciao\"))" , |
| 1040 | "QScriptValue(0, QString(\"\"))" , |
| 1041 | "QScriptValue(0, QString())" , |
| 1042 | "QScriptValue(0, QString(\"0\"))" , |
| 1043 | "QScriptValue(0, QString(\"123\"))" , |
| 1044 | "QScriptValue(0, QString(\"12.3\"))" , |
| 1045 | "QScriptValue(engine, QScriptValue::UndefinedValue)" , |
| 1046 | "QScriptValue(engine, QScriptValue::NullValue)" , |
| 1047 | "QScriptValue(engine, true)" , |
| 1048 | "QScriptValue(engine, false)" , |
| 1049 | "QScriptValue(engine, int(122))" , |
| 1050 | "QScriptValue(engine, uint(124))" , |
| 1051 | "QScriptValue(engine, 0)" , |
| 1052 | "QScriptValue(engine, 0.0)" , |
| 1053 | "QScriptValue(engine, 123.0)" , |
| 1054 | "QScriptValue(engine, 6.37e-8)" , |
| 1055 | "QScriptValue(engine, -6.37e-8)" , |
| 1056 | "QScriptValue(engine, 0x43211234)" , |
| 1057 | "QScriptValue(engine, 0x10000)" , |
| 1058 | "QScriptValue(engine, 0x10001)" , |
| 1059 | "QScriptValue(engine, qSNaN())" , |
| 1060 | "QScriptValue(engine, qQNaN())" , |
| 1061 | "QScriptValue(engine, qInf())" , |
| 1062 | "QScriptValue(engine, -qInf())" , |
| 1063 | "QScriptValue(engine, \"NaN\")" , |
| 1064 | "QScriptValue(engine, \"Infinity\")" , |
| 1065 | "QScriptValue(engine, \"-Infinity\")" , |
| 1066 | "QScriptValue(engine, \"ciao\")" , |
| 1067 | "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" , |
| 1068 | "QScriptValue(engine, QString(\"\"))" , |
| 1069 | "QScriptValue(engine, QString())" , |
| 1070 | "QScriptValue(engine, QString(\"0\"))" , |
| 1071 | "QScriptValue(engine, QString(\"123\"))" , |
| 1072 | "QScriptValue(engine, QString(\"1.23\"))" , |
| 1073 | "engine->evaluate(\"[]\")" , |
| 1074 | "engine->evaluate(\"{}\")" , |
| 1075 | "engine->evaluate(\"Object.prototype\")" , |
| 1076 | "engine->evaluate(\"Date.prototype\")" , |
| 1077 | "engine->evaluate(\"Array.prototype\")" , |
| 1078 | "engine->evaluate(\"Function.prototype\")" , |
| 1079 | "engine->evaluate(\"Error.prototype\")" , |
| 1080 | "engine->evaluate(\"Object\")" , |
| 1081 | "engine->evaluate(\"Array\")" , |
| 1082 | "engine->evaluate(\"Number\")" , |
| 1083 | "engine->evaluate(\"Function\")" , |
| 1084 | "engine->evaluate(\"(function() { return 1; })\")" , |
| 1085 | "engine->evaluate(\"(function() { return 'ciao'; })\")" , |
| 1086 | "engine->evaluate(\"(function() { throw new Error('foo'); })\")" , |
| 1087 | "engine->evaluate(\"/foo/\")" , |
| 1088 | "engine->evaluate(\"new Object()\")" , |
| 1089 | "engine->evaluate(\"new Array()\")" , |
| 1090 | "engine->evaluate(\"new Error()\")" , |
| 1091 | "engine->evaluate(\"new Boolean(true)\")" , |
| 1092 | "engine->evaluate(\"new Boolean(false)\")" , |
| 1093 | "engine->evaluate(\"new Number(123)\")" , |
| 1094 | "engine->evaluate(\"new RegExp('foo', 'gim')\")" , |
| 1095 | "engine->evaluate(\"new String('ciao')\")" , |
| 1096 | "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" , |
| 1097 | "engine->evaluate(\"Undefined\")" , |
| 1098 | "engine->evaluate(\"Null\")" , |
| 1099 | "engine->evaluate(\"True\")" , |
| 1100 | "engine->evaluate(\"False\")" , |
| 1101 | "engine->evaluate(\"undefined\")" , |
| 1102 | "engine->evaluate(\"null\")" , |
| 1103 | "engine->evaluate(\"true\")" , |
| 1104 | "engine->evaluate(\"false\")" , |
| 1105 | "engine->evaluate(\"122\")" , |
| 1106 | "engine->evaluate(\"124\")" , |
| 1107 | "engine->evaluate(\"0\")" , |
| 1108 | "engine->evaluate(\"0.0\")" , |
| 1109 | "engine->evaluate(\"123.0\")" , |
| 1110 | "engine->evaluate(\"6.37e-8\")" , |
| 1111 | "engine->evaluate(\"-6.37e-8\")" , |
| 1112 | "engine->evaluate(\"0x43211234\")" , |
| 1113 | "engine->evaluate(\"0x10000\")" , |
| 1114 | "engine->evaluate(\"0x10001\")" , |
| 1115 | "engine->evaluate(\"NaN\")" , |
| 1116 | "engine->evaluate(\"Infinity\")" , |
| 1117 | "engine->evaluate(\"-Infinity\")" , |
| 1118 | "engine->evaluate(\"'ciao'\")" , |
| 1119 | "engine->evaluate(\"''\")" , |
| 1120 | "engine->evaluate(\"'0'\")" , |
| 1121 | "engine->evaluate(\"'123'\")" , |
| 1122 | "engine->evaluate(\"'12.4'\")" , |
| 1123 | "engine->nullValue()" , |
| 1124 | "engine->undefinedValue()" , |
| 1125 | "engine->newObject()" , |
| 1126 | "engine->newArray()" , |
| 1127 | "engine->newArray(10)" , |
| 1128 | "engine->newDate(QDateTime())" , |
| 1129 | "engine->newQMetaObject(&QObject::staticMetaObject)" , |
| 1130 | "engine->newRegExp(\"foo\", \"gim\")" , |
| 1131 | "engine->newVariant(QVariant())" , |
| 1132 | "engine->newVariant(QVariant(123))" , |
| 1133 | "engine->newVariant(QVariant(false))" , |
| 1134 | "engine->newQObject(0)" , |
| 1135 | "engine->newQObject(engine)" }; |
| 1136 | static qsreal toInteger_valueArray[] = { |
| 1137 | 0, 0, 0, 1, 0, 122, 124, 0, 0, 123, |
| 1138 | 0, 0, 1126240820, 65536, 65537, 0, 0, qInf(), qInf(), 0, |
| 1139 | qInf(), qInf(), 0, 0, 0, 0, 0, 123, 12, 0, |
| 1140 | 0, 1, 0, 122, 124, 0, 0, 123, 0, 0, |
| 1141 | 1126240820, 65536, 65537, 0, 0, qInf(), qInf(), 0, qInf(), qInf(), |
| 1142 | 0, 0, 0, 0, 0, 123, 12, 0, 0, 1, |
| 1143 | 0, 122, 124, 0, 0, 123, 0, 0, 1126240820, 65536, |
| 1144 | 65537, 0, 0, qInf(), qInf(), 0, qInf(), qInf(), 0, 0, |
| 1145 | 0, 0, 0, 123, 1, 0, 0, 0, 0, 0, |
| 1146 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1147 | 0, 0, 0, 1, 0, 123, 0, 0, 22, 0, |
| 1148 | 0, 0, 0, 0, 0, 1, 0, 122, 124, 0, |
| 1149 | 0, 123, 0, 0, 1126240820, 65536, 65537, 0, qInf(), qInf(), |
| 1150 | 0, 0, 0, 123, 12, 0, 0, 0, 0, 0, |
| 1151 | 0, 0, 0, 0, 123, 0, 0, 0}; |
| 1152 | void tst_QScriptValueGenerated::toInteger_makeData(const char* expr) |
| 1153 | { |
| 1154 | static const QHash<QString, qsreal> toInteger = |
| 1155 | charValueArraysToHash(keys: toInteger_tagArray, values: toInteger_valueArray, |
| 1156 | size: int(sizeof(toInteger_tagArray) / sizeof(const char *))); |
| 1157 | newRow(tag: expr) << toInteger.value(akey: expr); |
| 1158 | } |
| 1159 | |
| 1160 | void tst_QScriptValueGenerated::toInteger_test(const char*, const QScriptValue& value) |
| 1161 | { |
| 1162 | QFETCH(qsreal, expected); |
| 1163 | if (qIsInf(d: expected)) { |
| 1164 | QVERIFY(qIsInf(value.toInteger())); |
| 1165 | QVERIFY(qIsInf(value.toInteger())); |
| 1166 | return; |
| 1167 | } |
| 1168 | QCOMPARE(value.toInteger(), expected); |
| 1169 | QCOMPARE(value.toInteger(), expected); |
| 1170 | } |
| 1171 | |
| 1172 | DEFINE_TEST_FUNCTION(toInteger) |
| 1173 | |
| 1174 | |
| 1175 | void tst_QScriptValueGenerated::toInt32_initData() |
| 1176 | { |
| 1177 | QTest::addColumn<qint32>(name: "expected" ); |
| 1178 | initScriptValues(); |
| 1179 | } |
| 1180 | |
| 1181 | static const char *toInt32_tagArray[] = { |
| 1182 | "QScriptValue()" , |
| 1183 | "QScriptValue(QScriptValue::UndefinedValue)" , |
| 1184 | "QScriptValue(QScriptValue::NullValue)" , |
| 1185 | "QScriptValue(true)" , |
| 1186 | "QScriptValue(false)" , |
| 1187 | "QScriptValue(int(122))" , |
| 1188 | "QScriptValue(uint(124))" , |
| 1189 | "QScriptValue(0)" , |
| 1190 | "QScriptValue(0.0)" , |
| 1191 | "QScriptValue(123.0)" , |
| 1192 | "QScriptValue(6.37e-8)" , |
| 1193 | "QScriptValue(-6.37e-8)" , |
| 1194 | "QScriptValue(0x43211234)" , |
| 1195 | "QScriptValue(0x10000)" , |
| 1196 | "QScriptValue(0x10001)" , |
| 1197 | "QScriptValue(qSNaN())" , |
| 1198 | "QScriptValue(qQNaN())" , |
| 1199 | "QScriptValue(qInf())" , |
| 1200 | "QScriptValue(-qInf())" , |
| 1201 | "QScriptValue(\"NaN\")" , |
| 1202 | "QScriptValue(\"Infinity\")" , |
| 1203 | "QScriptValue(\"-Infinity\")" , |
| 1204 | "QScriptValue(\"ciao\")" , |
| 1205 | "QScriptValue(QString::fromLatin1(\"ciao\"))" , |
| 1206 | "QScriptValue(QString(\"\"))" , |
| 1207 | "QScriptValue(QString())" , |
| 1208 | "QScriptValue(QString(\"0\"))" , |
| 1209 | "QScriptValue(QString(\"123\"))" , |
| 1210 | "QScriptValue(QString(\"12.4\"))" , |
| 1211 | "QScriptValue(0, QScriptValue::UndefinedValue)" , |
| 1212 | "QScriptValue(0, QScriptValue::NullValue)" , |
| 1213 | "QScriptValue(0, true)" , |
| 1214 | "QScriptValue(0, false)" , |
| 1215 | "QScriptValue(0, int(122))" , |
| 1216 | "QScriptValue(0, uint(124))" , |
| 1217 | "QScriptValue(0, 0)" , |
| 1218 | "QScriptValue(0, 0.0)" , |
| 1219 | "QScriptValue(0, 123.0)" , |
| 1220 | "QScriptValue(0, 6.37e-8)" , |
| 1221 | "QScriptValue(0, -6.37e-8)" , |
| 1222 | "QScriptValue(0, 0x43211234)" , |
| 1223 | "QScriptValue(0, 0x10000)" , |
| 1224 | "QScriptValue(0, 0x10001)" , |
| 1225 | "QScriptValue(0, qSNaN())" , |
| 1226 | "QScriptValue(0, qQNaN())" , |
| 1227 | "QScriptValue(0, qInf())" , |
| 1228 | "QScriptValue(0, -qInf())" , |
| 1229 | "QScriptValue(0, \"NaN\")" , |
| 1230 | "QScriptValue(0, \"Infinity\")" , |
| 1231 | "QScriptValue(0, \"-Infinity\")" , |
| 1232 | "QScriptValue(0, \"ciao\")" , |
| 1233 | "QScriptValue(0, QString::fromLatin1(\"ciao\"))" , |
| 1234 | "QScriptValue(0, QString(\"\"))" , |
| 1235 | "QScriptValue(0, QString())" , |
| 1236 | "QScriptValue(0, QString(\"0\"))" , |
| 1237 | "QScriptValue(0, QString(\"123\"))" , |
| 1238 | "QScriptValue(0, QString(\"12.3\"))" , |
| 1239 | "QScriptValue(engine, QScriptValue::UndefinedValue)" , |
| 1240 | "QScriptValue(engine, QScriptValue::NullValue)" , |
| 1241 | "QScriptValue(engine, true)" , |
| 1242 | "QScriptValue(engine, false)" , |
| 1243 | "QScriptValue(engine, int(122))" , |
| 1244 | "QScriptValue(engine, uint(124))" , |
| 1245 | "QScriptValue(engine, 0)" , |
| 1246 | "QScriptValue(engine, 0.0)" , |
| 1247 | "QScriptValue(engine, 123.0)" , |
| 1248 | "QScriptValue(engine, 6.37e-8)" , |
| 1249 | "QScriptValue(engine, -6.37e-8)" , |
| 1250 | "QScriptValue(engine, 0x43211234)" , |
| 1251 | "QScriptValue(engine, 0x10000)" , |
| 1252 | "QScriptValue(engine, 0x10001)" , |
| 1253 | "QScriptValue(engine, qSNaN())" , |
| 1254 | "QScriptValue(engine, qQNaN())" , |
| 1255 | "QScriptValue(engine, qInf())" , |
| 1256 | "QScriptValue(engine, -qInf())" , |
| 1257 | "QScriptValue(engine, \"NaN\")" , |
| 1258 | "QScriptValue(engine, \"Infinity\")" , |
| 1259 | "QScriptValue(engine, \"-Infinity\")" , |
| 1260 | "QScriptValue(engine, \"ciao\")" , |
| 1261 | "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" , |
| 1262 | "QScriptValue(engine, QString(\"\"))" , |
| 1263 | "QScriptValue(engine, QString())" , |
| 1264 | "QScriptValue(engine, QString(\"0\"))" , |
| 1265 | "QScriptValue(engine, QString(\"123\"))" , |
| 1266 | "QScriptValue(engine, QString(\"1.23\"))" , |
| 1267 | "engine->evaluate(\"[]\")" , |
| 1268 | "engine->evaluate(\"{}\")" , |
| 1269 | "engine->evaluate(\"Object.prototype\")" , |
| 1270 | "engine->evaluate(\"Date.prototype\")" , |
| 1271 | "engine->evaluate(\"Array.prototype\")" , |
| 1272 | "engine->evaluate(\"Function.prototype\")" , |
| 1273 | "engine->evaluate(\"Error.prototype\")" , |
| 1274 | "engine->evaluate(\"Object\")" , |
| 1275 | "engine->evaluate(\"Array\")" , |
| 1276 | "engine->evaluate(\"Number\")" , |
| 1277 | "engine->evaluate(\"Function\")" , |
| 1278 | "engine->evaluate(\"(function() { return 1; })\")" , |
| 1279 | "engine->evaluate(\"(function() { return 'ciao'; })\")" , |
| 1280 | "engine->evaluate(\"(function() { throw new Error('foo'); })\")" , |
| 1281 | "engine->evaluate(\"/foo/\")" , |
| 1282 | "engine->evaluate(\"new Object()\")" , |
| 1283 | "engine->evaluate(\"new Array()\")" , |
| 1284 | "engine->evaluate(\"new Error()\")" , |
| 1285 | "engine->evaluate(\"new Boolean(true)\")" , |
| 1286 | "engine->evaluate(\"new Boolean(false)\")" , |
| 1287 | "engine->evaluate(\"new Number(123)\")" , |
| 1288 | "engine->evaluate(\"new RegExp('foo', 'gim')\")" , |
| 1289 | "engine->evaluate(\"new String('ciao')\")" , |
| 1290 | "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" , |
| 1291 | "engine->evaluate(\"Undefined\")" , |
| 1292 | "engine->evaluate(\"Null\")" , |
| 1293 | "engine->evaluate(\"True\")" , |
| 1294 | "engine->evaluate(\"False\")" , |
| 1295 | "engine->evaluate(\"undefined\")" , |
| 1296 | "engine->evaluate(\"null\")" , |
| 1297 | "engine->evaluate(\"true\")" , |
| 1298 | "engine->evaluate(\"false\")" , |
| 1299 | "engine->evaluate(\"122\")" , |
| 1300 | "engine->evaluate(\"124\")" , |
| 1301 | "engine->evaluate(\"0\")" , |
| 1302 | "engine->evaluate(\"0.0\")" , |
| 1303 | "engine->evaluate(\"123.0\")" , |
| 1304 | "engine->evaluate(\"6.37e-8\")" , |
| 1305 | "engine->evaluate(\"-6.37e-8\")" , |
| 1306 | "engine->evaluate(\"0x43211234\")" , |
| 1307 | "engine->evaluate(\"0x10000\")" , |
| 1308 | "engine->evaluate(\"0x10001\")" , |
| 1309 | "engine->evaluate(\"NaN\")" , |
| 1310 | "engine->evaluate(\"Infinity\")" , |
| 1311 | "engine->evaluate(\"-Infinity\")" , |
| 1312 | "engine->evaluate(\"'ciao'\")" , |
| 1313 | "engine->evaluate(\"''\")" , |
| 1314 | "engine->evaluate(\"'0'\")" , |
| 1315 | "engine->evaluate(\"'123'\")" , |
| 1316 | "engine->evaluate(\"'12.4'\")" , |
| 1317 | "engine->nullValue()" , |
| 1318 | "engine->undefinedValue()" , |
| 1319 | "engine->newObject()" , |
| 1320 | "engine->newArray()" , |
| 1321 | "engine->newArray(10)" , |
| 1322 | "engine->newDate(QDateTime())" , |
| 1323 | "engine->newQMetaObject(&QObject::staticMetaObject)" , |
| 1324 | "engine->newRegExp(\"foo\", \"gim\")" , |
| 1325 | "engine->newVariant(QVariant())" , |
| 1326 | "engine->newVariant(QVariant(123))" , |
| 1327 | "engine->newVariant(QVariant(false))" , |
| 1328 | "engine->newQObject(0)" , |
| 1329 | "engine->newQObject(engine)" }; |
| 1330 | |
| 1331 | static qint32 toInt32_valueArray[] = { |
| 1332 | 0, 0, |
| 1333 | 0, 1, |
| 1334 | 0, 122, |
| 1335 | 124, 0, |
| 1336 | 0, 123, |
| 1337 | 0, 0, |
| 1338 | 1126240820, 65536, |
| 1339 | 65537, 0, |
| 1340 | 0, 0, |
| 1341 | 0, 0, |
| 1342 | 0, 0, |
| 1343 | 0, 0, |
| 1344 | 0, 0, |
| 1345 | 0, 123, |
| 1346 | 12, 0, |
| 1347 | 0, 1, |
| 1348 | 0, 122, |
| 1349 | 124, 0, |
| 1350 | 0, 123, |
| 1351 | 0, 0, |
| 1352 | 1126240820, 65536, |
| 1353 | 65537, 0, |
| 1354 | 0, 0, |
| 1355 | 0, 0, |
| 1356 | 0, 0, |
| 1357 | 0, 0, |
| 1358 | 0, 0, |
| 1359 | 0, 123, |
| 1360 | 12, 0, |
| 1361 | 0, 1, |
| 1362 | 0, 122, |
| 1363 | 124, 0, |
| 1364 | 0, 123, |
| 1365 | 0, 0, |
| 1366 | 1126240820, 65536, |
| 1367 | 65537, 0, |
| 1368 | 0, 0, |
| 1369 | 0, 0, |
| 1370 | 0, 0, |
| 1371 | 0, 0, |
| 1372 | 0, 0, |
| 1373 | 0, 123, |
| 1374 | 1, 0, |
| 1375 | 0, 0, |
| 1376 | 0, 0, |
| 1377 | 0, 0, |
| 1378 | 0, 0, |
| 1379 | 0, 0, |
| 1380 | 0, 0, |
| 1381 | 0, 0, |
| 1382 | 0, 0, |
| 1383 | 0, 1, |
| 1384 | 0, 123, |
| 1385 | 0, 0, |
| 1386 | 22, 0, |
| 1387 | 0, 0, |
| 1388 | 0, 0, |
| 1389 | 0, 1, |
| 1390 | 0, 122, |
| 1391 | 124, 0, |
| 1392 | 0, 123, |
| 1393 | 0, 0, |
| 1394 | 1126240820, 65536, |
| 1395 | 65537, 0, |
| 1396 | 0, 0, |
| 1397 | 0, 0, |
| 1398 | 0, 123, |
| 1399 | 12, 0, |
| 1400 | 0, 0, |
| 1401 | 0, 0, |
| 1402 | 0, 0, |
| 1403 | 0, 0, |
| 1404 | 123, 0, |
| 1405 | 0, 0}; |
| 1406 | |
| 1407 | void tst_QScriptValueGenerated::toInt32_makeData(const char* expr) |
| 1408 | { |
| 1409 | static const QHash<QString, qint32> toInt32 = |
| 1410 | charValueArraysToHash(keys: toInt32_tagArray, values: toInt32_valueArray, |
| 1411 | size: int(sizeof(toInt32_tagArray) / sizeof(const char *))); |
| 1412 | newRow(tag: expr) << toInt32.value(akey: expr); |
| 1413 | } |
| 1414 | |
| 1415 | void tst_QScriptValueGenerated::toInt32_test(const char*, const QScriptValue& value) |
| 1416 | { |
| 1417 | QFETCH(qint32, expected); |
| 1418 | QCOMPARE(value.toInt32(), expected); |
| 1419 | QCOMPARE(value.toInt32(), expected); |
| 1420 | } |
| 1421 | |
| 1422 | DEFINE_TEST_FUNCTION(toInt32) |
| 1423 | |
| 1424 | |
| 1425 | void tst_QScriptValueGenerated::toUInt32_initData() |
| 1426 | { |
| 1427 | QTest::addColumn<quint32>(name: "expected" ); |
| 1428 | initScriptValues(); |
| 1429 | } |
| 1430 | |
| 1431 | static const char *toUInt32_tagArray[] = { |
| 1432 | "QScriptValue()" , |
| 1433 | "QScriptValue(QScriptValue::UndefinedValue)" , |
| 1434 | "QScriptValue(QScriptValue::NullValue)" , |
| 1435 | "QScriptValue(true)" , |
| 1436 | "QScriptValue(false)" , |
| 1437 | "QScriptValue(int(122))" , |
| 1438 | "QScriptValue(uint(124))" , |
| 1439 | "QScriptValue(0)" , |
| 1440 | "QScriptValue(0.0)" , |
| 1441 | "QScriptValue(123.0)" , |
| 1442 | "QScriptValue(6.37e-8)" , |
| 1443 | "QScriptValue(-6.37e-8)" , |
| 1444 | "QScriptValue(0x43211234)" , |
| 1445 | "QScriptValue(0x10000)" , |
| 1446 | "QScriptValue(0x10001)" , |
| 1447 | "QScriptValue(qSNaN())" , |
| 1448 | "QScriptValue(qQNaN())" , |
| 1449 | "QScriptValue(qInf())" , |
| 1450 | "QScriptValue(-qInf())" , |
| 1451 | "QScriptValue(\"NaN\")" , |
| 1452 | "QScriptValue(\"Infinity\")" , |
| 1453 | "QScriptValue(\"-Infinity\")" , |
| 1454 | "QScriptValue(\"ciao\")" , |
| 1455 | "QScriptValue(QString::fromLatin1(\"ciao\"))" , |
| 1456 | "QScriptValue(QString(\"\"))" , |
| 1457 | "QScriptValue(QString())" , |
| 1458 | "QScriptValue(QString(\"0\"))" , |
| 1459 | "QScriptValue(QString(\"123\"))" , |
| 1460 | "QScriptValue(QString(\"12.4\"))" , |
| 1461 | "QScriptValue(0, QScriptValue::UndefinedValue)" , |
| 1462 | "QScriptValue(0, QScriptValue::NullValue)" , |
| 1463 | "QScriptValue(0, true)" , |
| 1464 | "QScriptValue(0, false)" , |
| 1465 | "QScriptValue(0, int(122))" , |
| 1466 | "QScriptValue(0, uint(124))" , |
| 1467 | "QScriptValue(0, 0)" , |
| 1468 | "QScriptValue(0, 0.0)" , |
| 1469 | "QScriptValue(0, 123.0)" , |
| 1470 | "QScriptValue(0, 6.37e-8)" , |
| 1471 | "QScriptValue(0, -6.37e-8)" , |
| 1472 | "QScriptValue(0, 0x43211234)" , |
| 1473 | "QScriptValue(0, 0x10000)" , |
| 1474 | "QScriptValue(0, 0x10001)" , |
| 1475 | "QScriptValue(0, qSNaN())" , |
| 1476 | "QScriptValue(0, qQNaN())" , |
| 1477 | "QScriptValue(0, qInf())" , |
| 1478 | "QScriptValue(0, -qInf())" , |
| 1479 | "QScriptValue(0, \"NaN\")" , |
| 1480 | "QScriptValue(0, \"Infinity\")" , |
| 1481 | "QScriptValue(0, \"-Infinity\")" , |
| 1482 | "QScriptValue(0, \"ciao\")" , |
| 1483 | "QScriptValue(0, QString::fromLatin1(\"ciao\"))" , |
| 1484 | "QScriptValue(0, QString(\"\"))" , |
| 1485 | "QScriptValue(0, QString())" , |
| 1486 | "QScriptValue(0, QString(\"0\"))" , |
| 1487 | "QScriptValue(0, QString(\"123\"))" , |
| 1488 | "QScriptValue(0, QString(\"12.3\"))" , |
| 1489 | "QScriptValue(engine, QScriptValue::UndefinedValue)" , |
| 1490 | "QScriptValue(engine, QScriptValue::NullValue)" , |
| 1491 | "QScriptValue(engine, true)" , |
| 1492 | "QScriptValue(engine, false)" , |
| 1493 | "QScriptValue(engine, int(122))" , |
| 1494 | "QScriptValue(engine, uint(124))" , |
| 1495 | "QScriptValue(engine, 0)" , |
| 1496 | "QScriptValue(engine, 0.0)" , |
| 1497 | "QScriptValue(engine, 123.0)" , |
| 1498 | "QScriptValue(engine, 6.37e-8)" , |
| 1499 | "QScriptValue(engine, -6.37e-8)" , |
| 1500 | "QScriptValue(engine, 0x43211234)" , |
| 1501 | "QScriptValue(engine, 0x10000)" , |
| 1502 | "QScriptValue(engine, 0x10001)" , |
| 1503 | "QScriptValue(engine, qSNaN())" , |
| 1504 | "QScriptValue(engine, qQNaN())" , |
| 1505 | "QScriptValue(engine, qInf())" , |
| 1506 | "QScriptValue(engine, -qInf())" , |
| 1507 | "QScriptValue(engine, \"NaN\")" , |
| 1508 | "QScriptValue(engine, \"Infinity\")" , |
| 1509 | "QScriptValue(engine, \"-Infinity\")" , |
| 1510 | "QScriptValue(engine, \"ciao\")" , |
| 1511 | "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" , |
| 1512 | "QScriptValue(engine, QString(\"\"))" , |
| 1513 | "QScriptValue(engine, QString())" , |
| 1514 | "QScriptValue(engine, QString(\"0\"))" , |
| 1515 | "QScriptValue(engine, QString(\"123\"))" , |
| 1516 | "QScriptValue(engine, QString(\"1.23\"))" , |
| 1517 | "engine->evaluate(\"[]\")" , |
| 1518 | "engine->evaluate(\"{}\")" , |
| 1519 | "engine->evaluate(\"Object.prototype\")" , |
| 1520 | "engine->evaluate(\"Date.prototype\")" , |
| 1521 | "engine->evaluate(\"Array.prototype\")" , |
| 1522 | "engine->evaluate(\"Function.prototype\")" , |
| 1523 | "engine->evaluate(\"Error.prototype\")" , |
| 1524 | "engine->evaluate(\"Object\")" , |
| 1525 | "engine->evaluate(\"Array\")" , |
| 1526 | "engine->evaluate(\"Number\")" , |
| 1527 | "engine->evaluate(\"Function\")" , |
| 1528 | "engine->evaluate(\"(function() { return 1; })\")" , |
| 1529 | "engine->evaluate(\"(function() { return 'ciao'; })\")" , |
| 1530 | "engine->evaluate(\"(function() { throw new Error('foo'); })\")" , |
| 1531 | "engine->evaluate(\"/foo/\")" , |
| 1532 | "engine->evaluate(\"new Object()\")" , |
| 1533 | "engine->evaluate(\"new Array()\")" , |
| 1534 | "engine->evaluate(\"new Error()\")" , |
| 1535 | "engine->evaluate(\"new Boolean(true)\")" , |
| 1536 | "engine->evaluate(\"new Boolean(false)\")" , |
| 1537 | "engine->evaluate(\"new Number(123)\")" , |
| 1538 | "engine->evaluate(\"new RegExp('foo', 'gim')\")" , |
| 1539 | "engine->evaluate(\"new String('ciao')\")" , |
| 1540 | "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" , |
| 1541 | "engine->evaluate(\"Undefined\")" , |
| 1542 | "engine->evaluate(\"Null\")" , |
| 1543 | "engine->evaluate(\"True\")" , |
| 1544 | "engine->evaluate(\"False\")" , |
| 1545 | "engine->evaluate(\"undefined\")" , |
| 1546 | "engine->evaluate(\"null\")" , |
| 1547 | "engine->evaluate(\"true\")" , |
| 1548 | "engine->evaluate(\"false\")" , |
| 1549 | "engine->evaluate(\"122\")" , |
| 1550 | "engine->evaluate(\"124\")" , |
| 1551 | "engine->evaluate(\"0\")" , |
| 1552 | "engine->evaluate(\"0.0\")" , |
| 1553 | "engine->evaluate(\"123.0\")" , |
| 1554 | "engine->evaluate(\"6.37e-8\")" , |
| 1555 | "engine->evaluate(\"-6.37e-8\")" , |
| 1556 | "engine->evaluate(\"0x43211234\")" , |
| 1557 | "engine->evaluate(\"0x10000\")" , |
| 1558 | "engine->evaluate(\"0x10001\")" , |
| 1559 | "engine->evaluate(\"NaN\")" , |
| 1560 | "engine->evaluate(\"Infinity\")" , |
| 1561 | "engine->evaluate(\"-Infinity\")" , |
| 1562 | "engine->evaluate(\"'ciao'\")" , |
| 1563 | "engine->evaluate(\"''\")" , |
| 1564 | "engine->evaluate(\"'0'\")" , |
| 1565 | "engine->evaluate(\"'123'\")" , |
| 1566 | "engine->evaluate(\"'12.4'\")" , |
| 1567 | "engine->nullValue()" , |
| 1568 | "engine->undefinedValue()" , |
| 1569 | "engine->newObject()" , |
| 1570 | "engine->newArray()" , |
| 1571 | "engine->newArray(10)" , |
| 1572 | "engine->newDate(QDateTime())" , |
| 1573 | "engine->newQMetaObject(&QObject::staticMetaObject)" , |
| 1574 | "engine->newRegExp(\"foo\", \"gim\")" , |
| 1575 | "engine->newVariant(QVariant())" , |
| 1576 | "engine->newVariant(QVariant(123))" , |
| 1577 | "engine->newVariant(QVariant(false))" , |
| 1578 | "engine->newQObject(0)" , |
| 1579 | "engine->newQObject(engine)" }; |
| 1580 | |
| 1581 | static quint32 toUInt32_valueArray[] = { |
| 1582 | 0, 0, |
| 1583 | 0, 1, |
| 1584 | 0, 122, |
| 1585 | 124, 0, |
| 1586 | 0, 123, |
| 1587 | 0, 0, |
| 1588 | 1126240820, 65536, |
| 1589 | 65537, 0, |
| 1590 | 0, 0, |
| 1591 | 0, 0, |
| 1592 | 0, 0, |
| 1593 | 0, 0, |
| 1594 | 0, 0, |
| 1595 | 0, 123, |
| 1596 | 12, 0, |
| 1597 | 0, 1, |
| 1598 | 0, 122, |
| 1599 | 124, 0, |
| 1600 | 0, 123, |
| 1601 | 0, 0, |
| 1602 | 1126240820, 65536, |
| 1603 | 65537, 0, |
| 1604 | 0, 0, |
| 1605 | 0, 0, |
| 1606 | 0, 0, |
| 1607 | 0, 0, |
| 1608 | 0, 0, |
| 1609 | 0, 123, |
| 1610 | 12, 0, |
| 1611 | 0, 1, |
| 1612 | 0, 122, |
| 1613 | 124, 0, |
| 1614 | 0, 123, |
| 1615 | 0, 0, |
| 1616 | 1126240820, 65536, |
| 1617 | 65537, 0, |
| 1618 | 0, 0, |
| 1619 | 0, 0, |
| 1620 | 0, 0, |
| 1621 | 0, 0, |
| 1622 | 0, 0, |
| 1623 | 0, 123, |
| 1624 | 1, 0, |
| 1625 | 0, 0, |
| 1626 | 0, 0, |
| 1627 | 0, 0, |
| 1628 | 0, 0, |
| 1629 | 0, 0, |
| 1630 | 0, 0, |
| 1631 | 0, 0, |
| 1632 | 0, 0, |
| 1633 | 0, 1, |
| 1634 | 0, 123, |
| 1635 | 0, 0, |
| 1636 | 22, 0, |
| 1637 | 0, 0, |
| 1638 | 0, 0, |
| 1639 | 0, 1, |
| 1640 | 0, 122, |
| 1641 | 124, 0, |
| 1642 | 0, 123, |
| 1643 | 0, 0, |
| 1644 | 1126240820, 65536, |
| 1645 | 65537, 0, |
| 1646 | 0, 0, |
| 1647 | 0, 0, |
| 1648 | 0, 123, |
| 1649 | 12, 0, |
| 1650 | 0, 0, |
| 1651 | 0, 0, |
| 1652 | 0, 0, |
| 1653 | 0, 0, |
| 1654 | 123, 0, |
| 1655 | 0, 0}; |
| 1656 | |
| 1657 | void tst_QScriptValueGenerated::toUInt32_makeData(const char* expr) |
| 1658 | { |
| 1659 | static const QHash<QString, quint32> toUInt32 = |
| 1660 | charValueArraysToHash(keys: toUInt32_tagArray, values: toUInt32_valueArray, |
| 1661 | size: int(sizeof(toUInt32_tagArray) / sizeof(const char *))); |
| 1662 | newRow(tag: expr) << toUInt32.value(akey: expr); |
| 1663 | } |
| 1664 | |
| 1665 | void tst_QScriptValueGenerated::toUInt32_test(const char*, const QScriptValue& value) |
| 1666 | { |
| 1667 | QFETCH(quint32, expected); |
| 1668 | QCOMPARE(value.toUInt32(), expected); |
| 1669 | QCOMPARE(value.toUInt32(), expected); |
| 1670 | } |
| 1671 | |
| 1672 | DEFINE_TEST_FUNCTION(toUInt32) |
| 1673 | |
| 1674 | |
| 1675 | void tst_QScriptValueGenerated::toUInt16_initData() |
| 1676 | { |
| 1677 | QTest::addColumn<quint16>(name: "expected" ); |
| 1678 | initScriptValues(); |
| 1679 | } |
| 1680 | |
| 1681 | static const char *toUInt16_tagArray[] = { |
| 1682 | "QScriptValue()" , |
| 1683 | "QScriptValue(QScriptValue::UndefinedValue)" , |
| 1684 | "QScriptValue(QScriptValue::NullValue)" , |
| 1685 | "QScriptValue(true)" , |
| 1686 | "QScriptValue(false)" , |
| 1687 | "QScriptValue(int(122))" , |
| 1688 | "QScriptValue(uint(124))" , |
| 1689 | "QScriptValue(0)" , |
| 1690 | "QScriptValue(0.0)" , |
| 1691 | "QScriptValue(123.0)" , |
| 1692 | "QScriptValue(6.37e-8)" , |
| 1693 | "QScriptValue(-6.37e-8)" , |
| 1694 | "QScriptValue(0x43211234)" , |
| 1695 | "QScriptValue(0x10000)" , |
| 1696 | "QScriptValue(0x10001)" , |
| 1697 | "QScriptValue(qSNaN())" , |
| 1698 | "QScriptValue(qQNaN())" , |
| 1699 | "QScriptValue(qInf())" , |
| 1700 | "QScriptValue(-qInf())" , |
| 1701 | "QScriptValue(\"NaN\")" , |
| 1702 | "QScriptValue(\"Infinity\")" , |
| 1703 | "QScriptValue(\"-Infinity\")" , |
| 1704 | "QScriptValue(\"ciao\")" , |
| 1705 | "QScriptValue(QString::fromLatin1(\"ciao\"))" , |
| 1706 | "QScriptValue(QString(\"\"))" , |
| 1707 | "QScriptValue(QString())" , |
| 1708 | "QScriptValue(QString(\"0\"))" , |
| 1709 | "QScriptValue(QString(\"123\"))" , |
| 1710 | "QScriptValue(QString(\"12.4\"))" , |
| 1711 | "QScriptValue(0, QScriptValue::UndefinedValue)" , |
| 1712 | "QScriptValue(0, QScriptValue::NullValue)" , |
| 1713 | "QScriptValue(0, true)" , |
| 1714 | "QScriptValue(0, false)" , |
| 1715 | "QScriptValue(0, int(122))" , |
| 1716 | "QScriptValue(0, uint(124))" , |
| 1717 | "QScriptValue(0, 0)" , |
| 1718 | "QScriptValue(0, 0.0)" , |
| 1719 | "QScriptValue(0, 123.0)" , |
| 1720 | "QScriptValue(0, 6.37e-8)" , |
| 1721 | "QScriptValue(0, -6.37e-8)" , |
| 1722 | "QScriptValue(0, 0x43211234)" , |
| 1723 | "QScriptValue(0, 0x10000)" , |
| 1724 | "QScriptValue(0, 0x10001)" , |
| 1725 | "QScriptValue(0, qSNaN())" , |
| 1726 | "QScriptValue(0, qQNaN())" , |
| 1727 | "QScriptValue(0, qInf())" , |
| 1728 | "QScriptValue(0, -qInf())" , |
| 1729 | "QScriptValue(0, \"NaN\")" , |
| 1730 | "QScriptValue(0, \"Infinity\")" , |
| 1731 | "QScriptValue(0, \"-Infinity\")" , |
| 1732 | "QScriptValue(0, \"ciao\")" , |
| 1733 | "QScriptValue(0, QString::fromLatin1(\"ciao\"))" , |
| 1734 | "QScriptValue(0, QString(\"\"))" , |
| 1735 | "QScriptValue(0, QString())" , |
| 1736 | "QScriptValue(0, QString(\"0\"))" , |
| 1737 | "QScriptValue(0, QString(\"123\"))" , |
| 1738 | "QScriptValue(0, QString(\"12.3\"))" , |
| 1739 | "QScriptValue(engine, QScriptValue::UndefinedValue)" , |
| 1740 | "QScriptValue(engine, QScriptValue::NullValue)" , |
| 1741 | "QScriptValue(engine, true)" , |
| 1742 | "QScriptValue(engine, false)" , |
| 1743 | "QScriptValue(engine, int(122))" , |
| 1744 | "QScriptValue(engine, uint(124))" , |
| 1745 | "QScriptValue(engine, 0)" , |
| 1746 | "QScriptValue(engine, 0.0)" , |
| 1747 | "QScriptValue(engine, 123.0)" , |
| 1748 | "QScriptValue(engine, 6.37e-8)" , |
| 1749 | "QScriptValue(engine, -6.37e-8)" , |
| 1750 | "QScriptValue(engine, 0x43211234)" , |
| 1751 | "QScriptValue(engine, 0x10000)" , |
| 1752 | "QScriptValue(engine, 0x10001)" , |
| 1753 | "QScriptValue(engine, qSNaN())" , |
| 1754 | "QScriptValue(engine, qQNaN())" , |
| 1755 | "QScriptValue(engine, qInf())" , |
| 1756 | "QScriptValue(engine, -qInf())" , |
| 1757 | "QScriptValue(engine, \"NaN\")" , |
| 1758 | "QScriptValue(engine, \"Infinity\")" , |
| 1759 | "QScriptValue(engine, \"-Infinity\")" , |
| 1760 | "QScriptValue(engine, \"ciao\")" , |
| 1761 | "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" , |
| 1762 | "QScriptValue(engine, QString(\"\"))" , |
| 1763 | "QScriptValue(engine, QString())" , |
| 1764 | "QScriptValue(engine, QString(\"0\"))" , |
| 1765 | "QScriptValue(engine, QString(\"123\"))" , |
| 1766 | "QScriptValue(engine, QString(\"1.23\"))" , |
| 1767 | "engine->evaluate(\"[]\")" , |
| 1768 | "engine->evaluate(\"{}\")" , |
| 1769 | "engine->evaluate(\"Object.prototype\")" , |
| 1770 | "engine->evaluate(\"Date.prototype\")" , |
| 1771 | "engine->evaluate(\"Array.prototype\")" , |
| 1772 | "engine->evaluate(\"Function.prototype\")" , |
| 1773 | "engine->evaluate(\"Error.prototype\")" , |
| 1774 | "engine->evaluate(\"Object\")" , |
| 1775 | "engine->evaluate(\"Array\")" , |
| 1776 | "engine->evaluate(\"Number\")" , |
| 1777 | "engine->evaluate(\"Function\")" , |
| 1778 | "engine->evaluate(\"(function() { return 1; })\")" , |
| 1779 | "engine->evaluate(\"(function() { return 'ciao'; })\")" , |
| 1780 | "engine->evaluate(\"(function() { throw new Error('foo'); })\")" , |
| 1781 | "engine->evaluate(\"/foo/\")" , |
| 1782 | "engine->evaluate(\"new Object()\")" , |
| 1783 | "engine->evaluate(\"new Array()\")" , |
| 1784 | "engine->evaluate(\"new Error()\")" , |
| 1785 | "engine->evaluate(\"new Boolean(true)\")" , |
| 1786 | "engine->evaluate(\"new Boolean(false)\")" , |
| 1787 | "engine->evaluate(\"new Number(123)\")" , |
| 1788 | "engine->evaluate(\"new RegExp('foo', 'gim')\")" , |
| 1789 | "engine->evaluate(\"new String('ciao')\")" , |
| 1790 | "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" , |
| 1791 | "engine->evaluate(\"Undefined\")" , |
| 1792 | "engine->evaluate(\"Null\")" , |
| 1793 | "engine->evaluate(\"True\")" , |
| 1794 | "engine->evaluate(\"False\")" , |
| 1795 | "engine->evaluate(\"undefined\")" , |
| 1796 | "engine->evaluate(\"null\")" , |
| 1797 | "engine->evaluate(\"true\")" , |
| 1798 | "engine->evaluate(\"false\")" , |
| 1799 | "engine->evaluate(\"122\")" , |
| 1800 | "engine->evaluate(\"124\")" , |
| 1801 | "engine->evaluate(\"0\")" , |
| 1802 | "engine->evaluate(\"0.0\")" , |
| 1803 | "engine->evaluate(\"123.0\")" , |
| 1804 | "engine->evaluate(\"6.37e-8\")" , |
| 1805 | "engine->evaluate(\"-6.37e-8\")" , |
| 1806 | "engine->evaluate(\"0x43211234\")" , |
| 1807 | "engine->evaluate(\"0x10000\")" , |
| 1808 | "engine->evaluate(\"0x10001\")" , |
| 1809 | "engine->evaluate(\"NaN\")" , |
| 1810 | "engine->evaluate(\"Infinity\")" , |
| 1811 | "engine->evaluate(\"-Infinity\")" , |
| 1812 | "engine->evaluate(\"'ciao'\")" , |
| 1813 | "engine->evaluate(\"''\")" , |
| 1814 | "engine->evaluate(\"'0'\")" , |
| 1815 | "engine->evaluate(\"'123'\")" , |
| 1816 | "engine->evaluate(\"'12.4'\")" , |
| 1817 | "engine->nullValue()" , |
| 1818 | "engine->undefinedValue()" , |
| 1819 | "engine->newObject()" , |
| 1820 | "engine->newArray()" , |
| 1821 | "engine->newArray(10)" , |
| 1822 | "engine->newDate(QDateTime())" , |
| 1823 | "engine->newQMetaObject(&QObject::staticMetaObject)" , |
| 1824 | "engine->newRegExp(\"foo\", \"gim\")" , |
| 1825 | "engine->newVariant(QVariant())" , |
| 1826 | "engine->newVariant(QVariant(123))" , |
| 1827 | "engine->newVariant(QVariant(false))" , |
| 1828 | "engine->newQObject(0)" , |
| 1829 | "engine->newQObject(engine)" }; |
| 1830 | |
| 1831 | static quint16 toUInt16_valueArray[] = { |
| 1832 | 0, 0, |
| 1833 | 0, 1, |
| 1834 | 0, 122, |
| 1835 | 124, 0, |
| 1836 | 0, 123, |
| 1837 | 0, 0, |
| 1838 | 4660, 0, |
| 1839 | 1, 0, |
| 1840 | 0, 0, |
| 1841 | 0, 0, |
| 1842 | 0, 0, |
| 1843 | 0, 0, |
| 1844 | 0, 0, |
| 1845 | 0, 123, |
| 1846 | 12, 0, |
| 1847 | 0, 1, |
| 1848 | 0, 122, |
| 1849 | 124, 0, |
| 1850 | 0, 123, |
| 1851 | 0, 0, |
| 1852 | 4660, 0, |
| 1853 | 1, 0, |
| 1854 | 0, 0, |
| 1855 | 0, 0, |
| 1856 | 0, 0, |
| 1857 | 0, 0, |
| 1858 | 0, 0, |
| 1859 | 0, 123, |
| 1860 | 12, 0, |
| 1861 | 0, 1, |
| 1862 | 0, 122, |
| 1863 | 124, 0, |
| 1864 | 0, 123, |
| 1865 | 0, 0, |
| 1866 | 4660, 0, |
| 1867 | 1, 0, |
| 1868 | 0, 0, |
| 1869 | 0, 0, |
| 1870 | 0, 0, |
| 1871 | 0, 0, |
| 1872 | 0, 0, |
| 1873 | 0, 123, |
| 1874 | 1, 0, |
| 1875 | 0, 0, |
| 1876 | 0, 0, |
| 1877 | 0, 0, |
| 1878 | 0, 0, |
| 1879 | 0, 0, |
| 1880 | 0, 0, |
| 1881 | 0, 0, |
| 1882 | 0, 0, |
| 1883 | 0, 1, |
| 1884 | 0, 123, |
| 1885 | 0, 0, |
| 1886 | 22, 0, |
| 1887 | 0, 0, |
| 1888 | 0, 0, |
| 1889 | 0, 1, |
| 1890 | 0, 122, |
| 1891 | 124, 0, |
| 1892 | 0, 123, |
| 1893 | 0, 0, |
| 1894 | 4660, 0, |
| 1895 | 1, 0, |
| 1896 | 0, 0, |
| 1897 | 0, 0, |
| 1898 | 0, 123, |
| 1899 | 12, 0, |
| 1900 | 0, 0, |
| 1901 | 0, 0, |
| 1902 | 0, 0, |
| 1903 | 0, 0, |
| 1904 | 123, 0, |
| 1905 | 0, 0}; |
| 1906 | |
| 1907 | void tst_QScriptValueGenerated::toUInt16_makeData(const char* expr) |
| 1908 | { |
| 1909 | static const QHash<QString, quint16> toUInt16 = |
| 1910 | charValueArraysToHash(keys: toUInt16_tagArray, values: toUInt16_valueArray, |
| 1911 | size: int(sizeof(toUInt16_tagArray) / sizeof(const char *))); |
| 1912 | newRow(tag: expr) << toUInt16.value(akey: expr); |
| 1913 | } |
| 1914 | |
| 1915 | void tst_QScriptValueGenerated::toUInt16_test(const char*, const QScriptValue& value) |
| 1916 | { |
| 1917 | QFETCH(quint16, expected); |
| 1918 | QCOMPARE(value.toUInt16(), expected); |
| 1919 | QCOMPARE(value.toUInt16(), expected); |
| 1920 | } |
| 1921 | |
| 1922 | DEFINE_TEST_FUNCTION(toUInt16) |
| 1923 | |