Multiply numbers #3
Labels
No labels
aira:blocked
aira:cancelled
aira:ci
aira:done
aira:implementing
aira:merging
aira:plan-review
aira:planning
aira:qa
aira:queued
aira:ready
aira:review
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/web-calculator-3#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add multiplication.
Requirements
op=multiplyreturnsa * b.×button. Pressing6,×,7,=shows42.Acceptance criteria
/api/calculate?a=6&b=7&op=multiplyreturns{"result":42}./api/calculate?a=-2&b=0.5&op=multiplyreturns{"result":-1}.addandsubtractstill work; bad input still returns 400.Aira · queued
Aira picked up this task. Branch
aira/3-multiply-numbers.Aira · planning
Orchestrator thread started (composer-2.5). Planning on
aira/3-multiply-numbers.T3 thread:
mcp:launch:5173a26954af44cee42675ec290efcac5c9d3c251cb0cc44928a98acdf969553Aira · Plan (round 1) at
fb8bebd0Wrote docs/plans/issue-3.md (multiply API op=multiply, × UI button, tests, risks); committed and pushed to aira/3-multiply-numbers.
docs/plans/issue-3.md
Issue #3: Multiply numbers
Goal
Extend the calculator with multiplication end-to-end: handle
op=multiplyinlib/calculator.jsasa * b, expose it through the existingGET /api/calculateroute (unchanged contract), and add a×(U+00D7 multiplication sign) keypad button that behaves like+and−. The flow6,×,7,=must display42via the API. Addition, subtraction, validation, and error responses remain unchanged.Acceptance criteria
GET /api/calculate?a=6&b=7&op=multiplyreturns HTTP 200 with body{"result":42}.GET /api/calculate?a=-2&b=0.5&op=multiplyreturns HTTP 200 with body{"result":-1}.GET /api/calculatewithop=addandop=subtractstill returns correct results; missing, empty, or non-numeric operands and unknownopstill return HTTP 400 with anerrorstring./includes a multiply button; pressing operands and=with multiplication selected shows the product returned by the API (same pattern as addition and subtraction).Design
Calculator module (
lib/calculator.js)calculate(a, b, op)with a branch forop === 'multiply': computex * yafter existingparseNumberon both operands.addandsubtract: if the result is not finite, throwresult out of range.parseNumberunchanged; unknown-op path acceptsadd,subtract, andmultiplyonly; all other ops throwunknown operation.HTTP layer (
server.js)handleCalculatealready passesopthrough tocalculate; new operation is recognized only in the module layer.UI (
public/index.html)×(multiplication sign) withdata-key="×"consistent with+and−.+,−, or×, commit the current operand asleftand setpendingOptoadd,subtract, ormultiplyrespectively.=, continue callingfetchwithopfrompendingOp(existing guardif (left === null || pendingOp === null) return).6→×→7→=→GET /api/calculate?a=6&b=7&op=multiply→ display42.C, decimal input, addition, and subtraction flows from prior issues.Keypad layout
−above1column and+above3column (row with digits 1–3). Place×on an open cell without breaking digit placement—e.g. add a row or swap a cell adjacent to+and−following the same styling as other operators.data-key="×"is present in served HTML.Test layout
test/calculator.test.jsmultiplyand regressions onadd/subtract/ unknown optest/server.test.jstest/ui.test.jsFiles to change
lib/calculator.jsmultiplybranch incalculateserver.jspublic/index.htmlpendingOpmapping on operator keystest/calculator.test.jstest/server.test.jstest/ui.test.js×toREQUIRED_KEYSDo not edit
.forgejo/workflows/ci.ymlfor this task.Test plan
Unit (
test/calculator.test.js)calculate('6', '7', 'multiply')→42calculate('-2', '0.5', 'multiply')→-1calculate('2', '3', 'add')→5calculate('2', '5', 'subtract')→-3calculate('1', '2', 'pow')throwsout of rangeaddHTTP API (
test/server.test.js)?a=6&b=7&op=multiply→ 200,result: 42?a=-2&b=0.5&op=multiply→ 200,result: -1?a=2&b=3&op=add→ 200,result: 5?a=2&b=5&op=subtract→ 200,result: -3?a=1&b=2&op=pow→ 400,errorstringa/b, non-numeric, empty) withop=multiplywhere applicableAll existing server tests (health, index, 404, add/subtract errors) must still pass.
UI / page (
test/ui.test.js)REQUIRED_KEYSto include×;GET /HTML must includedata-key="×"./api/calculateremains valid.6×7=→42in browser (automation out of scope fornode --test).Local gate
npm testbefore every push; all tests green.Risks
pendingOpmapping misses×+/−; code review against AC4 flow×(U+00D7) vsxor*in testsdata-key="×"; API uses stringmultiply×beside existing operators; keep digit grid intact0.1 * 0.2)Number.isFinitecheck; optional overflow unit testImplementation order
lib/calculator.jsmultiply branch + unit tests intest/calculator.test.jstest/server.test.js(module already wired)public/index.htmlmultiply button and operator mapping +test/ui.test.jsnpm test, then pushaira/3-multiply-numbersAttachment: plan-3-r1.md
Aira · plan review
Plan pushed at
fb8bebd0; independent Dodik plan review started.Aira · dodik-plan PASS on
fb8bebd0The plan maps every task requirement to a numbered, testable acceptance criterion and fits the current code: multiply is a new branch in calculate after parseNumber, the existing GET /api/calculate route already forwards op, and the keypad only needs a × button that sets pendingOp to multiply. Unit and HTTP tests prove 67=42, -20.5=-1, add/subtract regressions, and 400 responses for bad input; the page test requires data-key="×". Scope stays inside the calculator module, the page, and the three test files. The keypad sentence misstates where − and + sit on a full 4×4 grid; placement can still follow the plan’s add-a-row guidance, so this does not block the work.
Checks performed
Attachment: dodik-plan-fb8bebd0.json
Aira · implementing
Plan approved by Dodik at
fb8bebd0. Implementation started.Aira · ci
Ready for review at
d1f866de(PR #11). Waiting for CI.Implemented multiply in lib/calculator.js, × button and pendingOp in public/index.html, and calculator/server/ui tests; npm test 27/27 pass; pushed to aira/3-multiply-numbers.
Aira · CI passed on
d1f866deAira · review
CI is green on
d1f866de. Independent Dodik and code review started.Aira · dodik PASS on
d1f866deMultiplication is implemented end to end and matches the approved plan. GET /api/calculate with op=multiply returns 42 for 6 and 7 and -1 for -2 and 0.5; add, subtract, and 400 error handling still work. The page has a × button, and pressing 6, ×, 7, = shows 42. The full suite passes (27 tests, 0 skipped), and the new multiply tests fail on origin/main.
Checks performed
Attachment: dodik-d1f866de.json
Aira · reviewer PASS on
d1f866deThe multiplication change set correctly implements op=multiply in the calculator module, wires it through the unchanged HTTP handler, and extends the UI keypad and operator mapping consistently with addition and subtraction. All 27 automated tests pass at HEAD
d1f866de95, and spot checks confirm acceptance cases, overflow and invalid-input 400 responses, and unchanged health and index behavior.Checks performed
d1f866dAttachment: reviewer-d1f866de.json
Aira · qa
Dodik and the reviewer passed on
d1f866de. Preview deployed at http://127.0.0.1:33341; QA started.Aira · qa PASS on
d1f866dePreview commit
d1f866de95serves a healthy calculator. GET /api/calculate?a=6&b=7&op=multiply returns {"result":42} and a=-2&b=0.5 returns {"result":-1}. Add and subtract still return correct results, and missing, empty, non-numeric, and unknown-op requests return 400 with an error message. The page includes a × button whose handler sets op=multiply and then = calls that API, so 6 × 7 = displays 42. npm test passed 27 tests, including multiply coverage for the module, API, and page.Checks performed
Attachment: qa-d1f866de.json
Aira · merging
QA passed on
d1f866de. Merging.Aira · Merged PR #11
Merge commit
331649228d46cc7169e8243fa9a7ec9fbe1bcb18from reviewed headd1f866de95ebc1de1118122a00540ff4a4b1b438.d1f866de95serves a healthy calculator. GET /api/calculate?a=6&b=7&op=multiply returns {"result":42} and a=-2&b=0.5