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 :
Qt Code:
  1. var TestDriver = new TestDriver();
  2.  
  3. //include actually pauses interpretation of this QtScript and
  4. // begins execution of test.qs -- making it like a C++ header
  5. include(test.qs);
  6.  
  7. var w = test.somemethod(); // execute individual test
  8. ...
  9. 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).