From 4d71f70fd1cd0e11d9698e52411cd55045044c34 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 27 Nov 2023 14:05:25 -0500 Subject: Add assertions to check created red-black tree --- shape.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'shape.c') diff --git a/shape.c b/shape.c index 7fe21b1c58..c969b78da5 100644 --- a/shape.c +++ b/shape.c @@ -409,6 +409,14 @@ redblack_cache_ancestors(rb_shape_t * shape) if (shape->type == SHAPE_IVAR) { shape->ancestor_index = redblack_insert(parent_index, shape->edge_name, shape); + +#if RUBY_DEBUG + if (shape->ancestor_index) { + redblack_node_t *inserted_node = redblack_find(shape->ancestor_index, shape->edge_name); + RUBY_ASSERT(inserted_node); + RUBY_ASSERT(redblack_value(inserted_node) == shape); + } +#endif } else { shape->ancestor_index = parent_index; -- cgit v1.2.3