Fixed vector math, added simple test for it

This commit is contained in:
ksuprynowicz 2022-11-20 21:07:14 +01:00
parent e680b5dc72
commit 0b8958204f
4 changed files with 18 additions and 9 deletions

View file

@ -460,7 +460,8 @@ bool ScriptEngineV8::castValueToVariant(const V8ScriptValue& v8Val, QVariant& de
}
// last chance, just convert it to a variant
// V8TODO
Q_ASSERT(false);
qDebug() << "Converting: " << *v8::String::Utf8Value(_v8Isolate, val->ToDetailString(getConstContext()).ToLocalChecked())
<< "to variant. Destination type: " << QMetaType::typeName(destTypeId);
//dest = val->ToVariant();
break;
}

View file

@ -1,8 +1,9 @@
# Declare dependencies
macro (setup_testcase_dependencies)
# V8TODO: replace most link_hifi_libraries with include_hifi_library_headers
# link in the shared libraries
link_hifi_libraries(shared test-utils script-engine networking)
link_hifi_libraries(shared test-utils script-engine networking octree avatars entities model-networking material-networking model-serializers graphics gpu ktx shaders hfm image procedural)
package_libraries_for_deployment()

View file

@ -12,6 +12,8 @@
#include "StatTracker.h"
#include "NodeList.h"
#include "../../../libraries/entities/src/EntityScriptingInterface.h"
//#include "../../../libraries/entities/src/EntityScriptingInterface.h"
QTEST_MAIN(ScriptEngineTests)
@ -43,7 +45,7 @@ void ScriptEngineTests::initTestCase() {
DependencyManager::set<ResourceRequestObserver>();
DependencyManager::set<StatTracker>();
DependencyManager::set<ScriptInitializers>();
DependencyManager::set<EntityScriptingInterface>(true);
QSharedPointer<ScriptEngines> ac = DependencyManager::get<ScriptEngines>();
QVERIFY(!ac.isNull());
@ -75,8 +77,8 @@ void ScriptEngineTests::scriptTest() {
QSharedPointer<ScriptEngines> ac = DependencyManager::get<ScriptEngines>();
QVERIFY(!ac.isNull());
QDir testScriptsDir("tests");
// TODO: can we execute test scripts in serial way rather than parallel
/*QDir testScriptsDir("tests");
QStringList testScripts = testScriptsDir.entryList(QStringList() << "*.js", QDir::Files);
testScripts.sort();
@ -84,14 +86,15 @@ void ScriptEngineTests::scriptTest() {
script = "tests/" + script;
qInfo() << "Running test script: " << script;
ac->loadOneScript(script);
}
}*/
ac->loadOneScript("tests/script-engine/tests/003_vector_math.js");
qDebug() << ac->getRunning();
while (true) {
// TODO: if I don't have infinite loop here, it exits before scripts finish. It also reports: QSignalSpy: No such signal: 'scriptCountChanged'
for (int n = 0; n > -1; n++) {
QSignalSpy spy(ac.get(), SIGNAL(scriptCountChanged));
spy.wait(3000000);
spy.wait(1000);
qDebug() << "Signal happened";
}
//spy.wait(5000);

View file

@ -0,0 +1,4 @@
print(JSON.stringify(this));
var v1 = { x: 1, y: 0, z: 0 };
var v2 = { x: 1, y: 0, z: 0 };
print(JSON.stringify(Vec3.sum(v1,v2)));