fix: deprecate child_containing_descendant and add child_with_descendant instead
This commit is contained in:
parent
2e3504a422
commit
934a2814fd
5 changed files with 91 additions and 30 deletions
|
|
@ -169,24 +169,22 @@ fn test_node_child() {
|
|||
assert_eq!(tree.root_node().parent(), None);
|
||||
|
||||
assert_eq!(
|
||||
tree.root_node()
|
||||
.child_containing_descendant(null_node)
|
||||
.unwrap(),
|
||||
tree.root_node().child_with_descendant(null_node).unwrap(),
|
||||
array_node
|
||||
);
|
||||
assert_eq!(
|
||||
array_node.child_containing_descendant(null_node).unwrap(),
|
||||
array_node.child_with_descendant(null_node).unwrap(),
|
||||
object_node
|
||||
);
|
||||
assert_eq!(
|
||||
object_node.child_containing_descendant(null_node).unwrap(),
|
||||
object_node.child_with_descendant(null_node).unwrap(),
|
||||
pair_node
|
||||
);
|
||||
assert_eq!(
|
||||
pair_node.child_containing_descendant(null_node).unwrap(),
|
||||
pair_node.child_with_descendant(null_node).unwrap(),
|
||||
null_node
|
||||
);
|
||||
assert_eq!(null_node.child_containing_descendant(null_node), None);
|
||||
assert_eq!(null_node.child_with_descendant(null_node), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -288,16 +286,14 @@ fn test_parent_of_zero_width_node() {
|
|||
assert_eq!(block_parent.to_string(), "(function_definition name: (identifier) parameters: (parameters (identifier)) body: (block))");
|
||||
|
||||
assert_eq!(
|
||||
root.child_containing_descendant(block).unwrap(),
|
||||
root.child_with_descendant(block).unwrap(),
|
||||
function_definition
|
||||
);
|
||||
assert_eq!(
|
||||
function_definition
|
||||
.child_containing_descendant(block)
|
||||
.unwrap(),
|
||||
function_definition.child_with_descendant(block).unwrap(),
|
||||
block
|
||||
);
|
||||
assert_eq!(block.child_containing_descendant(block), None);
|
||||
assert_eq!(block.child_with_descendant(block), None);
|
||||
|
||||
let code = "<script></script>";
|
||||
parser.set_language(&get_language("html")).unwrap();
|
||||
|
|
@ -477,24 +473,22 @@ fn test_node_named_child() {
|
|||
assert_eq!(tree.root_node().parent(), None);
|
||||
|
||||
assert_eq!(
|
||||
tree.root_node()
|
||||
.child_containing_descendant(null_node)
|
||||
.unwrap(),
|
||||
tree.root_node().child_with_descendant(null_node).unwrap(),
|
||||
array_node
|
||||
);
|
||||
assert_eq!(
|
||||
array_node.child_containing_descendant(null_node).unwrap(),
|
||||
array_node.child_with_descendant(null_node).unwrap(),
|
||||
object_node
|
||||
);
|
||||
assert_eq!(
|
||||
object_node.child_containing_descendant(null_node).unwrap(),
|
||||
object_node.child_with_descendant(null_node).unwrap(),
|
||||
pair_node
|
||||
);
|
||||
assert_eq!(
|
||||
pair_node.child_containing_descendant(null_node).unwrap(),
|
||||
pair_node.child_with_descendant(null_node).unwrap(),
|
||||
null_node
|
||||
);
|
||||
assert_eq!(null_node.child_containing_descendant(null_node), None);
|
||||
assert_eq!(null_node.child_with_descendant(null_node), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue