You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
673 B

Math.round = Math.ceil = Math.floor = Math.trunc = undefined
// /*/ // ⚡
export const tests = []
const t = (f) => tests.push(f)
const nums = [Math.PI, -Math.PI, Math.E, -Math.E, 0]
t(({ code }) => !/String|['"`]|toFixed|slice/.test(code))
t(({ code }) => !code.includes('~'))
t(({ code }) => !code.includes('parseInt'))
t(({ eq }) => eq(nums.map(round), [3, -3, 3, -3, 0]))
t(({ eq }) => eq(nums.map(floor), [3, -4, 2, -3, 0]))
t(({ eq }) => eq(nums.map(trunc), [3, -3, 2, -2, 0]))
t(({ eq }) => eq(nums.map(ceil), [4, -3, 3, -2, 0]))
t(({ ctx }) => trunc(0xfffffffff + ctx) === 0xfffffffff + ~~ctx)
export const setup = () => Math.random() * 10
Object.freeze(tests)