MCPcopy Create free account
hub / github.com/hashintel/hash / context

Function context

libs/error-stack/tests/test_frame.rs:95–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93
94#[test]
95fn context() {
96 let mut report = create_report().change_context(ContextA(10));
97
98 let flow = report.frames_mut(|frame| {
99 assert_eq!(frame.sources().len(), 1);
100 assert!(frame.is::<Location>(), "not a location frame");
101
102 let source = frame
103 .sources_mut()
104 .first_mut()
105 .expect("no source frame found");
106
107 let context = source
108 .downcast_mut::<ContextA>()
109 .expect("not a context frame");
110 context.0 += 10;
111 ControlFlow::Break(())
112 });
113 assert!(flow.is_break(), "No location frame found");
114
115 let frame = report.frames().next().expect("No location frame found");
116 assert_eq!(frame.sources().len(), 1);
117 let source = frame.sources().first().expect("no source frame found");
118 let context = source
119 .downcast_ref::<ContextA>()
120 .expect("not a context frame");
121 assert_eq!(context.0, 20);
122}
123
124#[test]
125fn type_id() {

Callers 1

change_context_lazyMethod · 0.50

Calls 9

ContextAClass · 0.85
frames_mutMethod · 0.80
sources_mutMethod · 0.80
framesMethod · 0.80
sourcesMethod · 0.80
create_reportFunction · 0.70
change_contextMethod · 0.45
expectMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected