Subtract numbers #2

Closed
opened 2026-11-21 02:25:10 +00:00 by lab-admin · 15 comments
Owner

Add subtraction next to addition.

Requirements

  • API: op=subtract returns a - b.
  • UI: a − (minus) button that works like +. Pressing 7, −, 1, 0, = shows -3.
  • Addition keeps working; error handling stays the same (400 {"error"} for bad input).
  • Tests for the new operation in the module, API and page.

Acceptance criteria

  1. /api/calculate?a=2&b=5&op=subtract returns {"result":-3}.
  2. /api/calculate?a=0.5&b=0.25&op=subtract returns {"result":0.25}.
  3. op=add still works and an unknown op still returns 400.
  4. The page has a minus button and shows differences returned by the API.
Add subtraction next to addition. ## Requirements - API: `op=subtract` returns `a - b`. - UI: a `−` (minus) button that works like `+`. Pressing `7`, `−`, `1`, `0`, `=` shows `-3`. - Addition keeps working; error handling stays the same (`400 {"error"}` for bad input). - Tests for the new operation in the module, API and page. ## Acceptance criteria 1. `/api/calculate?a=2&b=5&op=subtract` returns `{"result":-3}`. 2. `/api/calculate?a=0.5&b=0.25&op=subtract` returns `{"result":0.25}`. 3. `op=add` still works and an unknown op still returns 400. 4. The page has a minus button and shows differences returned by the API.
Collaborator

Aira · queued

Aira picked up this task. Branch aira/2-subtract-numbers.

**Aira · queued** Aira picked up this task. Branch `aira/2-subtract-numbers`.
Collaborator

Aira · planning

Orchestrator thread started (composer-2.5). Planning on aira/2-subtract-numbers.

T3 thread: mcp:launch:9957c1149a1f9eb5ec9c7ccb8cd1c2919a8db07a66402a00590211ba86917eb3

**Aira · planning** Orchestrator thread started (composer-2.5). Planning on `aira/2-subtract-numbers`. T3 thread: `mcp:launch:9957c1149a1f9eb5ec9c7ccb8cd1c2919a8db07a66402a00590211ba86917eb3`
Collaborator

Aira · Plan (round 1) at 9d74802c

Read AGENTS.md and the existing add implementation; wrote docs/plans/issue-2.md following issue-1 format; committed and pushed to aira/2-subtract-numbers. No code changes yet.

docs/plans/issue-2.md

Issue #2: Subtract numbers

Goal

Add subtraction alongside addition end to end: a pure subtract function in lib/calculator.js, GET /api/calculate support for op=subtract, and a − (minus) button in the UI that behaves like + but invokes subtraction on =. The example flow 7, −, 1, 0, = must show -3. Addition and existing error handling remain unchanged.

Acceptance criteria

  1. GET /api/calculate?a=2&b=5&op=subtract returns HTTP 200 with body {"result":-3}.
  2. GET /api/calculate?a=0.5&b=0.25&op=subtract returns HTTP 200 with body {"result":0.25}.
  3. op=add still works (e.g. existing success cases) and an unknown op still returns HTTP 400 with {"error":"<message>"}.
  4. The page at / has a minus button and displays differences returned by the API (including 7 − 1 0 = → -3 via the client calling the API with op=subtract).

Design

Calculator module (lib/calculator.js)

  • Add subtract(a, b) — returns a - b for finite numbers (caller supplies parsed numbers).
  • Extend calculate(op, a, b):
    • Dispatch op === 'subtract' to subtract (same operand validation path as add).
    • Keep allowing only add and subtract; any other op returns { error: 'unknown operation' }.
  • Export subtract from module.exports alongside existing exports.
  • Reuse existing parseNumber and non-finite result checks (overflow / Infinity on subtract should mirror add behaviour).

HTTP layer (server.js)

  • No routing changes expected: /api/calculate already delegates to calculate(op, a, b).
  • Verify behaviour indirectly via tests after module update.

UI (public/index.html)

  • Add a − key to the button grid (Unicode minus U+2212 or consistent − label in the labels array and dataset.key).
  • Introduce client state pendingOp (default 'add' or set on operator press):
    • + and − commit the current operand as the first number and set pendingOp to 'add' or 'subtract' respectively (same waitingForSecond flow as today’s +).
    • = builds URLSearchParams with op: pendingOp (not hardcoded 'add').
  • After a successful =, reset pendingOp to a sensible default (e.g. 'add') so chained use stays predictable.
  • Keep digit, ., C, and display behaviour aligned with issue #1.

Files to change

File Change
lib/calculator.js Add subtract; extend calculate for op=subtract; export subtract.
server.js None (unless review finds a gap; logic stays in module).
public/index.html Minus button; track pendingOp; pass op to API on =.
test/calculator.test.js Unit tests for subtract and calculate('subtract', ...).
test/server.test.js HTTP tests for acceptance criteria 1–3 (subtract success, add regression, unknown op).
test/ui.test.js Assert minus button present in HTML; optional assertion that script references subtract or dynamic op.

Test plan

Unit tests (test/calculator.test.js)

Test Proves
subtract(2, 5) === -3 Criterion 1 (module level).
subtract(0.5, 0.25) === 0.25 Criterion 2 (module level).
calculate('subtract', '2', '5') → { result: -3 } Dispatch and parsing.
calculate('add', ...) still succeeds Criterion 3 (module).
calculate('pow', ...) still unknown error Criterion 3 (module).

HTTP tests (test/server.test.js)

Use existing withServer + fetch pattern:

Request Expect
?a=2&b=5&op=subtract 200, { result: -3 }
?a=0.5&b=0.25&op=subtract 200, { result: 0.25 }
?a=2&b=3&op=add 200, { result: 5 } (regression)
?a=1&b=2&op=pow 400, error string
?a=7&b=10&op=subtract 200, { result: -3 } (UI example operands)

UI / page tests (test/ui.test.js)

Test Proves
HTML labels (or equivalent) includes minus ('−' or documented label) Criterion 4 (button present).
HTML still includes required digits, +, =, C, and fetch to /api/calculate Regression.
Script uses operation from state (e.g. subtract or non–hardcoded-only add) Criterion 4 (wiring).

Run npm test locally before every push; all tests must pass.

Risks

Risk Mitigation
Minus sign confusion (ASCII - vs Unicode − in UI label vs API op=subtract) API uses op=subtract; UI label is display-only; tests assert HTML contains the minus key label used in code.
UI hardcodes op: 'add' on = Explicit pendingOp set by + / −; test that fetch params include subtract.
Floating-point 0.5 - 0.25 Same as add: rely on JSON number; acceptance test uses given decimals.
Breaking addition or validation Keep calculate structure; add subtract branch only; run full existing test suite.
Grid layout with extra button Adjust labels order to fit 4-column grid without removing existing keys.

Implementation order (for later steps)

  1. lib/calculator.js + test/calculator.test.js
  2. HTTP tests in test/server.test.js (server unchanged)
  3. public/index.html UI + test/ui.test.js
  4. Full npm test, then push branch aira/2-subtract-numbers

Attachment: plan-2-r1.md

**Aira · Plan (round 1) at `9d74802c`** Read AGENTS.md and the existing add implementation; wrote docs/plans/issue-2.md following issue-1 format; committed and pushed to aira/2-subtract-numbers. No code changes yet. <details><summary>docs/plans/issue-2.md</summary> # Issue #2: Subtract numbers ## Goal Add subtraction alongside addition end to end: a pure `subtract` function in `lib/calculator.js`, `GET /api/calculate` support for `op=subtract`, and a `−` (minus) button in the UI that behaves like `+` but invokes subtraction on `=`. The example flow `7`, `−`, `1`, `0`, `=` must show `-3`. Addition and existing error handling remain unchanged. ## Acceptance criteria 1. `GET /api/calculate?a=2&b=5&op=subtract` returns HTTP 200 with body `{"result":-3}`. 2. `GET /api/calculate?a=0.5&b=0.25&op=subtract` returns HTTP 200 with body `{"result":0.25}`. 3. `op=add` still works (e.g. existing success cases) and an unknown `op` still returns HTTP 400 with `{"error":"<message>"}`. 4. The page at `/` has a minus button and displays differences returned by the API (including `7` `−` `1` `0` `=` → `-3` via the client calling the API with `op=subtract`). ## Design ### Calculator module (`lib/calculator.js`) - Add `subtract(a, b)` — returns `a - b` for finite numbers (caller supplies parsed numbers). - Extend `calculate(op, a, b)`: - Dispatch `op === 'subtract'` to `subtract` (same operand validation path as `add`). - Keep allowing only `add` and `subtract`; any other `op` returns `{ error: 'unknown operation' }`. - Export `subtract` from `module.exports` alongside existing exports. - Reuse existing `parseNumber` and non-finite result checks (overflow / `Infinity` on subtract should mirror add behaviour). ### HTTP layer (`server.js`) - No routing changes expected: `/api/calculate` already delegates to `calculate(op, a, b)`. - Verify behaviour indirectly via tests after module update. ### UI (`public/index.html`) - Add a `−` key to the button grid (Unicode minus U+2212 or consistent `−` label in the `labels` array and `dataset.key`). - Introduce client state `pendingOp` (default `'add'` or set on operator press): - `+` and `−` commit the current operand as the first number and set `pendingOp` to `'add'` or `'subtract'` respectively (same `waitingForSecond` flow as today’s `+`). - `=` builds `URLSearchParams` with `op: pendingOp` (not hardcoded `'add'`). - After a successful `=`, reset `pendingOp` to a sensible default (e.g. `'add'`) so chained use stays predictable. - Keep digit, `.`, `C`, and display behaviour aligned with issue #1. ## Files to change | File | Change | |------|--------| | `lib/calculator.js` | Add `subtract`; extend `calculate` for `op=subtract`; export `subtract`. | | `server.js` | None (unless review finds a gap; logic stays in module). | | `public/index.html` | Minus button; track `pendingOp`; pass `op` to API on `=`. | | `test/calculator.test.js` | Unit tests for `subtract` and `calculate('subtract', ...)`. | | `test/server.test.js` | HTTP tests for acceptance criteria 1–3 (subtract success, add regression, unknown op). | | `test/ui.test.js` | Assert minus button present in HTML; optional assertion that script references `subtract` or dynamic `op`. | ## Test plan ### Unit tests (`test/calculator.test.js`) | Test | Proves | |------|--------| | `subtract(2, 5) === -3` | Criterion 1 (module level). | | `subtract(0.5, 0.25) === 0.25` | Criterion 2 (module level). | | `calculate('subtract', '2', '5')` → `{ result: -3 }` | Dispatch and parsing. | | `calculate('add', ...)` still succeeds | Criterion 3 (module). | | `calculate('pow', ...)` still unknown error | Criterion 3 (module). | ### HTTP tests (`test/server.test.js`) Use existing `withServer` + `fetch` pattern: | Request | Expect | |---------|--------| | `?a=2&b=5&op=subtract` | 200, `{ result: -3 }` | | `?a=0.5&b=0.25&op=subtract` | 200, `{ result: 0.25 }` | | `?a=2&b=3&op=add` | 200, `{ result: 5 }` (regression) | | `?a=1&b=2&op=pow` | 400, `error` string | | `?a=7&b=10&op=subtract` | 200, `{ result: -3 }` (UI example operands) | ### UI / page tests (`test/ui.test.js`) | Test | Proves | |------|--------| | HTML `labels` (or equivalent) includes minus (`'−'` or documented label) | Criterion 4 (button present). | | HTML still includes required digits, `+`, `=`, `C`, and `fetch` to `/api/calculate` | Regression. | | Script uses operation from state (e.g. `subtract` or non–hardcoded-only `add`) | Criterion 4 (wiring). | Run `npm test` locally before every push; all tests must pass. ## Risks | Risk | Mitigation | |------|------------| | Minus sign confusion (ASCII `-` vs Unicode `−` in UI label vs API `op=subtract`) | API uses `op=subtract`; UI label is display-only; tests assert HTML contains the minus key label used in code. | | UI hardcodes `op: 'add'` on `=` | Explicit `pendingOp` set by `+` / `−`; test that fetch params include subtract. | | Floating-point `0.5 - 0.25` | Same as add: rely on JSON number; acceptance test uses given decimals. | | Breaking addition or validation | Keep `calculate` structure; add subtract branch only; run full existing test suite. | | Grid layout with extra button | Adjust `labels` order to fit 4-column grid without removing existing keys. | ## Implementation order (for later steps) 1. `lib/calculator.js` + `test/calculator.test.js` 2. HTTP tests in `test/server.test.js` (server unchanged) 3. `public/index.html` UI + `test/ui.test.js` 4. Full `npm test`, then push branch `aira/2-subtract-numbers` </details> Attachment: [plan-2-r1.md](https://aira-lab.cluster-dev.spkey.co/attachments/9a8c5660-4e76-4146-b985-f20f3c1b6ae2)
Collaborator

Aira · plan review

Plan pushed at 9d74802c; independent Dodik plan review started.

**Aira · plan review** Plan pushed at `9d74802c`; independent Dodik plan review started.
Collaborator

Aira · dodik-plan PASS on 9d74802c

The issue #2 plan at 9d74802 maps each subtraction requirement to a numbered, testable acceptance criterion, and the design matches the current code: subtract belongs in lib/calculator.js on the same validation path as add, server.js already delegates op to calculate, and the page should add a − key plus pendingOp instead of hardcoding op=add. The test plan covers the module, the HTTP cases (including 2−5, 0.5−0.25, add regression, unknown op, and the 7−10 example), and the page button and wiring, with no out-of-scope work.

Checks performed
  • Confirmed HEAD is 9d74802 with a clean tree and read docs/plans/issue-2.md
  • Mapped API a−b, the − button flow 7 − 1 0 = → -3, unchanged addition and 400 error handling, and module/API/page tests onto acceptance criteria 1–4
  • Read lib/calculator.js, server.js, public/index.html, the existing tests, issue #1 plan, and AGENTS.md; the design matches calculate's add-only dispatch, shared parseNumber and non-finite checks, the server's pass-through of op, and the UI's labels grid plus hardcoded op: 'add'
  • Confirmed the test plan proves criteria 1–3 at unit and HTTP level and criterion 4 with a minus label, fetch wiring, and the 7/10 operand case, including unknown-op and addition regression
  • Confirmed the file list stays inside the calculator module, page, and tests and does not add operations or server routing
  • Ran npm test: 28 passing, matching the baseline the plan extends

Attachment: dodik-plan-9d74802c.json

**Aira · dodik-plan PASS on `9d74802c`** The issue #2 plan at 9d74802 maps each subtraction requirement to a numbered, testable acceptance criterion, and the design matches the current code: subtract belongs in lib/calculator.js on the same validation path as add, server.js already delegates op to calculate, and the page should add a − key plus pendingOp instead of hardcoding op=add. The test plan covers the module, the HTTP cases (including 2−5, 0.5−0.25, add regression, unknown op, and the 7−10 example), and the page button and wiring, with no out-of-scope work. <details><summary>Checks performed</summary> - Confirmed HEAD is 9d74802 with a clean tree and read docs/plans/issue-2.md - Mapped API a−b, the − button flow 7 − 1 0 = → -3, unchanged addition and 400 error handling, and module/API/page tests onto acceptance criteria 1–4 - Read lib/calculator.js, server.js, public/index.html, the existing tests, issue #1 plan, and AGENTS.md; the design matches calculate's add-only dispatch, shared parseNumber and non-finite checks, the server's pass-through of op, and the UI's labels grid plus hardcoded op: 'add' - Confirmed the test plan proves criteria 1–3 at unit and HTTP level and criterion 4 with a minus label, fetch wiring, and the 7/10 operand case, including unknown-op and addition regression - Confirmed the file list stays inside the calculator module, page, and tests and does not add operations or server routing - Ran npm test: 28 passing, matching the baseline the plan extends </details> Attachment: [dodik-plan-9d74802c.json](https://aira-lab.cluster-dev.spkey.co/attachments/8d48b06c-835c-4ca7-b042-5a3bf281dc60)
Collaborator

Aira · implementing

Plan approved by Dodik at 9d74802c. Implementation started.

**Aira · implementing** Plan approved by Dodik at `9d74802c`. Implementation started.
Collaborator

Aira · ci

Ready for review at 3482997d (PR #10). Waiting for CI.

Implemented subtract in lib/calculator.js, minus button and pendingOp in public/index.html (server unchanged), and unit/HTTP/UI tests for all acceptance criteria. npm test: 34 passed. Pushed feat commit on aira/2-subtract-numbers.

**Aira · ci** Ready for review at `3482997d` (PR #10). Waiting for CI. Implemented subtract in lib/calculator.js, minus button and pendingOp in public/index.html (server unchanged), and unit/HTTP/UI tests for all acceptance criteria. npm test: 34 passed. Pushed feat commit on aira/2-subtract-numbers.
Collaborator

Aira · CI passed on 3482997d

  • ci / test (pull_request): success
**Aira · CI passed on `3482997d`** - ci / test (pull_request): success
Collaborator

Aira · review

CI is green on 3482997d. Independent Dodik and code review started.

**Aira · review** CI is green on `3482997d`. Independent Dodik and code review started.
Collaborator

Aira · dodik PASS on 3482997d

Commit 3482997 implements subtraction as specified in docs/plans/issue-2.md. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3} and a=0.5&b=0.25 returns 200 {"result":0.25}; op=add still returns sums and an unknown op still returns 400 {"error":"unknown operation"}. The page has a Unicode minus button that sets pendingOp to subtract, and the sequence 7, −, 1, 0, = calls a=7&b=10&op=subtract and shows -3, while 1, 2, +, 3, = still shows 15. npm test passed 34 tests with none skipped or weakened, and the diff is limited to the plan, calculator, page, and tests.

Checks performed
  • Compared git diff origin/main...HEAD at 3482997: only docs/plans/issue-2.md, lib/calculator.js, public/index.html, test/calculator.test.js, test/server.test.js, and test/ui.test.js changed; server.js was left unchanged as planned.
  • Confirmed new module, HTTP, and page tests assert the subtract results and minus-button wiring and would fail on the previous add-only code; no assertions were removed, no tests are skipped or todo, and no debug leftovers were added.
  • Ran npm test: 34 passed, 0 failed, 0 skipped, 0 todo.
  • Curled a live server: /api/calculate subtract cases returned {"result":-3} and {"result":0.25}, op=add returned {"result":5}, op=pow returned 400 {"error":"unknown operation"}, and invalid a with op=subtract returned 400 {"error":"invalid a"}. /health still returned {"ok":true,"sha":...}.
  • Served HTML contains the − label, pendingOp, and pressOperator('subtract') passed as op. A DOM replay against that server showed 7 − 1 0 = as -3 via /api/calculate?a=7&b=10&op=subtract, and 1 2 + 3 = as 15. Browser preview could not start (missing host libraries); this replay plus the served page was the check.
  • README and AGENTS.md still describe the generic calculate contract and did not need an operations list; nothing in them became incorrect.

Attachment: dodik-3482997d.json

**Aira · dodik PASS on `3482997d`** Commit 3482997 implements subtraction as specified in docs/plans/issue-2.md. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3} and a=0.5&b=0.25 returns 200 {"result":0.25}; op=add still returns sums and an unknown op still returns 400 {"error":"unknown operation"}. The page has a Unicode minus button that sets pendingOp to subtract, and the sequence 7, −, 1, 0, = calls a=7&b=10&op=subtract and shows -3, while 1, 2, +, 3, = still shows 15. npm test passed 34 tests with none skipped or weakened, and the diff is limited to the plan, calculator, page, and tests. <details><summary>Checks performed</summary> - Compared git diff origin/main...HEAD at 3482997: only docs/plans/issue-2.md, lib/calculator.js, public/index.html, test/calculator.test.js, test/server.test.js, and test/ui.test.js changed; server.js was left unchanged as planned. - Confirmed new module, HTTP, and page tests assert the subtract results and minus-button wiring and would fail on the previous add-only code; no assertions were removed, no tests are skipped or todo, and no debug leftovers were added. - Ran npm test: 34 passed, 0 failed, 0 skipped, 0 todo. - Curled a live server: /api/calculate subtract cases returned {"result":-3} and {"result":0.25}, op=add returned {"result":5}, op=pow returned 400 {"error":"unknown operation"}, and invalid a with op=subtract returned 400 {"error":"invalid a"}. /health still returned {"ok":true,"sha":...}. - Served HTML contains the − label, pendingOp, and pressOperator('subtract') passed as op. A DOM replay against that server showed 7 − 1 0 = as -3 via /api/calculate?a=7&b=10&op=subtract, and 1 2 + 3 = as 15. Browser preview could not start (missing host libraries); this replay plus the served page was the check. - README and AGENTS.md still describe the generic calculate contract and did not need an operations list; nothing in them became incorrect. </details> Attachment: [dodik-3482997d.json](https://aira-lab.cluster-dev.spkey.co/attachments/318c338f-96fd-4926-8e4e-534629fade58)
Collaborator

Aira · reviewer PASS on 3482997d

The subtraction feature is implemented consistently across lib/calculator.js, the existing server delegate, and the UI via pendingOp and a minus key; acceptance API cases and regressions for add and unknown op are covered by tests, and npm test passes with no correctness, security, or behavioural regressions identified in the diff.

Checks performed
  • git diff origin/main...3482997d53916d01af53e954b64ce2935a4c484e reviewed
  • npm test — 34 tests, 0 failures
  • calculate('subtract') dispatch, validation, and non-finite result path aligned with add
  • HTTP /api/calculate subtract acceptance and add/unknown-op regression tests present
  • UI labels include −, pendingOp wired to fetch, clear resets pendingOp
  • Manual spot-check: subtract overflow returns non-finite error; negative operands work

Attachment: reviewer-3482997d.json

**Aira · reviewer PASS on `3482997d`** The subtraction feature is implemented consistently across lib/calculator.js, the existing server delegate, and the UI via pendingOp and a minus key; acceptance API cases and regressions for add and unknown op are covered by tests, and npm test passes with no correctness, security, or behavioural regressions identified in the diff. <details><summary>Checks performed</summary> - git diff origin/main...3482997d53916d01af53e954b64ce2935a4c484e reviewed - npm test — 34 tests, 0 failures - calculate('subtract') dispatch, validation, and non-finite result path aligned with add - HTTP /api/calculate subtract acceptance and add/unknown-op regression tests present - UI labels include −, pendingOp wired to fetch, clear resets pendingOp - Manual spot-check: subtract overflow returns non-finite error; negative operands work </details> Attachment: [reviewer-3482997d.json](https://aira-lab.cluster-dev.spkey.co/attachments/195d24c2-5880-462b-b198-2d1d5362930f)
Collaborator

Aira · qa

Dodik and the reviewer passed on 3482997d. Preview deployed at http://127.0.0.1:46141; QA started.

**Aira · qa** Dodik and the reviewer passed on `3482997d`. Preview deployed at http://127.0.0.1:46141; QA started.
Collaborator

Aira · qa PASS on 3482997d

Health reports sha 3482997d53. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3}, a=0.5&b=0.25&op=subtract returns 200 {"result":0.25}, and the UI sequence 7 − 10 (= a=7&b=10&op=subtract) returns 200 {"result":-3}. op=add still returns 200 {"result":7} for a=2&b=5, unknown and missing or non-numeric inputs return 400 {"error":...}, and GET / is 200 HTML containing a U+2212 minus button wired to op=subtract that displays the API result. npm test passed 34/34.

Checks performed

Attachment: qa-3482997d.json

**Aira · qa PASS on `3482997d`** Health reports sha 3482997d53916d01af53e954b64ce2935a4c484e. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3}, a=0.5&b=0.25&op=subtract returns 200 {"result":0.25}, and the UI sequence 7 − 10 (= a=7&b=10&op=subtract) returns 200 {"result":-3}. op=add still returns 200 {"result":7} for a=2&b=5, unknown and missing or non-numeric inputs return 400 {"error":...}, and GET / is 200 HTML containing a U+2212 minus button wired to op=subtract that displays the API result. npm test passed 34/34. <details><summary>Checks performed</summary> - GET http://127.0.0.1:46141/health → 200 {"ok":true,"sha":"3482997d53916d01af53e954b64ce2935a4c484e"} - GET http://127.0.0.1:46141/ → 200 text/html with button label U+2212, handler pressOperator('subtract'), and fetch('/api/calculate?') that writes body.result to #display - GET http://127.0.0.1:46141/api/calculate?a=2&b=5&op=subtract → 200 {"result":-3} - GET http://127.0.0.1:46141/api/calculate?a=0.5&b=0.25&op=subtract → 200 {"result":0.25} - GET http://127.0.0.1:46141/api/calculate?a=7&b=10&op=subtract → 200 {"result":-3} - GET http://127.0.0.1:46141/api/calculate?a=5&b=5&op=subtract → 200 {"result":0} - GET http://127.0.0.1:46141/api/calculate?a=-2&b=-5&op=subtract → 200 {"result":3} - GET http://127.0.0.1:46141/api/calculate?a=10&b=3&op=subtract → 200 {"result":7} - GET http://127.0.0.1:46141/api/calculate?a=2&b=5&op=add → 200 {"result":7} - GET http://127.0.0.1:46141/api/calculate?a=2&b=5&op=multiply → 400 {"error":"unknown operation"} - GET http://127.0.0.1:46141/api/calculate?b=5&op=subtract → 400 {"error":"invalid a"} - GET http://127.0.0.1:46141/api/calculate?a=&b=1&op=subtract → 400 {"error":"invalid a"} - GET http://127.0.0.1:46141/api/calculate?a=foo&b=1&op=subtract → 400 {"error":"invalid a"} - GET http://127.0.0.1:46141/api/calculate?a=1&b=bar&op=subtract → 400 {"error":"invalid b"} - GET http://127.0.0.1:46141/api/calculate?a=1&op=subtract → 400 {"error":"invalid b"} - GET http://127.0.0.1:46141/api/calculate?a=1&b=2 → 400 {"error":"missing operation"} - GET http://127.0.0.1:46141/api/calculate?a=1&b=2&op= → 400 {"error":"missing operation"} - GET http://127.0.0.1:46141/api/calculate?a=1&b=2&op=SUBTRACT → 400 {"error":"unknown operation"} - GET http://127.0.0.1:46141/api/calculate?a=1&b=&op=add → 400 {"error":"invalid b"} - npm test (node --test) → 34 passed, 0 failed, including subtract module, API, and page tests </details> Attachment: [qa-3482997d.json](https://aira-lab.cluster-dev.spkey.co/attachments/b4e342c0-f6c0-432c-a17c-1b1dfd2cc933)
Collaborator

Aira · merging

QA passed on 3482997d. Merging.

**Aira · merging** QA passed on `3482997d`. Merging.
Collaborator

Aira · Merged PR #10

Merge commit 8956e23d9afb718b23b33f59ddf1946fa431e373 from reviewed head 3482997d53916d01af53e954b64ce2935a4c484e.

Gate Verdict Summary
ci pass ci / test (pull_request)
dodik pass Commit 3482997 implements subtraction as specified in docs/plans/issue-2.md. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3} and a=0.5&b=0.25 r
reviewer pass The subtraction feature is implemented consistently across lib/calculator.js, the existing server delegate, and the UI via pendingOp and a minus key; acceptance
qa pass Health reports sha 3482997d53. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3}, a=0.5&b=0.25&op=subtract returns
**Aira · Merged PR #10** Merge commit `8956e23d9afb718b23b33f59ddf1946fa431e373` from reviewed head `3482997d53916d01af53e954b64ce2935a4c484e`. | Gate | Verdict | Summary | |---|---|---| | ci | pass | ci / test (pull_request) | | dodik | pass | Commit 3482997 implements subtraction as specified in docs/plans/issue-2.md. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3} and a=0.5&b=0.25 r | | reviewer | pass | The subtraction feature is implemented consistently across lib/calculator.js, the existing server delegate, and the UI via pendingOp and a minus key; acceptance | | qa | pass | Health reports sha 3482997d53916d01af53e954b64ce2935a4c484e. GET /api/calculate?a=2&b=5&op=subtract returns 200 {"result":-3}, a=0.5&b=0.25&op=subtract returns |
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/web-calculator-2#2
No description provided.