fork of https://github.com/tree-sitter/tree-sitter-graph
at main 883 B view raw
1// -*- coding: utf-8 -*- 2// ------------------------------------------------------------------------------------------------ 3// Copyright © 2022, tree-sitter authors. 4// Licensed under either of Apache License, Version 2.0, or MIT license, at your option. 5// Please see the LICENSE-APACHE or LICENSE-MIT files in this distribution for license details. 6// ------------------------------------------------------------------------------------------------ 7 8use tree_sitter_graph::Variables; 9 10#[test] 11fn can_create_nested_variables() { 12 fn f<'a>(v: &'a Variables<'a>) -> Variables<'a> { 13 let mut w = Variables::nested(v); 14 w.add("bar".into(), 2.into()).expect("Failed to set bar"); 15 w 16 } 17 let mut v = Variables::new(); 18 v.add("foo".into(), 1.into()).expect("Failed to set foo"); 19 let w = f(&v); 20 w.get(&"foo".into()).expect("Failed to get foo"); 21}