Skip to content

Commit 4488331

Browse files
committed
test(deep_causality_ast): increased test coverage.
Signed-off-by: Marvin Hansen <[email protected]>
1 parent f58aa67 commit 4488331

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

deep_causality_ast/tests/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
load("@rules_rust//rust:defs.bzl", "rust_test_suite")
22

33
rust_test_suite(
4-
name = "tests",
4+
name = "const_tree",
55
srcs = glob([
6-
"*_tests.rs",
6+
"const_tree/*_tests.rs",
77
]),
88
tags = [
99
"unit-test",

deep_causality_ast/tests/const_tree_tests.rs renamed to deep_causality_ast/tests/const_tree/const_tree_tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,21 @@ fn test_into_map() {
283283
assert_eq!(*tree_clone.children()[0].value(), 20);
284284
}
285285

286+
#[test]
287+
fn test_consuming_iterator_shared_arc() {
288+
let tree = ConstTree::with_children(1, vec![ConstTree::new(2), ConstTree::new(3)]);
289+
let tree_clone1 = tree.clone();
290+
let tree_clone2 = tree.clone(); // Ensure multiple references
291+
292+
// Call into_iter on one of the clones. This should trigger the Err branch.
293+
let values: Vec<_> = tree_clone1.into_iter().collect();
294+
assert_eq!(values, vec![1, 2, 3]);
295+
296+
// Verify that the other clone is still valid.
297+
assert_eq!(*tree_clone2.value(), 1);
298+
assert_eq!(tree_clone2.children().len(), 2);
299+
}
300+
286301
#[test]
287302
fn test_join() {
288303
// Create a tree of trees: ConstTree<ConstTree<i32>>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
* Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
4+
*/
5+
6+
#[cfg(test)]
7+
mod const_tree_tests;

deep_causality_ast/tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
* SPDX-License-Identifier: MIT
33
* Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
44
*/
5-
#[cfg(test)]
6-
mod const_tree_tests;
5+
6+
mod const_tree;

0 commit comments

Comments
 (0)