From ac60c21cb6b63a79e277481e264074ba793354c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:02:53 +0000 Subject: [PATCH 1/4] Initial plan From 14e3ae7b543e9a6cde967d19be58ca6f6db0ba44 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:07:26 +0000 Subject: [PATCH 2/4] Add comprehensive tests for gcd function Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com> --- src/lib_test.ts | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/lib_test.ts diff --git a/src/lib_test.ts b/src/lib_test.ts new file mode 100644 index 0000000..0664832 --- /dev/null +++ b/src/lib_test.ts @@ -0,0 +1,75 @@ +import { assertEquals } from "jsr:@std/assert"; +import { gcd } from "./lib.ts"; + +Deno.test("gcd - basic calculations", () => { + assertEquals(gcd(12, 8), 4); + assertEquals(gcd(54, 24), 6); + assertEquals(gcd(48, 18), 6); + assertEquals(gcd(100, 50), 50); +}); + +Deno.test("gcd - zero values", () => { + assertEquals(gcd(0, 5), 5); + assertEquals(gcd(5, 0), 5); + assertEquals(gcd(0, 0), 0); +}); + +Deno.test("gcd - negative numbers", () => { + // gcd should handle negative numbers by converting to absolute values + assertEquals(gcd(-12, 8), 4); + assertEquals(gcd(12, -8), 4); + assertEquals(gcd(-12, -8), 4); + assertEquals(gcd(-54, 24), 6); +}); + +Deno.test("gcd - same numbers", () => { + assertEquals(gcd(7, 7), 7); + assertEquals(gcd(1, 1), 1); + assertEquals(gcd(100, 100), 100); +}); + +Deno.test("gcd - coprime numbers", () => { + // Numbers with no common divisor except 1 + assertEquals(gcd(13, 17), 1); + assertEquals(gcd(7, 11), 1); + assertEquals(gcd(25, 49), 1); +}); + +Deno.test("gcd - one is 1", () => { + assertEquals(gcd(1, 5), 1); + assertEquals(gcd(5, 1), 1); + assertEquals(gcd(1, 1), 1); +}); + +Deno.test("gcd - large numbers", () => { + assertEquals(gcd(1000, 500), 500); + assertEquals(gcd(1071, 462), 21); + assertEquals(gcd(270, 192), 6); +}); + +Deno.test("gcd - decimal numbers (should be rounded)", () => { + // The function rounds inputs, so decimals should work + // 12.7 rounds to 13, 8.3 rounds to 8 -> gcd(13, 8) = 1 + assertEquals(gcd(12.7, 8.3), 1); + // 54.9 rounds to 55, 24.1 rounds to 24 -> gcd(55, 24) = 1 + assertEquals(gcd(54.9, 24.1), 1); + // 10.5 rounds to 11, 5.5 rounds to 6 -> gcd(11, 6) = 1 + assertEquals(gcd(10.5, 5.5), 1); + // 12.4 rounds to 12, 8.4 rounds to 8 -> gcd(12, 8) = 4 + assertEquals(gcd(12.4, 8.4), 4); +}); + +Deno.test("gcd - prime numbers", () => { + assertEquals(gcd(17, 19), 1); + assertEquals(gcd(23, 29), 1); + assertEquals(gcd(11, 13), 1); +}); + +Deno.test("gcd - powers of 2", () => { + assertEquals(gcd(16, 8), 8); + assertEquals(gcd(32, 16), 16); + assertEquals(gcd(64, 32), 32); + assertEquals(gcd(128, 256), 128); +}); + + From 43a4f0675c2f1088c5d9d34690df0f5aefd19418 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:08:33 +0000 Subject: [PATCH 3/4] Remove trailing blank lines from test file Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com> --- src/lib_test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib_test.ts b/src/lib_test.ts index 0664832..b3c51f2 100644 --- a/src/lib_test.ts +++ b/src/lib_test.ts @@ -71,5 +71,3 @@ Deno.test("gcd - powers of 2", () => { assertEquals(gcd(64, 32), 32); assertEquals(gcd(128, 256), 128); }); - - From ea38f760085361b902a2091eeee78908fd5e9d79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:09:17 +0000 Subject: [PATCH 4/4] Remove duplicate test case gcd(1, 1) Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com> --- src/lib_test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib_test.ts b/src/lib_test.ts index b3c51f2..7d19b41 100644 --- a/src/lib_test.ts +++ b/src/lib_test.ts @@ -38,7 +38,6 @@ Deno.test("gcd - coprime numbers", () => { Deno.test("gcd - one is 1", () => { assertEquals(gcd(1, 5), 1); assertEquals(gcd(5, 1), 1); - assertEquals(gcd(1, 1), 1); }); Deno.test("gcd - large numbers", () => {