Has anyone ever tried to implement a form of script nesting within a QtScript/QtScriptEngine design. I'm trying to create a unit testing platform in which the entire system is driven via QtScript. Ideally i would create a global 'TestDriver' object and have all of the includes (individual tests) register themself with the global TestDriver before calling TestDriver.executeTests();
Imagine you have a test.qs and init.qs
init.qs :
var TestDriver = new TestDriver();
//include actually pauses interpretation of this QtScript and
// begins execution of test.qs -- making it like a C++ header
include(test.qs);
var w = test.somemethod(); // execute individual test
...
TestDriver.executeTests(); // execute all registered tests
var TestDriver = new TestDriver();
//include actually pauses interpretation of this QtScript and
// begins execution of test.qs -- making it like a C++ header
include(test.qs);
var w = test.somemethod(); // execute individual test
...
TestDriver.executeTests(); // execute all registered tests
To copy to clipboard, switch view to plain text mode
I'm thinking the only way to create the above is to either have a QtScript preprocessor which basically does the file inclusion before sending it to the ScriptEngine.evaluate method. However that is kind of messy.
Another idea is to nest a ScriptEngine within a script to allow a script to execute other scripts (i hope there is a better way to do this).
Bookmarks