Challenge 2: Test a Subroutine From Course 1 — Possible Solution ==================================================================== # t/power.t use strict; use warnings; use Test::More; sub power { my ($base, $exponent) = @_; $exponent //= 2; return $base ** $exponent; } is(power(5), 25, 'power(5) defaults to squaring'); is(power(2, 8), 256, 'power(2, 8) uses explicit exponent'); is(power(3, 3), 27, 'power(3, 3) cubes correctly'); done_testing(); Running "prove t/power.t": t/power.t .. ok All tests successful. WHY THIS WORKS AS AN ANSWER ------------------------------ The power subroutine is reused entirely unchanged from Course 1, Chapter 7's own challenge solution — the //= defined-or default for $exponent and the ** exponentiation operator both work exactly as originally written; the only new thing here is testing it. is(power(5), 25, ...) reuses this chapter's own is() pattern to verify the DEFAULT-exponent path specifically — calling power with only one argument should fall back to squaring, and 5 ** 2 = 25 confirms that. is(power(2, 8), 256, ...) and is(power(3, 3), 27, ...) both test the EXPLICIT-exponent path with two different inputs — 2 ** 8 = 256 and 3 ** 3 = 27 — deliberately covering both branches of the subroutine's actual behavior (default vs. explicit) rather than just one, which is what makes this a genuinely useful test rather than a single coincidental check. done_testing(); reuses the chapter's own modern-style closing call, and running prove t/power.t against the file confirms all three assertions pass, verifying power() behaves correctly across its full range of intended use.