@@ -2242,6 +2242,12 @@ impl<'a> std::fmt::Display for FunctionPrinter<'a> {
2242
2242
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
2243
2243
let fun = & self . fun ;
2244
2244
let iseq_name = iseq_get_location ( fun. iseq , 0 ) ;
2245
+ // In tests, strip the line number for builtin ISEQs to make tests stable across line changes
2246
+ let iseq_name = if cfg ! ( test) && iseq_name. contains ( "@<internal:" ) {
2247
+ iseq_name[ ..iseq_name. rfind ( ':' ) . unwrap ( ) ] . to_string ( )
2248
+ } else {
2249
+ iseq_name
2250
+ } ;
2245
2251
writeln ! ( f, "fn {iseq_name}:" ) ?;
2246
2252
for block_id in fun. rpo ( ) {
2247
2253
write ! ( f, "{block_id}(" ) ?;
@@ -5003,7 +5009,7 @@ mod tests {
5003
5009
#[ test]
5004
5010
fn test_invokebuiltin_delegate_annotated ( ) {
5005
5011
assert_method_hir_with_opcode ( "Float" , YARVINSN_opt_invokebuiltin_delegate_leave , expect ! [ [ r#"
5006
- fn Float@<internal:kernel>:197:
5012
+ fn Float@<internal:kernel>:
5007
5013
bb0(v0:BasicObject, v1:BasicObject, v2:BasicObject, v3:BasicObject):
5008
5014
v6:Flonum = InvokeBuiltin rb_f_float, v0, v1, v2
5009
5015
Jump bb1(v0, v1, v2, v3, v6)
@@ -5015,7 +5021,7 @@ mod tests {
5015
5021
#[ test]
5016
5022
fn test_invokebuiltin_cexpr_annotated ( ) {
5017
5023
assert_method_hir_with_opcode ( "class" , YARVINSN_opt_invokebuiltin_delegate_leave , expect ! [ [ r#"
5018
- fn class@<internal:kernel>:20:
5024
+ fn class@<internal:kernel>:
5019
5025
bb0(v0:BasicObject):
5020
5026
v3:Class = InvokeBuiltin _bi20, v0
5021
5027
Jump bb1(v0, v3)
@@ -5031,7 +5037,7 @@ mod tests {
5031
5037
assert ! ( iseq_contains_opcode( iseq, YARVINSN_opt_invokebuiltin_delegate ) , "iseq Dir.open does not contain invokebuiltin" ) ;
5032
5038
let function = iseq_to_hir ( iseq) . unwrap ( ) ;
5033
5039
assert_function_hir ( function, expect ! [ [ r#"
5034
- fn open@<internal:dir>:184:
5040
+ fn open@<internal:dir>:
5035
5041
bb0(v0:BasicObject, v1:BasicObject, v2:BasicObject, v3:BasicObject, v4:BasicObject):
5036
5042
v5:NilClass = Const Value(nil)
5037
5043
v8:BasicObject = InvokeBuiltin dir_s_open, v0, v1, v2
@@ -5045,7 +5051,7 @@ mod tests {
5045
5051
assert ! ( iseq_contains_opcode( iseq, YARVINSN_opt_invokebuiltin_delegate_leave ) , "iseq GC.enable does not contain invokebuiltin" ) ;
5046
5052
let function = iseq_to_hir ( iseq) . unwrap ( ) ;
5047
5053
assert_function_hir ( function, expect ! [ [ r#"
5048
- fn enable@<internal:gc>:55:
5054
+ fn enable@<internal:gc>:
5049
5055
bb0(v0:BasicObject):
5050
5056
v3:BasicObject = InvokeBuiltin gc_enable, v0
5051
5057
Jump bb1(v0, v3)
@@ -5060,7 +5066,7 @@ mod tests {
5060
5066
assert ! ( iseq_contains_opcode( iseq, YARVINSN_invokebuiltin ) , "iseq GC.start does not contain invokebuiltin" ) ;
5061
5067
let function = iseq_to_hir ( iseq) . unwrap ( ) ;
5062
5068
assert_function_hir ( function, expect ! [ [ r#"
5063
- fn start@<internal:gc>:36:
5069
+ fn start@<internal:gc>:
5064
5070
bb0(v0:BasicObject, v1:BasicObject, v2:BasicObject, v3:BasicObject, v4:BasicObject):
5065
5071
v6:FalseClass = Const Value(false)
5066
5072
v8:BasicObject = InvokeBuiltin gc_start_internal, v0, v1, v2, v3, v6
0 commit comments