runEval method
Future<D4rtTestResult>
runEval(
- BridgeConfig config,
- String initScriptFile,
- String expressionFile, {
- Duration? timeout,
Generate bridges and evaluate an expression file, capturing results.
- Runs the bridge generator in-memory with
config. - Compiles and runs the test runner with
--test-eval <initScriptFile> <expressionFile>. The init script sets up the D4rt environment (imports, variables), then the expression file is evaluated usingeval(). - Returns a D4rtTestResult.
Both file paths are relative to projectPath or absolute.
Example:
final result = await tester.runEval(
config,
'scripts/init.dart',
'scripts/eval_expressions.dart',
);
expect(result.success, isTrue);
Implementation
Future<D4rtTestResult> runEval(
BridgeConfig config,
String initScriptFile,
String expressionFile, {
Duration? timeout,
}) async {
// Generate and compile bridges
final ok = await prepareBridges(config);
if (!ok) {
return D4rtTestResult(
timedOut: false,
exceptions: _lastGenerationErrors!,
exitCode: -1,
);
}
// Run using compiled binary
return _runBinary([
'--test-eval',
initScriptFile,
expressionFile,
], timeout ?? defaultTimeout);
}