File tree 1 file changed +45
-0
lines changed 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -37,4 +37,49 @@ fn parse_class_dummy() {
37
37
fn parse_class_intbox ( ) {
38
38
let mut file = File :: open ( "classes/IntBox.class" ) . unwrap ( ) ;
39
39
let class_file = ClassFile :: from_file ( & mut file) . unwrap ( ) ;
40
+
41
+ assert_eq ! ( "IntBox" , class_file. get_class_name( ) ) ;
42
+
43
+ assert_eq ! ( Some ( "IntBox.java" ) , class_file. get_source_file_name( ) ) ;
44
+
45
+ assert_eq ! ( 2 , class_file. methods. len( ) ) ;
46
+
47
+ let constructor = & class_file. methods [ 0 ] ;
48
+ let constructor_code = constructor. get_code ( & class_file) ;
49
+
50
+ use Bytecode :: * ;
51
+ assert_eq ! (
52
+ Some ( Code {
53
+ max_stack: 2 ,
54
+ max_locals: 2 ,
55
+ code: vec![
56
+ ( 0 , Aload_0 ) ,
57
+ ( 1 , Invokespecial ( 1 ) ) ,
58
+ ( 4 , Aload_0 ) ,
59
+ ( 5 , Iload_1 ) ,
60
+ ( 6 , Putfield ( 2 ) ) ,
61
+ ( 9 , Return ) ,
62
+ ] ,
63
+ exception_table: vec![ ] ,
64
+ } ) ,
65
+ constructor_code
66
+ ) ;
67
+
68
+ let get_value = & class_file. methods [ 1 ] ;
69
+ let get_value_code = get_value. get_code ( & class_file) ;
70
+
71
+ use Bytecode :: * ;
72
+ assert_eq ! (
73
+ Some ( Code {
74
+ max_stack: 1 ,
75
+ max_locals: 1 ,
76
+ code: vec![
77
+ ( 0 , Aload_0 ) ,
78
+ ( 1 , Getfield ( 2 ) ) ,
79
+ ( 4 , Ireturn ) ,
80
+ ] ,
81
+ exception_table: vec![ ] ,
82
+ } ) ,
83
+ get_value_code
84
+ ) ;
40
85
}
You can’t perform that action at this time.
0 commit comments