1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#[test]
fn parse_file() {
let input = include_str!("./input.tiny");
let file = tiny_v2::File {
header: tiny_v2::Header {
major_version: 2,
minor_version: 0,
namespace_a: "official",
namespace_b: "intermediary",
namespaces: vec!["named"],
properties: vec![
tiny_v2::Property {
key: "anotherProperty",
value: None,
},
tiny_v2::Property {
key: "someProperty",
value: Some("someValue"),
},
],
},
content: tiny_v2::Content {
class_section: vec![
tiny_v2::ClassSection {
class_name_a: "b",
class_name_b: Some("class_234"),
extra_ns_class_names: vec!["pkg/xy/AnotherClass"],
class_sub_sections: vec![tiny_v2::ClassSubSection::Method {
method_desc_a: "(Ljava/lang/String;)I",
method_name_a: "a",
method_name_b: Some("method_567"),
extra_ns_method_names: vec!["anotherMethod"],
method_sub_sections: Vec::new(),
}],
},
tiny_v2::ClassSection {
class_name_a: "a",
class_name_b: Some("class_123"),
extra_ns_class_names: vec!["pkg/SomeClass"],
class_sub_sections: vec![
tiny_v2::ClassSubSection::Method {
method_desc_a: "(III)V",
method_name_a: "a",
method_name_b: Some("method_456"),
extra_ns_method_names: vec!["someMethod"],
method_sub_sections: vec![
tiny_v2::MethodSubSection::Comment(
"Just a method for demonstrating the format.",
),
tiny_v2::MethodSubSection::Parameter {
lv_index: 3,
var_name_a: None,
var_name_b: Some("param_2"),
extra_ns_var_names: vec!["z"],
method_parameter_sub_sections: Vec::new(),
},
tiny_v2::MethodSubSection::Parameter {
lv_index: 2,
var_name_a: None,
var_name_b: Some("param_1"),
extra_ns_var_names: vec!["y"],
method_parameter_sub_sections: Vec::new(),
},
tiny_v2::MethodSubSection::Parameter {
lv_index: 1,
var_name_a: None,
var_name_b: Some("param_0"),
extra_ns_var_names: vec!["x"],
method_parameter_sub_sections: Vec::new(),
},
],
},
tiny_v2::ClassSubSection::Field {
field_desc_a: "[I",
field_name_a: "a",
field_name_b: Some("field_789"),
extra_ns_field_names: vec!["someField"],
field_sub_sections: Vec::new(),
},
],
},
],
},
};
let parsed = tiny_v2::from_str(input).unwrap();
assert_eq!(format!("{:?}", file), format!("{:?}", parsed));
}