mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 22:34:09 +00:00
Shapes: shape.circleThroughPoints refuses a null anchors
This commit is contained in:
@@ -425,7 +425,7 @@ fn circle_through_points(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
None => selected_anchor_points(s)?.ok_or_else(|| bad(C, "direct-select two or three anchor points, or give `points`"))?,
|
||||
};
|
||||
let key = "anchors";
|
||||
let at_points = match p.get(key).filter(|v| !v.is_null()).map(Value::as_str) {
|
||||
let at_points = match p.get(key).map(Value::as_str) {
|
||||
None | Some(Some("standard")) => false,
|
||||
Some(Some("points")) => true,
|
||||
Some(_) => return Err(bad(C, format!("`{key}` must be one of {}", "standard, points"))),
|
||||
|
||||
@@ -226,7 +226,7 @@ fn anchors_at_the_points_puts_an_anchor_at_each_point() {
|
||||
assert_eq!(anchors.len(), 4, "{anchors:?}");
|
||||
assert_eq!((anchors[0], anchors[2]), (Point::new(0.0, 0.0), Point::new(100.0, 0.0)));
|
||||
let (count, undo) = (object_count(&s), undo_len(&s));
|
||||
for bad in [json!("corners"), json!(true), json!(4)] {
|
||||
for bad in [json!("corners"), json!(true), json!(4), Value::Null] {
|
||||
let e = s.execute(C, &json!({ "points": [[0, 0], [100, 0]], "anchors": bad })).unwrap_err().to_string();
|
||||
assert!(e.contains("`anchors` must be one of standard, points"), "{e}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user