NAME=text-funcs-mafia
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -f -l 3 bins/android/mafia 2>/dev/null
EOF
EXPECT=<<EOF
0x5b69c0 method.DateTime.compareTo
0x5b6aa4 method.Duration.compareTo
0x5b6b64 method.Duration.dyn:_
EOF
RUN

NAME=r2-funcs-mafia
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -r -f -l 2 bins/android/mafia 2>/dev/null
EOF
EXPECT=<<EOF
f method.DateTime.compareTo = 0x5b69c0
'@0x5b69c0'CC method.DateTime.compareTo
f method.Duration.compareTo = 0x5b6aa4
'@0x5b6aa4'CC method.Duration.compareTo
EOF
RUN

NAME=quiet-r2-funcs-mafia
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -qrf -l 2 bins/android/mafia 2>/dev/null
EOF
EXPECT=<<EOF
f method.DateTime.compareTo = 0x5b69c0
f method.Duration.compareTo = 0x5b6aa4
EOF
RUN

NAME=json-funcs-mafia
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -j -f -l 3 bins/android/mafia 2>/dev/null
EOF
EXPECT=<<EOF
[{"addr":5990848,"name":"method.DateTime.compareTo"},{"addr":5991076,"name":"method.Duration.compareTo"},{"addr":5991268,"name":"method.Duration.dyn:_"}]
EOF
RUN

# Regression guard: Code slots whose owner is a Class must be labeled
# stub.Allocate<ClassName>Stub, not shifted into a neighboring method name by
# the name-pool fallback. 0x5b6bf4 is the AllocateDurationStub in this fixture.
NAME=funcs-mafia-allocate-stub
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -f -q bins/android/mafia 2>/dev/null | grep -E '^0x5b6bf4 '
EOF
EXPECT=<<EOF
0x5b6bf4 stub.AllocateDurationStub
EOF
RUN

# The same address must NOT appear under any method.fn_* fallback name, which
# was the bug before the Code-owner-cid fix.
NAME=funcs-mafia-allocate-stub-not-fallback
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -f -q bins/android/mafia 2>/dev/null | grep -c '^0x5b6bf4 method.fn_'
EOF
EXPECT=<<EOF
0
EOF
RUN

# Type-test stubs (Code owner is an AbstractType) must be synthesized as
# stub.typetest_* rather than pulling from the name pool.
NAME=funcs-mafia-typetest-stub-present
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -f -q bins/android/mafia 2>/dev/null | grep -c ' stub.typetest_'
EOF
EXPECT=<<EOF
1277
EOF
RUN

# And there must be a healthy population of allocate stubs. On Dart 3.9.0 mafia
# the count is 4096; if it drops noticeably (e.g. back to zero) the owner-cid
# lookup has regressed.
NAME=funcs-mafia-allocate-stub-count
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -f -q bins/android/mafia 2>/dev/null | grep -c ' stub.Allocate'
EOF
EXPECT=<<EOF
4096
EOF
RUN
