Mock::Sub::Child(3pm)

πŸ“¦
version 1.09 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Mock::Sub::Child πŸ’–

okay so bestie, welcome to the Mock::Sub::Child page β€” it's the lil helper module that lives inside the Mock::Sub family, and it's the one doing the actual heavy lifting behind the scenes. πŸŽ€


✨ NAME ✨

Mock::Sub::Child β€” provides for Mock::Sub. that's it, that's the whole job. it's the child module, the supporting character, and honestly? it's giving main character energy anyway. πŸ‘‘


🌸 METHODS 🌸

okay so real talk: the full deets live over in the parent Mock::Sub module. what you're getting here is the briefing β€” the lil sparknotes version. if you want the whole saga, go read the parent. no cap. 🫢


πŸ¦‹ new

this method can only be called by the parent Mock::Sub module.

that's the rule. it's a members-only situation. πŸ™ˆ


πŸ¦‹ called

returns a bool telling you whether the mocked sub has been called yet. like, has it actually run or is it still sitting there being fake. πŸ’…


πŸ¦‹ called_count

returns an integer β€” the number of times the mocked sub has been called. counting the receipts, fr fr. πŸ”₯


πŸ¦‹ called_with

returns a list of the arguments the mocked sub was called with. so you can see exactly what got passed in. πŸ‘€


πŸ¦‹ mock

this method should only be called by the parent mock object.

bestie. you shouldn't be calling this. like genuinely. hands off. 🚫

πŸ¦‹ remock

re-mocks an unmocked sub back to the same subroutine it was originally mocked with. so if you un-did the mock and you're having regrets, this puts it right back where it was. the comeback era. ✨


πŸ¦‹ mocked_state

returns a bool β€” is the sub that this object represents currently mocked, or not. vibe check on the mock status. 🌈


πŸ¦‹ name

returns the name of the sub this object is mocking. just the name. the whole identity. πŸ’œ


πŸ¦‹ return_value

send in any values you want β€” list or scalar, your choice β€” and the mocked sub will return them when it's called. you're basically dictating the plot. 🎬


πŸ¦‹ side_effect

send in a code reference with any actions you want the mocked sub to perform after it's been called. so it does the return thing, and then it does your lil extra thing. obsessed. πŸ“


πŸ¦‹ reset

resets all state of the object back to default.

heads up: this does not unmock the sub. it's just a glow-up back to factory settings, the mock stays put. πŸ’€

πŸ¦‹ unmock

restores the original functionality of the mocked sub, and calls reset() on the object. so it's the full clean-up β€” your real sub is back, and the object is fresh. iconic behaviour, honestly. 🌟


🧚 bye bestie 🧚

that's the whole page!! slay. this came from perl v5.34.0, dated 2022-03-06, and it's the Mock::Sub::Child(3pm) page, in case you lost track of where you were. mwah, go mock responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from