2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
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.
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.
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.
20 #include "qscriptengine.h"
21 #include "qscriptvalue.h"
24 class tst_QScriptEngine : public QObject {
28 void checkSyntax_data();
31 void evaluateString_data();
32 void evaluateString();
33 void evaluateProgram_data();
34 void evaluateProgram();
37 void undefinedValue();
39 void toStringHandle();
42 void tst_QScriptEngine::checkSyntax_data()
44 evaluateString_data();
47 void tst_QScriptEngine::checkSyntax()
49 QFETCH(QString, code);
52 engine.checkSyntax(code);
56 void tst_QScriptEngine::constructor()
63 void tst_QScriptEngine::evaluateString_data()
65 QTest::addColumn<QString>("code");
66 QTest::newRow("empty script") << QString::fromLatin1("");
67 QTest::newRow("number literal") << QString::fromLatin1("123");
68 QTest::newRow("string literal") << QString::fromLatin1("'ciao'");
69 QTest::newRow("regexp literal") << QString::fromLatin1("/foo/gim");
70 QTest::newRow("null literal") << QString::fromLatin1("null");
71 QTest::newRow("undefined literal") << QString::fromLatin1("undefined");
72 QTest::newRow("empty object literal") << QString::fromLatin1("{}");
73 QTest::newRow("this") << QString::fromLatin1("this");
76 void tst_QScriptEngine::evaluateString()
78 QFETCH(QString, code);
81 engine.evaluate(code);
85 void tst_QScriptEngine::evaluateProgram_data()
87 evaluateString_data();
90 void tst_QScriptEngine::evaluateProgram()
92 QFETCH(QString, code);
94 QScriptProgram program(code);
96 engine.evaluate(program);
100 void tst_QScriptEngine::newObject()
102 QScriptEngine engine;
108 void tst_QScriptEngine::nullValue()
110 QScriptEngine engine;
116 void tst_QScriptEngine::undefinedValue()
118 QScriptEngine engine;
120 engine.undefinedValue();
124 void tst_QScriptEngine::globalObject()
126 QScriptEngine engine;
128 engine.globalObject();
132 void tst_QScriptEngine::toStringHandle()
134 QScriptEngine engine;
135 QString str = QString::fromLatin1("foobarbaz");
137 engine.toStringHandle(str);
141 QTEST_MAIN(tst_QScriptEngine)
142 #include "tst_qscriptengine.moc"