Some improvements to math::sqrt (#6853)
* Treat number as any rather than default Signed-off-by: Nick Cameron <nrc@ncameron.org> * Don't square root negative numbers Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -2694,4 +2694,13 @@ sketch001 = startSketchOn(XY)
|
||||
let ast = r#"foo = tan(0): number(rad) - 4deg"#;
|
||||
parse_execute(ast).await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn neg_sqrt() {
|
||||
let ast = r#"bad = sqrt(-2)"#;
|
||||
|
||||
let e = parse_execute(ast).await.unwrap_err();
|
||||
// Make sure we get a useful error message and not an engine error.
|
||||
assert!(e.message().contains("sqrt"), "Error message: '{}'", e.message());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user