refactor: cleanup decision tree (#32)

* refactor: cleanup decision tree;

* remove unused error; add graph tests;

* add test and fix for depth limit
This commit is contained in:
stefan-gorules
2023-05-02 18:07:06 +02:00
committed by GitHub
parent 32b08ba57b
commit 9dcb694c8c
13 changed files with 466 additions and 434 deletions
+7 -13
View File
@@ -66,22 +66,17 @@ impl Script {
let Some(src_script) = v8::Script::compile(tc_scope, src, None) else {
let exception = tc_scope.exception().context("Failed to load script")?;
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope).to_string()));
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope)));
};
match src_script.run(tc_scope) {
Some(..) => {}
None => {
let exception = tc_scope.exception().unwrap();
return Err(anyhow!(exception
.to_rust_string_lossy(tc_scope)
.to_string()));
}
if let None = src_script.run(tc_scope) {
let exception = tc_scope.exception().unwrap();
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope)));
}
let Some(js_script) = v8::Script::compile(tc_scope, js_src, None) else {
let exception = tc_scope.exception().context("Failed to load script")?;
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope).to_string()));
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope)));
};
let Some(result) = js_script.run(tc_scope) else {
@@ -90,10 +85,9 @@ impl Script {
}
let exception = tc_scope.exception().context("Failed to run loaded script")?;
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope).to_string()));
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope)));
};
let res: EvaluateResponse = serde_v8::from_v8(tc_scope, result).unwrap();
Ok(res)
serde_v8::from_v8(tc_scope, result).context("Failed to parse function result")
}
}