From 3f2a5c8a070962f27e45a3cf5eb401f726b629a8 Mon Sep 17 00:00:00 2001 From: typosaurus Date: Sat, 25 Jul 2026 17:08:02 +0200 Subject: [PATCH 1/2] feat(nadia): Implement multiply and divide in calculator.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Outcome: done Changed: src/calculator.py:11-19 Verified by: `make verify` — exit 0, "verification passed" Findings: src/calculator.py now defines multiply(left: int, right: int) -> int and divide(left: int, right: int) -> int. divide raises ValueError('division by zero') when the divisor is zero, using integer floor division (//) to preserve the int return type. Open: none Confidence: high — both functions added, header preserved, no comments/docstrings, full type annotations, verify passed. Typosaurus-Run: d9404e45783a42b586e07fc0342eee5c Typosaurus-Node: 430bbdd86efb4f16a1c90433f0667e6b Typosaurus-Agent: @nadia Refs: #2 --- src/__pycache__/calculator.cpython-315.pyc | Bin 0 -> 1391 bytes src/calculator.py | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/__pycache__/calculator.cpython-315.pyc diff --git a/src/__pycache__/calculator.cpython-315.pyc b/src/__pycache__/calculator.cpython-315.pyc new file mode 100644 index 0000000000000000000000000000000000000000..188bff0cbf453b74ab1c50aec4fb7939e25a108f GIT binary patch literal 1391 zcmd5+&ubG=5T3WYNw#fFQx%gy)!INI80~fO8O{e9G#h zGiGyCRpz*=oD*6E&Wt1eV61L;lfVGph&p?xLNSZYAq+J%$b%VD5pP&qL(V{=+pddC zgwzS_8o;-O#ZQfqQNlcZ{v9HbW567#n!q_SDOoBeMTk;7Klz=N!^bHrQOZiBSV=>@ zo)uMbbRtO=us{YESrtkB!igEhyAo|j;vJgeAdsp3=X7wP;O&b@uD>m3dMbaoZ6^+- zzaR9lLhIE({)^jkZZ29v7nM^Wb$Dyc=4eZq<1OX9ntU#1RnX}Z(iA(e@s=8%3VIo~ zXU_sXD^I4lEvRiS5lT;pcEa@ai?08{kNmK^vfEqfdl*uK&o}KL_Ff={c(r=6yutPG z9_?0lxJ!VVDwqE(4*K5<>s!g$yERV literal 0 HcmV?d00001 diff --git a/src/calculator.py b/src/calculator.py index e41739a..983e401 100644 --- a/src/calculator.py +++ b/src/calculator.py @@ -6,3 +6,13 @@ def add(left: int, right: int) -> int: def subtract(left: int, right: int) -> int: return left - right + + +def multiply(left: int, right: int) -> int: + return left * right + + +def divide(left: int, right: int) -> int: + if right == 0: + raise ValueError('division by zero') + return left // right From 8f7f09f44ad50acbb9e7a5598555e89bd54b35ab Mon Sep 17 00:00:00 2001 From: typosaurus Date: Sat, 25 Jul 2026 17:08:53 +0200 Subject: [PATCH 2/2] test(sveta): Write tests for multiply and divide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Outcome: done Changed: tests/test_calculator.py:1-65, Makefile:1 Verified by: `make verify` — exit 0, "Ran 16 tests in 0.000s ... OK" Findings: tests/test_calculator.py exists with 16 test methods covering add, subtract, multiply (positive/negative/zero), divide (positive/negative/zero-numerator/floor), and divide-by-zero ValueError. make verify now runs both compileall (src + tests) and unittest discover, all passing. Open: none Confidence: high — all 16 tests pass; coverage spans all acceptance criteria including multiply edge cases (positive, negative, zero) and divide edge cases (positive, negative, zero numerator, divide-by-zero). Typosaurus-Run: d9404e45783a42b586e07fc0342eee5c Typosaurus-Node: 00f8d57fc2964dc9bf5ae68ad25a6e18 Typosaurus-Agent: @sveta Refs: #2 --- Makefile | 2 +- .../test_calculator.cpython-315.pyc | Bin 0 -> 6958 bytes tests/test_calculator.py | 58 ++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/__pycache__/test_calculator.cpython-315.pyc create mode 100644 tests/test_calculator.py diff --git a/Makefile b/Makefile index 6c607e1..0ddaaf7 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ verify: - @python3 -m compileall -q src && echo "verification passed" + @python3 -m compileall -q src tests && python3 -m unittest discover -s tests -q && echo "verification passed" diff --git a/tests/__pycache__/test_calculator.cpython-315.pyc b/tests/__pycache__/test_calculator.cpython-315.pyc new file mode 100644 index 0000000000000000000000000000000000000000..328beb24852169c3cd6884ea73d596d628eff3b5 GIT binary patch literal 6958 zcmcgx-EY%Y6u)*p>XxST`-^^r7Fv>aWo4Dv0I|ZxRwfh`3sp!fvE0O^nbM?O-=M)$ zA13W(4?HpzZQ0YppRxa7h^b809`-i%4b+Juq>Y_(oWxGz20FF96~{L}pV;^O{JX~| zhq;ze6N8a^lKkqYAY%#qP#S^aWP2Va>nzSx=_(U=l&?y2vXJL|!Z+s^{<(k%46`nF zoTkg#qFxBtS@j zkRTyJLK+BB2x%ask&q@r6he*=(o9GrAt6Fq2x%hZC?Tzc93iBQkaj|v3F#oDlaLT0 zU4(QK(n3fNA-#kgC8Up#enMIaIY!6;A#H>V5;8^91GjPc!*3W%0y@C1ODn*%DxZeO`PjFG z-d2zsBF8ha$1EaS!R0Jp)rA$(v_x7r&15PeG|fcEk#(zAz@5$0XthLn0aI)DtY%Hq zGnuT=g`sKIvC0)rxlf{a%}y|{*4Yk|0^={xJUl^%ZNM1?gcBT~a12PZo+uo!xCr*+-%#m?Wd5$ zslp99II93J8haF|>f%x@CjfifNBs7--}?8>n>Smp!SGSIM-8LLDjCffw{>JxOB>6= ziq@sI!WSboYxO&l*Efa>Bb&;5PP7NCU)qJWoG15(^SG>*Q^BsB|ATZ#k#0}U2X^6{ zr*5wZYvSEVCufSami6O#^{`p*!)V9Rl=l{Vps{CFJG{oLGDJz$JOWqdr_p#aT&3!z ztXR=Xa(#=cD||636OH>-*P9>7FFoyx6s8YT)&sB#cPg>pb%oA-O3Tct8{(`oEkj1e zEgSQux~Edi_YI!4lgC(H9hdzuE*?fx7R~`Dh+(*y#|w^Xu}NnY;6-DP@{I=^{+yYe zlsN_KsaPs9wel;A=&|#`_}h6TM-1z5i5$T@o<&oBbi^2#y^;n$)=HvtW<}CI!aI19 zR;4}Ky2zYWUwdUg3LuP^F9&eI+B*q1b89b(+c%o0ms8YP1$fceD~-Y3E7pj-g;$G} z>MJZ?YpQ`x+RXN^S*N-h^-^G!69!gOzjo)P{Pe~^{?4Wnae_NwicjH6T<`y4qMX^E zMERDQ>ocU-e)ZEU>T@ra``j#-UQ2e;JXMG43Qvr(rrzq#%lS(ig9Z68e=khnN^1H3 zbbt7c2kX{bHs4eT?9O+;C*O8b0eFjU!9 zYnAKT@-GONnu+4KtGS|jvg)b1!V@F%RP*J-{`EVJD{-m0n4l?p>_dWXsGFc0;N~&z z$#R=p!^`PxmRsRE(j^a!g@1vjtdj%Iy)&Nd6(|?%1ABFfR8CcbCv_Fup9-r?Zq?w} zMYQT||4LU3?QqG&%F65kLp?)ZU{-p;(B`3ifJf)4f)5SUj}P017EE?+8)Dyx#!OKS z=OsZ2%D;6PUDw_!}-3#O6iUh4@yUD5Q zDbp~mrUgBnGp=x+<(w)W>@8V7Q*f)%_&Q;%3HUZN@sMUqPOMU&aV%`NLOa}hZt0#z zrR7MSU03v>2Zy;6el>>Lo`r^@{%CH0F#SOP?%IxzwM_i!>Y%DW zE`GoGv@iPWrQ|Xxfr7DGOrDr>{-c08?RJCMkCCDbEyY$5wBspyY + +import unittest + +from src.calculator import add, subtract, multiply, divide + + +class TestCalculator(unittest.TestCase): + + def test_add(self) -> None: + self.assertEqual(add(2, 3), 5) + + def test_subtract(self) -> None: + self.assertEqual(subtract(5, 3), 2) + + def test_multiply_positive(self) -> None: + self.assertEqual(multiply(2, 3), 6) + + def test_multiply_negative_left(self) -> None: + self.assertEqual(multiply(-2, 3), -6) + + def test_multiply_negative_right(self) -> None: + self.assertEqual(multiply(2, -3), -6) + + def test_multiply_both_negative(self) -> None: + self.assertEqual(multiply(-2, -3), 6) + + def test_multiply_zero_left(self) -> None: + self.assertEqual(multiply(0, 5), 0) + + def test_multiply_zero_right(self) -> None: + self.assertEqual(multiply(5, 0), 0) + + def test_multiply_both_zero(self) -> None: + self.assertEqual(multiply(0, 0), 0) + + def test_divide_positive(self) -> None: + self.assertEqual(divide(6, 3), 2) + + def test_divide_negative_left(self) -> None: + self.assertEqual(divide(-6, 3), -2) + + def test_divide_negative_right(self) -> None: + self.assertEqual(divide(6, -3), -2) + + def test_divide_both_negative(self) -> None: + self.assertEqual(divide(-6, -3), 2) + + def test_divide_floor(self) -> None: + self.assertEqual(divide(7, 3), 2) + + def test_divide_zero_numerator(self) -> None: + self.assertEqual(divide(0, 5), 0) + + def test_divide_by_zero(self) -> None: + with self.assertRaises(ValueError) as cm: + divide(5, 0) + self.assertEqual(str(cm.exception), 'division by zero')