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
32void tst_QScriptValueGenerated::initScriptValues()
33{
34 m_values.clear();
35 if (engine)
36 delete engine;
37 engine = new QScriptEngine;
38 DEFINE_TEST_VALUE(QScriptValue());
39 DEFINE_TEST_VALUE(QScriptValue(QScriptValue::UndefinedValue));
40 DEFINE_TEST_VALUE(QScriptValue(QScriptValue::NullValue));
41 DEFINE_TEST_VALUE(QScriptValue(true));
42 DEFINE_TEST_VALUE(QScriptValue(false));
43 DEFINE_TEST_VALUE(QScriptValue(int(122)));
44 DEFINE_TEST_VALUE(QScriptValue(uint(124)));
45 DEFINE_TEST_VALUE(QScriptValue(0));
46 DEFINE_TEST_VALUE(QScriptValue(0.0));
47 DEFINE_TEST_VALUE(QScriptValue(123.0));
48 DEFINE_TEST_VALUE(QScriptValue(6.37e-8));
49 DEFINE_TEST_VALUE(QScriptValue(-6.37e-8));
50 DEFINE_TEST_VALUE(QScriptValue(0x43211234));
51 DEFINE_TEST_VALUE(QScriptValue(0x10000));
52 DEFINE_TEST_VALUE(QScriptValue(0x10001));
53 DEFINE_TEST_VALUE(QScriptValue(qSNaN()));
54 DEFINE_TEST_VALUE(QScriptValue(qQNaN()));
55 DEFINE_TEST_VALUE(QScriptValue(qInf()));
56 DEFINE_TEST_VALUE(QScriptValue(-qInf()));
57 DEFINE_TEST_VALUE(QScriptValue("NaN"));
58 DEFINE_TEST_VALUE(QScriptValue("Infinity"));
59 DEFINE_TEST_VALUE(QScriptValue("-Infinity"));
60 DEFINE_TEST_VALUE(QScriptValue("ciao"));
61 DEFINE_TEST_VALUE(QScriptValue(QString::fromLatin1("ciao")));
62 DEFINE_TEST_VALUE(QScriptValue(QString("")));
63 DEFINE_TEST_VALUE(QScriptValue(QString()));
64 DEFINE_TEST_VALUE(QScriptValue(QString("0")));
65 DEFINE_TEST_VALUE(QScriptValue(QString("123")));
66 DEFINE_TEST_VALUE(QScriptValue(QString("12.4")));
67 DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::UndefinedValue));
68 DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::NullValue));
69 DEFINE_TEST_VALUE(QScriptValue(0, true));
70 DEFINE_TEST_VALUE(QScriptValue(0, false));
71 DEFINE_TEST_VALUE(QScriptValue(0, int(122)));
72 DEFINE_TEST_VALUE(QScriptValue(0, uint(124)));
73 DEFINE_TEST_VALUE(QScriptValue(0, 0));
74 DEFINE_TEST_VALUE(QScriptValue(0, 0.0));
75 DEFINE_TEST_VALUE(QScriptValue(0, 123.0));
76 DEFINE_TEST_VALUE(QScriptValue(0, 6.37e-8));
77 DEFINE_TEST_VALUE(QScriptValue(0, -6.37e-8));
78 DEFINE_TEST_VALUE(QScriptValue(0, 0x43211234));
79 DEFINE_TEST_VALUE(QScriptValue(0, 0x10000));
80 DEFINE_TEST_VALUE(QScriptValue(0, 0x10001));
81 DEFINE_TEST_VALUE(QScriptValue(0, qSNaN()));
82 DEFINE_TEST_VALUE(QScriptValue(0, qQNaN()));
83 DEFINE_TEST_VALUE(QScriptValue(0, qInf()));
84 DEFINE_TEST_VALUE(QScriptValue(0, -qInf()));
85 DEFINE_TEST_VALUE(QScriptValue(0, "NaN"));
86 DEFINE_TEST_VALUE(QScriptValue(0, "Infinity"));
87 DEFINE_TEST_VALUE(QScriptValue(0, "-Infinity"));
88 DEFINE_TEST_VALUE(QScriptValue(0, "ciao"));
89 DEFINE_TEST_VALUE(QScriptValue(0, QString::fromLatin1("ciao")));
90 DEFINE_TEST_VALUE(QScriptValue(0, QString("")));
91 DEFINE_TEST_VALUE(QScriptValue(0, QString()));
92 DEFINE_TEST_VALUE(QScriptValue(0, QString("0")));
93 DEFINE_TEST_VALUE(QScriptValue(0, QString("123")));
94 DEFINE_TEST_VALUE(QScriptValue(0, QString("12.3")));
95 DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::UndefinedValue));
96 DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::NullValue));
97 DEFINE_TEST_VALUE(QScriptValue(engine, true));
98 DEFINE_TEST_VALUE(QScriptValue(engine, false));
99 DEFINE_TEST_VALUE(QScriptValue(engine, int(122)));
100 DEFINE_TEST_VALUE(QScriptValue(engine, uint(124)));
101 DEFINE_TEST_VALUE(QScriptValue(engine, 0));
102 DEFINE_TEST_VALUE(QScriptValue(engine, 0.0));
103 DEFINE_TEST_VALUE(QScriptValue(engine, 123.0));
104 DEFINE_TEST_VALUE(QScriptValue(engine, 6.37e-8));
105 DEFINE_TEST_VALUE(QScriptValue(engine, -6.37e-8));
106 DEFINE_TEST_VALUE(QScriptValue(engine, 0x43211234));
107 DEFINE_TEST_VALUE(QScriptValue(engine, 0x10000));
108 DEFINE_TEST_VALUE(QScriptValue(engine, 0x10001));
109 DEFINE_TEST_VALUE(QScriptValue(engine, qSNaN()));
110 DEFINE_TEST_VALUE(QScriptValue(engine, qQNaN()));
111 DEFINE_TEST_VALUE(QScriptValue(engine, qInf()));
112 DEFINE_TEST_VALUE(QScriptValue(engine, -qInf()));
113 DEFINE_TEST_VALUE(QScriptValue(engine, "NaN"));
114 DEFINE_TEST_VALUE(QScriptValue(engine, "Infinity"));
115 DEFINE_TEST_VALUE(QScriptValue(engine, "-Infinity"));
116 DEFINE_TEST_VALUE(QScriptValue(engine, "ciao"));
117 DEFINE_TEST_VALUE(QScriptValue(engine, QString::fromLatin1("ciao")));
118 DEFINE_TEST_VALUE(QScriptValue(engine, QString("")));
119 DEFINE_TEST_VALUE(QScriptValue(engine, QString()));
120 DEFINE_TEST_VALUE(QScriptValue(engine, QString("0")));
121 DEFINE_TEST_VALUE(QScriptValue(engine, QString("123")));
122 DEFINE_TEST_VALUE(QScriptValue(engine, QString("1.23")));
123 DEFINE_TEST_VALUE(engine->evaluate("[]"));
124 DEFINE_TEST_VALUE(engine->evaluate("{}"));
125 DEFINE_TEST_VALUE(engine->evaluate("Object.prototype"));
126 DEFINE_TEST_VALUE(engine->evaluate("Date.prototype"));
127 DEFINE_TEST_VALUE(engine->evaluate("Array.prototype"));
128 DEFINE_TEST_VALUE(engine->evaluate("Function.prototype"));
129 DEFINE_TEST_VALUE(engine->evaluate("Error.prototype"));
130 DEFINE_TEST_VALUE(engine->evaluate("Object"));
131 DEFINE_TEST_VALUE(engine->evaluate("Array"));
132 DEFINE_TEST_VALUE(engine->evaluate("Number"));
133 DEFINE_TEST_VALUE(engine->evaluate("Function"));
134 DEFINE_TEST_VALUE(engine->evaluate("(function() { return 1; })"));
135 DEFINE_TEST_VALUE(engine->evaluate("(function() { return 'ciao'; })"));
136 DEFINE_TEST_VALUE(engine->evaluate("(function() { throw new Error('foo'); })"));
137 DEFINE_TEST_VALUE(engine->evaluate("/foo/"));
138 DEFINE_TEST_VALUE(engine->evaluate("new Object()"));
139 DEFINE_TEST_VALUE(engine->evaluate("new Array()"));
140 DEFINE_TEST_VALUE(engine->evaluate("new Error()"));
141 DEFINE_TEST_VALUE(engine->evaluate("new Boolean(true)"));
142 DEFINE_TEST_VALUE(engine->evaluate("new Boolean(false)"));
143 DEFINE_TEST_VALUE(engine->evaluate("new Number(123)"));
144 DEFINE_TEST_VALUE(engine->evaluate("new RegExp('foo', 'gim')"));
145 DEFINE_TEST_VALUE(engine->evaluate("new String('ciao')"));
146 DEFINE_TEST_VALUE(engine->evaluate("a = new Object(); a.foo = 22; a.foo"));
147 DEFINE_TEST_VALUE(engine->evaluate("Undefined"));
148 DEFINE_TEST_VALUE(engine->evaluate("Null"));
149 DEFINE_TEST_VALUE(engine->evaluate("True"));
150 DEFINE_TEST_VALUE(engine->evaluate("False"));
151 DEFINE_TEST_VALUE(engine->evaluate("undefined"));
152 DEFINE_TEST_VALUE(engine->evaluate("null"));
153 DEFINE_TEST_VALUE(engine->evaluate("true"));
154 DEFINE_TEST_VALUE(engine->evaluate("false"));
155 DEFINE_TEST_VALUE(engine->evaluate("122"));
156 DEFINE_TEST_VALUE(engine->evaluate("124"));
157 DEFINE_TEST_VALUE(engine->evaluate("0"));
158 DEFINE_TEST_VALUE(engine->evaluate("0.0"));
159 DEFINE_TEST_VALUE(engine->evaluate("123.0"));
160 DEFINE_TEST_VALUE(engine->evaluate("6.37e-8"));
161 DEFINE_TEST_VALUE(engine->evaluate("-6.37e-8"));
162 DEFINE_TEST_VALUE(engine->evaluate("0x43211234"));
163 DEFINE_TEST_VALUE(engine->evaluate("0x10000"));
164 DEFINE_TEST_VALUE(engine->evaluate("0x10001"));
165 DEFINE_TEST_VALUE(engine->evaluate("NaN"));
166 DEFINE_TEST_VALUE(engine->evaluate("Infinity"));
167 DEFINE_TEST_VALUE(engine->evaluate("-Infinity"));
168 DEFINE_TEST_VALUE(engine->evaluate("'ciao'"));
169 DEFINE_TEST_VALUE(engine->evaluate("''"));
170 DEFINE_TEST_VALUE(engine->evaluate("'0'"));
171 DEFINE_TEST_VALUE(engine->evaluate("'123'"));
172 DEFINE_TEST_VALUE(engine->evaluate("'12.4'"));
173 DEFINE_TEST_VALUE(engine->nullValue());
174 DEFINE_TEST_VALUE(engine->undefinedValue());
175 DEFINE_TEST_VALUE(engine->newObject());
176 DEFINE_TEST_VALUE(engine->newArray());
177 DEFINE_TEST_VALUE(engine->newArray(10));
178 DEFINE_TEST_VALUE(engine->newDate(QDateTime()));
179 DEFINE_TEST_VALUE(engine->newQMetaObject(&QObject::staticMetaObject));
180 DEFINE_TEST_VALUE(engine->newRegExp("foo", "gim"));
181 DEFINE_TEST_VALUE(engine->newVariant(QVariant()));
182 DEFINE_TEST_VALUE(engine->newVariant(QVariant(123)));
183 DEFINE_TEST_VALUE(engine->newVariant(QVariant(false)));
184 DEFINE_TEST_VALUE(engine->newQObject(0));
185 DEFINE_TEST_VALUE(engine->newQObject(engine));
186}
187
188

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