MCPcopy Create free account
hub / github.com/Doctave/dossier / readonly_parameter

Function readonly_parameter

dossier-ts/src/function.rs:332–360  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

330
331 #[test]
332 fn readonly_parameter() {
333 let code = indoc! {r#"
334 function foo(bar: readonly string) {}
335 "#};
336
337 let tree = init_parser().parse(code, None).unwrap();
338 let mut cursor = tree.root_node().walk();
339 walk_tree_to_function(&mut cursor);
340
341 let symbol = parse(
342 &cursor.node(),
343 &mut ParserContext::new(Path::new("index.ts"), code),
344 )
345 .unwrap();
346
347 let function = symbol.kind.as_function().unwrap();
348
349 let params = function.parameters().collect::<Vec<_>>();
350 assert_eq!(params.len(), 1);
351
352 let bar = params[0].kind.as_parameter().unwrap();
353 assert_eq!(bar.identifier, "bar");
354 assert!(bar.readonly);
355 assert!(!bar.optional);
356 assert_eq!(
357 bar.parameter_type().unwrap().kind.as_type().unwrap(),
358 &Type::Predefined("string".to_owned())
359 );
360 }
361
362 #[test]
363 fn generics() {

Callers

nothing calls this directly

Calls 7

walk_tree_to_functionFunction · 0.85
init_parserFunction · 0.70
parseFunction · 0.70
parseMethod · 0.45
as_functionMethod · 0.45
parametersMethod · 0.45
as_parameterMethod · 0.45

Tested by

no test coverage detected