Skip to content

Commit

Permalink
Add ploy test.
Browse files Browse the repository at this point in the history
  • Loading branch information
only4sim committed Oct 31, 2023
1 parent ef4e545 commit 7db1d0d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions poly.test.ts
Original file line number Diff line number Diff line change
@@ -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
});

0 comments on commit 7db1d0d

Please sign in to comment.