NAME=objc hello-objc not encrypted
FILE=bins/mach0/hello-objc
CMDS=ic
EXPECT=<<EOF
0x100001180 [0x100000da0 - 0x100000e20]    128 objc class 0 Person :: NSObject
0x100000da0 objc method 0      sayHello
0x100000df0 objc method 1      name
0x100000e20 objc method 2      setName:
0x00000000 objc field 0      isa
0x100001178 objc field 1      Person::(ivar)name
0x00000000 objc field 2      Person::(property)name
EOF
RUN

NAME=objc generics-objc
FILE=bins/mach0/generics-objc
CMDS=ic
EXPECT=<<EOF
0x100001120 [0x100000e70 - 0x100000e70]      0 objc class 0 MyCustomClass :: NSObject
0x100000e70 objc method 0      doSomethingWithGeneric:
EOF
RUN

NAME=objc method flags (ic ViewController)
FILE=bins/mach0/TestMethods
CMDS=ic ViewController
EXPECT=<<EOF
class ViewController
0x10000676c method ViewController      viewDidLoad
0x1000067d0 method ViewController      didReceiveMemoryWarning
0x1000067bc method ViewController c    thisIsAClassMethod
0x100006820 method ViewController c    andAnotherOne
EOF
RUN

NAME=objc method flags (icj)
FILE=bins/mach0/TestMethods
CMDS=icj~{[0].methods[2].flags[0]}
EXPECT=<<EOF
class
EOF
RUN

NAME=objc method flags (ic*)
FILE=bins/mach0/TestMethods
CMDS=ic*~thisIsAClassMethod
EXPECT=<<EOF
"f method.class.ViewController.thisIsAClassMethod = 0x1000067bc"
EOF
RUN

NAME=objc categories (mangled)
FILE=bins/mach0/Alamofire-stripped
CMDS=ic Alamofire.SessionDelegate(Alamofire)~?
EXPECT=<<EOF
4
EOF
RUN

NAME=infinite aao
FILE=bins/mach0/r2_hang_test
CMDS=aao
EXPECT=
RUN

NAME=objc categories (swift)
FILE=bins/mach0/TestSwiftObjc
CMDS=ic~ class
EXPECT=<<EOF
0x100003078 [0x100001ad0 - 0x100001ad0]      0 objc class 0 TestSwiftObjc.ThisIsASwiftClass(TEST) :: TestSwiftObjc.ThisIsASwiftClass
0x00001f34 [0x00001f34 - 0x00001f34]      0 swift class 0 ThisIsASwiftClass
0x1000031e8 [0x100001d80 - 0x100001d80]      0 objc class 0 TestSwiftObjc.ThisIsASwiftClass :: NSObject
EOF
RUN

NAME=aao hello-objc selrefs
FILE=bins/mach0/hello-objc
CMDS=<<EOF
aao
ax~?
ax~selref
EOF
EXPECT=<<EOF
89
              section.0.__TEXT.__text+20 0x100000db4 > DATA:r-- > 0x100001150 section.14.__DATA.__objc_selrefs
                                 main+15 0x100000e5f > DATA:r-- > 0x100001158 section.14.__DATA.__objc_selrefs+8
                                 main+45 0x100000e7d > DATA:r-- > 0x100001160 section.14.__DATA.__objc_selrefs+16
                                 main+64 0x100000e90 > DATA:r-- > 0x100001168 section.14.__DATA.__objc_selrefs+24
                                 main+86 0x100000ea6 > DATA:r-- > 0x100001158 section.14.__DATA.__objc_selrefs+8
                                main+116 0x100000ec4 > DATA:r-- > 0x100001160 section.14.__DATA.__objc_selrefs+16
                                main+135 0x100000ed7 > DATA:r-- > 0x100001168 section.14.__DATA.__objc_selrefs+24
EOF
RUN

NAME=aao hello-objc methods references
FILE=bins/mach0/hello-objc
CMDS=aao;ax~method
EXPECT=<<EOF
              section.0.__TEXT.__text+20 0x100000db4 > CODE:--x > 0x100000df0 method.Person.name
                                 main+45 0x100000e7d > CODE:--x > 0x100000e20 method.Person.setName:
                                main+116 0x100000ec4 > CODE:--x > 0x100000e20 method.Person.setName:
EOF
RUN

NAME=macOS arm64 with DYLD_CHAINED_PTR_64_OFFSET
FILE=bins/mach0/hello-macos-arm64-chained
CMDS=<<EOF
ic Test
ic~::
EOF
EXPECT=<<EOF
class Test
0x100003a7c method Test      init
0x100003acc method Test      methodWithoutArgs
0x100003b18 method Test      methodWithOneArg:
0x100003b68 method Test      methodWithTwoArgs:secondArg:
0x100003be0 method Test      methodWithReturn
0x100003aa0 method Test c    someStaticMethod
0x1000080f8 [0x100003a7c - 0x100003be0]    356 objc class 0 Test :: NSObject
0x1000080f0 objc field 1      Test::(ivar)someField
EOF
RUN

NAME=aao-crash because of truncated file
FILE=bins/mach0/objc-crash
CMDS=<<EOF
aao
ic
EOF
EXPECT=<<EOF
0x100001098 [0x100000c47 - 0x100000d1d]    214 objc class 0 Test :: NSObject
0x100000d1d objc method 0      sayHello2
0x100000cf7 objc method 1      sayHello:
0x100000cce objc method 2      sayHello3::
0x100000ca7 objc method 3      sayLong:
0x100000c6a objc method 4      init
0x100000c47 objc method 5 c    callMeNot
0x00000000 objc field 0      isa
0x100001270 objc field 1      Test::(ivar)num
EOF
RUN

NAME=macOS arm64e with DYLD_CHAINED_PTR_ARM64E_USERLAND24
FILE=bins/mach0/TestMacOS-arm64e
CMDS=<<EOF
ic AppDelegate~:1..
ic~::
EOF
EXPECT=<<EOF
0x100003238 method AppDelegate      applicationDidFinishLaunching:
0x100003288 method AppDelegate      applicationWillTerminate:
0x1000032d8 method AppDelegate      applicationSupportsSecureRestorableState:
0x100008a70 [0x10000313c - 0x100003184]     72 objc class 0 ViewController :: NSViewController
0x100008a98 [0x100003238 - 0x1000032d8]    160 objc class 0 AppDelegate :: NSObject
0x00000000 objc field 0      AppDelegate::(property)hash
0x00000000 objc field 1      AppDelegate::(property)superclass
0x00000000 objc field 2      AppDelegate::(property)description
0x00000000 objc field 3      AppDelegate::(property)debugDescription
EOF
RUN
