]> git.saurik.com Git - apple/javascriptcore.git/blob - qt/tests/qscriptvalue/tst_qscriptvalue.h
28154a98238472b4cb51b0594d3839a9ec104059
[apple/javascriptcore.git] / qt / tests / qscriptvalue / tst_qscriptvalue.h
1 /*
2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef tst_qscriptvalue_h
21 #define tst_qscriptvalue_h
22
23 #include "qscriptengine.h"
24 #include "qscriptvalue.h"
25 #include <QtCore/qnumeric.h>
26 #include <QtTest/qtest.h>
27
28 Q_DECLARE_METATYPE(QScriptValue*);
29 Q_DECLARE_METATYPE(QScriptValue);
30
31 class tst_QScriptValue : public QObject {
32 Q_OBJECT
33
34 public:
35 tst_QScriptValue();
36 virtual ~tst_QScriptValue();
37
38 private slots:
39 void toStringSimple_data();
40 void toStringSimple();
41 void copyConstructor_data();
42 void copyConstructor();
43 void assignOperator_data();
44 void assignOperator();
45 void dataSharing();
46 void constructors_data();
47 void constructors();
48 void call();
49 void ctor();
50
51 // Generated test functions.
52 void isBool_data();
53 void isBool();
54
55 void isBoolean_data();
56 void isBoolean();
57
58 void isNumber_data();
59 void isNumber();
60
61 void isFunction_data();
62 void isFunction();
63
64 void isNull_data();
65 void isNull();
66
67 void isObject_data();
68 void isObject();
69
70 void isString_data();
71 void isString();
72
73 void isUndefined_data();
74 void isUndefined();
75
76 void isValid_data();
77 void isValid();
78
79 void toString_data();
80 void toString();
81
82 void toNumber_data();
83 void toNumber();
84
85 void toBool_data();
86 void toBool();
87
88 void toBoolean_data();
89 void toBoolean();
90
91 void toInteger_data();
92 void toInteger();
93
94 void toInt32_data();
95 void toInt32();
96
97 void toUInt32_data();
98 void toUInt32();
99
100 void toUInt16_data();
101 void toUInt16();
102
103 private:
104 typedef void (tst_QScriptValue::*InitDataFunction)();
105 typedef void (tst_QScriptValue::*DefineDataFunction)(const char*);
106 void dataHelper(InitDataFunction init, DefineDataFunction define);
107 QTestData& newRow(const char* tag);
108
109 typedef void (tst_QScriptValue::*TestFunction)(const char*, const QScriptValue&);
110 void testHelper(TestFunction fun);
111
112 // Generated functions
113
114 void initScriptValues();
115
116 void isBool_initData();
117 void isBool_makeData(const char* expr);
118 void isBool_test(const char* expr, const QScriptValue& value);
119
120 void isBoolean_initData();
121 void isBoolean_makeData(const char* expr);
122 void isBoolean_test(const char* expr, const QScriptValue& value);
123
124 void isNumber_initData();
125 void isNumber_makeData(const char* expr);
126 void isNumber_test(const char* expr, const QScriptValue&);
127
128 void isFunction_initData();
129 void isFunction_makeData(const char* expr);
130 void isFunction_test(const char* expr, const QScriptValue& value);
131
132 void isNull_initData();
133 void isNull_makeData(const char* expr);
134 void isNull_test(const char* expr, const QScriptValue& value);
135
136 void isObject_initData();
137 void isObject_makeData(const char* expr);
138 void isObject_test(const char* expr, const QScriptValue& value);
139
140 void isString_initData();
141 void isString_makeData(const char* expr);
142 void isString_test(const char* expr, const QScriptValue& value);
143
144 void isUndefined_initData();
145 void isUndefined_makeData(const char* expr);
146 void isUndefined_test(const char* expr, const QScriptValue& value);
147
148 void isValid_initData();
149 void isValid_makeData(const char* expr);
150 void isValid_test(const char* expr, const QScriptValue& value);
151
152 void toString_initData();
153 void toString_makeData(const char*);
154 void toString_test(const char*, const QScriptValue&);
155
156 void toNumber_initData();
157 void toNumber_makeData(const char*);
158 void toNumber_test(const char*, const QScriptValue&);
159
160 void toBool_initData();
161 void toBool_makeData(const char*);
162 void toBool_test(const char*, const QScriptValue&);
163
164 void toBoolean_initData();
165 void toBoolean_makeData(const char*);
166 void toBoolean_test(const char*, const QScriptValue&);
167
168 void toInteger_initData();
169 void toInteger_makeData(const char*);
170 void toInteger_test(const char*, const QScriptValue&);
171
172 void toInt32_initData();
173 void toInt32_makeData(const char*);
174 void toInt32_test(const char*, const QScriptValue&);
175
176 void toUInt32_initData();
177 void toUInt32_makeData(const char*);
178 void toUInt32_test(const char*, const QScriptValue&);
179
180 void toUInt16_initData();
181 void toUInt16_makeData(const char*);
182 void toUInt16_test(const char*, const QScriptValue&);
183
184 private:
185 QScriptEngine* engine;
186 QHash<QString, QScriptValue> m_values;
187 QString m_currentExpression;
188 };
189
190 #define DEFINE_TEST_FUNCTION(name) \
191 void tst_QScriptValue::name##_data() { dataHelper(&tst_QScriptValue::name##_initData, &tst_QScriptValue::name##_makeData); } \
192 void tst_QScriptValue::name() { testHelper(&tst_QScriptValue::name##_test); }
193
194
195
196 #endif // tst_qscriptvalue_h