From 7db1d0defc7ce9c5ca6d33629e364235cd529201 Mon Sep 17 00:00:00 2001 From: Curious Cat <35210356+only4sim@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:42:05 +0000 Subject: [PATCH] Add ploy test. --- poly.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 poly.test.ts diff --git a/poly.test.ts b/poly.test.ts new file mode 100644 index 0000000..c236645 --- /dev/null +++ b/poly.test.ts @@ -0,0 +1,22 @@ +import { poly } from './poly'; // Import your poly function from your implementation file + +describe('poly', () => { + it('should evaluate a polynomial correctly', () => { + // Define input, coefficients, and expected output + const input = 3; // Input value + const coefficients = [2, 1, 0.5]; // Coefficients for the polynomial 2x^2 + x + 0.5 + const expectedOutput = 19.5; // Expected output for x=3 + + // Convert input and coefficients to Fields (assuming you have a way to represent numbers as Fields) + const inputField = ...; // Convert input to a Field + const coefficientsField = coefficients.map((c) => ...); // Convert coefficients to Fields + + // Call the poly function + const result = poly(inputField, coefficientsField); + + // Assert that the result matches the expected output + expect(result.toNumber()).toEqual(expectedOutput); + }); + + // Add more test cases as needed +});