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#define DEFINE_TEST_VALUE(expr) m_values.insert(QString::fromLatin1(#expr), expr)
29
30Q_DECLARE_METATYPE(QScriptValue*);
31Q_DECLARE_METATYPE(QScriptValue);
32typedef QPair<QString, QScriptValue> QPairQStringAndQScriptValue;
33Q_DECLARE_METATYPE(QPairQStringAndQScriptValue);
34
35class tst_QScriptValue : public QObject {
36    Q_OBJECT
37
38public:
39    tst_QScriptValue();
40    virtual ~tst_QScriptValue();
41
42private slots:
43    void toStringSimple_data();
44    void toStringSimple();
45    void copyConstructor_data();
46    void copyConstructor();
47    void assignOperator_data();
48    void assignOperator();
49    void dataSharing();
50    void constructors_data();
51    void constructors();
52    void getSetPrototype();
53    void call();
54    void ctor();
55    void toObjectSimple();
56    void getPropertySimple_data();
57    void getPropertySimple();
58    void setPropertySimple();
59    void setProperty_data();
60    void setProperty();
61    void getSetProperty();
62    void getPropertyResolveFlag();
63    void propertyFlag_data();
64    void propertyFlag();
65    void globalObjectChanges();
66    void assignAndCopyConstruct_data();
67    void assignAndCopyConstruct();
68
69    // Generated test functions.
70    void isArray_data();
71    void isArray();
72
73    void isBool_data();
74    void isBool();
75
76    void isBoolean_data();
77    void isBoolean();
78
79    void isError_data();
80    void isError();
81
82    void isNumber_data();
83    void isNumber();
84
85    void isFunction_data();
86    void isFunction();
87
88    void isNull_data();
89    void isNull();
90
91    void isObject_data();
92    void isObject();
93
94    void isString_data();
95    void isString();
96
97    void isUndefined_data();
98    void isUndefined();
99
100    void isValid_data();
101    void isValid();
102
103    void toString_data();
104    void toString();
105
106    void toNumber_data();
107    void toNumber();
108
109    void toBool_data();
110    void toBool();
111
112    void toBoolean_data();
113    void toBoolean();
114
115    void toInteger_data();
116    void toInteger();
117
118    void toInt32_data();
119    void toInt32();
120
121    void toUInt32_data();
122    void toUInt32();
123
124    void toUInt16_data();
125    void toUInt16();
126
127    void equals_data();
128    void equals();
129
130    void strictlyEquals_data();
131    void strictlyEquals();
132
133    void instanceOf_data();
134    void instanceOf();
135
136private:
137    // Generated function
138    QPair<QString, QScriptValue> initScriptValues(uint idx);
139
140    QScriptEngine* m_engine;
141};
142
143#endif // tst_qscriptvalue_h
144