MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / main

Function main

debugger/tests/object.rs:14–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13#[tokio::test]
14async fn main() -> Result<()> {
15 let testcase = "object";
16 let (producer, events, allocations) = setup_2(testcase).await?;
17
18 rustc(&format!("testcases/{testcase}"));
19
20 Debugger::run(
21 DebuggerParams {
22 binary: format!("testcases/{testcase}.o"),
23 files: vec![
24 Default::default(),
25 SourceFile {
26 id: 1,
27 path: format!("testcases/{testcase}.rs"),
28 crate_name: testcase.into(),
29 modified: SystemTime::UNIX_EPOCH,
30 },
31 ],
32 breakpoints: vec![
33 Default::default(),
34 Breakpoint {
35 id: 1,
36 file_id: 1,
37 loc: LineColumn {
38 line: 50,
39 column: None,
40 },
41 loc_end: None,
42 breakpoint_type: BreakpointType::Breakpoint,
43 capture: VariableCapture::Only(vec!["man".to_owned(), "auto".to_owned()]),
44 },
45 ],
46 arguments: vec![],
47 },
48 producer.clone(),
49 );
50
51 producer.end().await?;
52 let payload = events.next().await?.message().into_bytes();
53 let event = EventStream::read_from(Bytes::from(payload));
54 match event {
55 Event::Breakpoint { locals, .. } => {
56 assert_eq!(locals.len(), 2);
57 for (i, (name, value)) in locals.iter().enumerate() {
58 match i {
59 0 => {
60 assert_eq!(name.as_str(), "man");
61 let json = serde_json::to_string(value).unwrap();
62 println!("{name} = {json}");
63 assert_eq!(
64 json,
65 r#"{"type":"Struct","typename":"object::Car","fields":{"brand":{"type":"String","typename":"&str","value":"Ford"},"engine":{"type":"Struct","typename":"object::Engine","fields":{"config":{"type":"Union","typeinfo":{"name":"object::EngineConfig","variants":["Inline","Vshape"]},"variant":"Inline","fields":{"i":{"type":"Prim","typename":"i32","value":4}}},"pistons":{"type":"Array","typename":"vec","data":[{"type":"Struct","typename":"object::Piston","fields":{"0":{"type":"Prim","typename":"u8","value":1}}},{"type":"Struct","typename":"object::Piston","fields":{"0":{"type":"Prim","typename":"u8","value":2}}},{"type":"Struct","typename":"object::Piston","fields":{"0":{"type":"Prim","typename":"u8","value":3}}},{"type":"Struct","typename":"object::Piston","fields":{"0":{"type":"Prim","typename":"u8","value":4}}}]}}},"gearbox":{"type":"Enum","typename":"object::Gearbox","variant":"Manual"}}}"#
66 );
67 }
68 1 => {
69 assert_eq!(name.as_str(), "auto");
70 if let RValue::Ref {
71 typename, value, ..

Callers

nothing calls this directly

Calls 8

setup_2Function · 0.85
rustcFunction · 0.85
into_bytesMethod · 0.80
nextMethod · 0.80
runFunction · 0.50
endMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected