import { Polinomial } from '.' ; describe ( 'Polinomial' , ( ) => { it ( 'multiplies two polinomials' , ( ) => { const polinomial1 = Polinomial . fromCoef ( [ 1 , 1 ] ) ; const polinomial2 = Polinomial . fromCoef ( [ 1 , 2 ] ) ; const expectedResult = [ 1 , 3 , 2 ] ; expect ( polinomial1 . multiply ( polinomial2 ) . toCoef ( ) ) . toEqual ( expectedResult ) ; } ) ; it ( 'correctly multiplies the one product that matters' , ( ) => { const leftHandSide = Polinomial . fromCoefExponents ( { 0 : 0 , 1 : 0 } ) ; const rightHandSide = Polinomial . fromCoefExponents ( { 0 : 1 , 1 : 0 } ) ; expect ( leftHandSide . multiply ( rightHandSide ) . toExponents ( ) ) . toEqual ( { 0 : 1 , 1 : 25 , 2 : 0 } ) ; } ) ; it ( 'correctly gets the rest of the division of two polynomials' , ( ) => { const HELLOWORLD = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 , 236 , 17 , 236 , 17 , 236 , 64 , 67 , 77 , 220 , 114 , 209 , 120 , 11 , 91 , 32 ] ; const exampleGeneratorPolinomial = { 0 : 45 , 1 : 32 , 2 : 94 , 3 : 64 , 4 : 70 , 5 : 118 , 6 : 61 , 7 : 46 , 8 : 67 , 9 : 251 , 10 : 0 } ; const expectedResult = [ 23 , 93 , 226 , 231 , 215 , 235 , 119 , 39 , 35 , 196 ] ; const leftHandSide = Polinomial . fromCoef ( HELLOWORLD ) ; const rightHandSide = Polinomial . fromCoefExponents ( exampleGeneratorPolinomial ) ; expect ( leftHandSide . modulo ( rightHandSide ) . toCoef ( ) ) . toEqual ( expectedResult ) ; } ) ; } ) ;