From 5e914a50a22e3b652e9235995aed60f22bab2464 Mon Sep 17 00:00:00 2001 From: Gusarich Date: Thu, 21 Mar 2024 18:21:59 +0300 Subject: [PATCH] fix --- .../writeSerialization.spec.ts.snap | 6 +++--- src/test/feature-math.spec.ts | 21 ++++++------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/generator/writers/__snapshots__/writeSerialization.spec.ts.snap b/src/generator/writers/__snapshots__/writeSerialization.spec.ts.snap index 2c57001ed..eabe16777 100644 --- a/src/generator/writers/__snapshots__/writeSerialization.spec.ts.snap +++ b/src/generator/writers/__snapshots__/writeSerialization.spec.ts.snap @@ -2991,7 +2991,7 @@ return b.end_cell().begin_parse();", } int result = 0; while (num >= base) { - num = num / base; + num /= base; result += 1; } return result;", @@ -6846,7 +6846,7 @@ return b.end_cell().begin_parse();", } int result = 0; while (num >= base) { - num = num / base; + num /= base; result += 1; } return result;", @@ -10701,7 +10701,7 @@ return b.end_cell().begin_parse();", } int result = 0; while (num >= base) { - num = num / base; + num /= base; result += 1; } return result;", diff --git a/src/test/feature-math.spec.ts b/src/test/feature-math.spec.ts index 9e7b660b4..740df83b4 100644 --- a/src/test/feature-math.spec.ts +++ b/src/test/feature-math.spec.ts @@ -360,23 +360,14 @@ describe('feature-math', () => { const maxint = 2n ** 256n - 1n; - function bigIntLogBase(num: bigint, base: bigint) { - let result = 0n; - while (num >= base) { - num = num / base; - result += 1n; - } - return result; - } - for (let num = maxint - 100n; num <= maxint; num++) { expect(await contract.getLog2(num)).toBe(255n); } for (let num = maxint - 10n; num <= maxint; num++) { - for (let base = 2n; base <= 10; base++) { - expect(await contract.getLog(num, base)).toBe( - bigIntLogBase(num, base) + for (let base = 2; base <= 10; base++) { + expect(await contract.getLog(num, BigInt(base))).toBe( + BigInt(num.toString(base).length - 1) ); } } @@ -389,9 +380,9 @@ describe('feature-math', () => { } for (let num = maxint / 2n - 5n; num <= maxint / 2n + 5n; num++) { - for (let base = 2n; base <= 10; base++) { - expect(await contract.getLog(num, base)).toBe( - bigIntLogBase(num, base) + for (let base = 2; base <= 10; base++) { + expect(await contract.getLog(num, BigInt(base))).toBe( + BigInt(num.toString(base).length - 1) ); } }