mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 09:14:12 +02:00
Scripting: qet.apiSignatures(), the calls a script can make
Read from the meta-object, so the list is the one the running build has: for someone writing a script, and for an assistant that has to write one without the source at hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QProcess>
|
||||
@@ -88,6 +89,27 @@ private slots:
|
||||
QCOMPARE(r.value(QStringLiteral("current")).toInt(), -1);
|
||||
}
|
||||
|
||||
// The list is read from the build itself: the calls a script uses
|
||||
// are in it with their parameter names, each once.
|
||||
void apiSignaturesListed()
|
||||
{
|
||||
const QJsonObject r = run(QStringLiteral(
|
||||
"qet.log('PROBE ' + JSON.stringify({sigs: qet.apiSignatures()}));\n"),
|
||||
QStringLiteral(QET_EXAMPLES_DIR "/perceuse.qet"));
|
||||
QVERIFY2(!r.isEmpty(), "the script logged nothing");
|
||||
QStringList sigs;
|
||||
for (const QJsonValue &v : r.value(QStringLiteral("sigs")).toArray())
|
||||
sigs << v.toString();
|
||||
QVERIFY(sigs.size() > 100);
|
||||
QVERIFY(sigs.contains(QStringLiteral("int currentFolio()")));
|
||||
QVERIFY(sigs.contains(QStringLiteral(
|
||||
"int addText(int folioIndex, QString text, double x, double y)")));
|
||||
QVERIFY(sigs.contains(QStringLiteral(
|
||||
"bool exportPdf(QString output, bool showTerminals)")));
|
||||
QCOMPARE(sigs.filter(QStringLiteral(" exportPdf(")).size(), 1);
|
||||
QVERIFY(sigs.filter(QStringLiteral("setUndoGrouped")).isEmpty());
|
||||
}
|
||||
|
||||
void headlessUndoStaysPerCall()
|
||||
{
|
||||
const QJsonObject r = run(QStringLiteral(
|
||||
|
||||
Reference in New Issue
Block a user