How to use result64 method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

ArrayInt64.spec.ts

Source:ArrayInt64.spec.ts Github

copy

Full Screen

1import * as fc from 'fast-check';2import {3 add64,4 ArrayInt64,5 halve64,6 isEqual64,7 isStrictlySmaller64,8 logLike64,9 negative64,10 substract64,11} from '../../../../../src/arbitrary/_internals/helpers/ArrayInt64';12function toArrayInt64(b: bigint, withNegativeZero: boolean): ArrayInt64 {13 const posB = b < BigInt(0) ? -b : b;14 return {15 sign: b < BigInt(0) || (withNegativeZero && b === BigInt(0)) ? -1 : 1,16 data: [Number(posB >> BigInt(32)), Number(posB & ((BigInt(1) << BigInt(32)) - BigInt(1)))],17 };18}19function toBigInt(a: ArrayInt64): bigint {20 return BigInt(a.sign) * ((BigInt(a.data[0]) << BigInt(32)) + BigInt(a.data[1]));21}22function expectValidArrayInt(a: ArrayInt64): void {23 expect([-1, 1]).toContain(a.sign);24 expect(a.data[0]).toBeGreaterThanOrEqual(0);25 expect(a.data[0]).toBeLessThanOrEqual(0xffffffff);26 expect(a.data[1]).toBeGreaterThanOrEqual(0);27 expect(a.data[1]).toBeLessThanOrEqual(0xffffffff);28}29function expectValidZeroIfAny(a: ArrayInt64): void {30 if (a.data[0] === 0 && a.data[1] === 0) {31 expect(a.sign).toBe(1);32 }33}34describe('ArrayInt64', () => {35 if (typeof BigInt === 'undefined') {36 it('no test', () => {37 expect(true).toBe(true);38 });39 return;40 }41 const MaxArrayIntValue = (BigInt(1) << BigInt(64)) - BigInt(1);42 describe('isEqual64', () => {43 it('should consider identical values as equal', () => {44 fc.assert(45 fc.property(fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }), (a) => {46 // Arrange47 const a64 = toArrayInt64(a, false);48 const a64Cloned = toArrayInt64(a, false);49 // Act50 const out = isEqual64(a64, a64Cloned);51 // Assert52 expect(out).toBe(true);53 })54 );55 });56 it('should consider two different values as not equal', () => {57 fc.assert(58 fc.property(59 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),60 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),61 fc.boolean(),62 fc.boolean(),63 (a, b, na, nb) => {64 // Arrange65 fc.pre(a !== b);66 const a64 = toArrayInt64(a, na);67 const b64 = toArrayInt64(b, nb);68 // Act69 const out = isEqual64(a64, b64);70 // Assert71 expect(out).toBe(false);72 }73 )74 );75 });76 it('should consider zero and -zero to be equal', () => {77 expect(isEqual64({ sign: -1, data: [0, 0] }, { sign: -1, data: [0, 0] })).toBe(true);78 expect(isEqual64({ sign: 1, data: [0, 0] }, { sign: -1, data: [0, 0] })).toBe(true);79 expect(isEqual64({ sign: -1, data: [0, 0] }, { sign: 1, data: [0, 0] })).toBe(true);80 expect(isEqual64({ sign: 1, data: [0, 0] }, { sign: 1, data: [0, 0] })).toBe(true);81 });82 });83 describe('isStrictlySmaller64', () => {84 it('should properly compare two ArrayInt64 (including negative zeros)', () => {85 fc.assert(86 fc.property(87 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),88 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),89 fc.boolean(),90 fc.boolean(),91 (a, b, na, nb) => {92 // Arrange93 const a64 = toArrayInt64(a, na);94 const b64 = toArrayInt64(b, nb);95 // Act96 const out = isStrictlySmaller64(a64, b64);97 // Assert98 expect(out).toBe(a < b);99 }100 )101 );102 });103 it('should consider zero and -zero as equal values (never strictly smaller that the other)', () => {104 expect(isStrictlySmaller64({ sign: -1, data: [0, 0] }, { sign: -1, data: [0, 0] })).toBe(false);105 expect(isStrictlySmaller64({ sign: 1, data: [0, 0] }, { sign: -1, data: [0, 0] })).toBe(false);106 expect(isStrictlySmaller64({ sign: -1, data: [0, 0] }, { sign: 1, data: [0, 0] })).toBe(false);107 expect(isStrictlySmaller64({ sign: 1, data: [0, 0] }, { sign: 1, data: [0, 0] })).toBe(false);108 });109 });110 describe('substract64', () => {111 it('should properly substract two ArrayInt64 (including negative zeros)', () => {112 fc.assert(113 fc.property(114 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),115 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),116 fc.boolean(),117 fc.boolean(),118 (a, b, na, nb) => {119 // Arrange120 const expectedResult = a - b;121 fc.pre(expectedResult >= -MaxArrayIntValue);122 fc.pre(expectedResult <= MaxArrayIntValue);123 const a64 = toArrayInt64(a, na);124 const b64 = toArrayInt64(b, nb);125 // Act126 const result64 = substract64(a64, b64);127 // Assert128 expectValidArrayInt(result64);129 expectValidZeroIfAny(result64);130 expect(toBigInt(result64)).toBe(expectedResult);131 }132 )133 );134 });135 it('should equal to first term if second one is zero', () => {136 fc.assert(137 fc.property(138 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),139 fc.boolean(),140 fc.boolean(),141 (a, na, nb) => {142 // Arrange143 const a64 = toArrayInt64(a, na);144 const b64 = toArrayInt64(BigInt(0), nb);145 // Act146 const result64 = substract64(a64, b64);147 // Assert148 expectValidArrayInt(result64);149 expectValidZeroIfAny(result64);150 expect(result64).toEqual(toArrayInt64(a, false)); // toArrayInt64(a, false): sign must be + for 0151 }152 )153 );154 });155 it('should equal to minus second term if first one is zero', () => {156 fc.assert(157 fc.property(158 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),159 fc.boolean(),160 fc.boolean(),161 (a, na, nb) => {162 // Arrange163 const z64 = toArrayInt64(BigInt(0), nb);164 const a64 = toArrayInt64(a, na);165 // Act166 const result64 = substract64(z64, a64);167 // Assert168 expectValidArrayInt(result64);169 expectValidZeroIfAny(result64);170 expect(result64).toEqual(toArrayInt64(-a, false)); // toArrayInt64(-a, false): sign must be + for 0171 }172 )173 );174 });175 it('should equal to zero when substracting zeros', () => {176 const negZero: ArrayInt64 = { sign: -1, data: [0, 0] };177 const posZero: ArrayInt64 = { sign: 1, data: [0, 0] };178 expect(substract64(negZero, negZero)).toEqual(posZero);179 expect(substract64(negZero, posZero)).toEqual(posZero);180 expect(substract64(posZero, negZero)).toEqual(posZero);181 expect(substract64(posZero, posZero)).toEqual(posZero);182 });183 });184 describe('negative64', () => {185 it('should properly negate an ArrayInt64 (including negative zeros)', () => {186 fc.assert(187 fc.property(fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }), fc.boolean(), (a, na) => {188 // Arrange189 const expectedResult = -a;190 const a64 = toArrayInt64(a, na);191 // Act192 const result64 = negative64(a64);193 // Assert194 expectValidArrayInt(result64);195 expect(toBigInt(result64)).toBe(expectedResult);196 })197 );198 });199 });200 describe('add64', () => {201 it('should properly add two ArrayInt64 (including negative zeros)', () => {202 fc.assert(203 fc.property(204 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),205 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),206 fc.boolean(),207 fc.boolean(),208 (a, b, na, nb) => {209 // Arrange210 const expectedResult = a + b;211 fc.pre(expectedResult >= -MaxArrayIntValue);212 fc.pre(expectedResult <= MaxArrayIntValue);213 const a64 = toArrayInt64(a, na);214 const b64 = toArrayInt64(b, nb);215 // Act216 const result64 = add64(a64, b64);217 // Assert218 expectValidArrayInt(result64);219 expectValidZeroIfAny(result64);220 expect(toBigInt(result64)).toBe(expectedResult);221 }222 )223 );224 });225 it('should equal to first term if second one is zero', () => {226 fc.assert(227 fc.property(228 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),229 fc.boolean(),230 fc.boolean(),231 (a, na, nb) => {232 // Arrange233 const a64 = toArrayInt64(a, na);234 const z64 = toArrayInt64(BigInt(0), nb);235 // Act236 const result64 = add64(a64, z64);237 // Assert238 expectValidArrayInt(result64);239 expectValidZeroIfAny(result64);240 expect(result64).toEqual(toArrayInt64(a, false)); // toArrayInt64(a, false): sign must be + for 0241 }242 )243 );244 });245 it('should equal to second term if first one is zero', () => {246 fc.assert(247 fc.property(248 fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }),249 fc.boolean(),250 fc.boolean(),251 (a, na, nb) => {252 // Arrange253 const z64 = toArrayInt64(BigInt(0), nb);254 const a64 = toArrayInt64(a, na);255 // Act256 const result64 = add64(z64, a64);257 // Assert258 expectValidArrayInt(result64);259 expectValidZeroIfAny(result64);260 expect(result64).toEqual(toArrayInt64(a, false)); // toArrayInt64(a, false): sign must be + for 0261 }262 )263 );264 });265 it('should equal to zero when adding zeros together', () => {266 const negZero: ArrayInt64 = { sign: -1, data: [0, 0] };267 const posZero: ArrayInt64 = { sign: 1, data: [0, 0] };268 expect(add64(negZero, negZero)).toEqual(posZero);269 expect(add64(negZero, posZero)).toEqual(posZero);270 expect(add64(posZero, negZero)).toEqual(posZero);271 expect(add64(posZero, posZero)).toEqual(posZero);272 });273 });274 describe('halve64', () => {275 it('should properly halve an ArrayInt64 (including negative zeros)', () => {276 fc.assert(277 fc.property(fc.bigInt({ min: -MaxArrayIntValue, max: MaxArrayIntValue }), fc.boolean(), (a, na) => {278 // Arrange279 const expectedResult = a / BigInt(2);280 const a64 = toArrayInt64(a, na);281 // Act282 const result64 = halve64(a64);283 // Assert284 expectValidArrayInt(result64);285 expect(toBigInt(result64)).toBe(expectedResult);286 })287 );288 });289 });290 describe('logLike64', () => {291 it('should properly log2 an ArrayInt64', () => {292 fc.assert(293 fc.property(fc.bigInt({ min: BigInt(1), max: MaxArrayIntValue }), (a) => {294 // Arrange295 const expectedResult = Math.floor(Math.log(Number(a)) / Math.log(2));296 const a64 = toArrayInt64(a, false); // no negative zero: a > 0297 // Act298 const result64 = logLike64(a64);299 // Assert300 expectValidArrayInt(result64);301 expect(toBigInt(result64)).toBe(BigInt(expectedResult));302 })303 );304 });305 it('should properly log2 a negative ArrayInt64', () => {306 fc.assert(307 fc.property(fc.bigInt({ min: BigInt(1), max: MaxArrayIntValue }), (a) => {308 // Arrange309 const expectedResult = -Math.floor(Math.log(Number(a)) / Math.log(2));310 const a64 = toArrayInt64(-a, false); // no negative zero: a > 0311 // Act312 const result64 = logLike64(a64);313 // Assert314 expectValidArrayInt(result64);315 expect(toBigInt(result64)).toBe(BigInt(expectedResult));316 })317 );318 });319 });...

Full Screen

Full Screen

aggregate-to-grid-vs-64.glsl.js

Source:aggregate-to-grid-vs-64.glsl.js Github

copy

Full Screen

1// Copyright (c) 2015 - 2018 Uber Technologies, Inc.2//3// Permission is hereby granted, free of charge, to any person obtaining a copy4// of this software and associated documentation files (the "Software"), to deal5// in the Software without restriction, including without limitation the rights6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell7// copies of the Software, and to permit persons to whom the Software is8// furnished to do so, subject to the following conditions:9//10// The above copyright notice and this permission notice shall be included in11// all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN19// THE SOFTWARE.20export default `\21#define SHADER_NAME gpu-aggregation-to-grid-vs-6422attribute vec2 positions;23attribute vec2 positions64Low;24attribute vec3 weights;25uniform vec2 windowSize;26uniform vec2 cellSize;27uniform vec2 gridSize;28uniform vec2 uProjectionMatrixFP64[16];29uniform bool projectPoints;30varying vec3 vWeights;31void project_to_pixel(vec2 pos, vec2 pos64Low, out vec2 pixelXY64[2]) {32 vec2 result64[4];33 vec2 position64[4];34 position64[0] = vec2(pos.x, pos64Low.x);35 position64[1] = vec2(pos.y, pos64Low.y);36 position64[2] = vec2(0., 0.);37 position64[3] = vec2(1., 0.);38 mat4_vec4_mul_fp64(uProjectionMatrixFP64, position64,39 result64);40 pixelXY64[0] = div_fp64(result64[0], result64[3]);41 pixelXY64[1] = div_fp64(result64[1], result64[3]);42}43void main(void) {44 vWeights = weights;45 vec2 windowPos = positions;46 vec2 windowPos64Low = positions64Low;47 if (projectPoints) {48 vec2 projectedXY[2];49 project_position_fp64(windowPos, windowPos64Low, projectedXY);50 windowPos.x = projectedXY[0].x;51 windowPos.y = projectedXY[1].x;52 windowPos64Low.x = projectedXY[0].y;53 windowPos64Low.y = projectedXY[1].y;54 }55 vec2 pixelXY64[2];56 project_to_pixel(windowPos, windowPos64Low, pixelXY64);57 // Transform (0,0):windowSize -> (0, 0): gridSize58 vec2 gridXY64[2];59 gridXY64[0] = div_fp64(pixelXY64[0], vec2(cellSize.x, 0));60 gridXY64[1] = div_fp64(pixelXY64[1], vec2(cellSize.y, 0));61 float x = floor(gridXY64[0].x);62 float y = floor(gridXY64[1].x);63 vec2 pos = vec2(x, y);64 // Transform (0,0):gridSize -> (-1, -1):(1,1)65 pos = (pos * (2., 2.) / (gridSize)) - (1., 1.);66 // Move to pixel center, pixel-size in screen sapce (2/gridSize) * 0.5 => 1/gridSize67 vec2 offset = 1.0 / gridSize;68 pos = pos + offset;69 gl_Position = vec4(pos, 0.0, 1.0);70}...

Full Screen

Full Screen

parse64.js

Source:parse64.js Github

copy

Full Screen

1const char64 =2 ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',3 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',4 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',5 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',6 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',7 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',8 'Y', 'Z', '+', '~']9function encode (num10) {10 let str10 = num10.toString()11 // console.log(str10.replace('.', ''))12 let pointIndex = str10.indexOf('.')13 let decimalIndex = pointIndex !== -1 ? str10.length - pointIndex - 1 : 014 // console.log(str10, decimalIndex, str10.replace('.', ''))15 let remainder64 = []16 let result64 = parseInt(str10.replace('.', ''))17 while (result64) {18 remainder64.push(result64 % 64)19 result64 = parseInt(result64 / 64)20 }21 return matchChar(remainder64) + matchChar([decimalIndex])22}23function decode (str64) {24 let num10 = 025 let multiple = 126 let decimalIndex = str64.slice(str64.length - 1)27 decimalIndex = char64.indexOf(decimalIndex)28 let nums10 = str64.split('').reverse()29 nums10.shift()30 nums10.forEach((item, i) => {31 let charNum = char64.indexOf(item)32 num10 += charNum * multiple33 multiple *= 6434 });35 console.log(num10)36 num10 /= Math.pow(10, decimalIndex)37 return num10.toFixed(decimalIndex)38}39function matchChar (charArr) {40 let res = charArr.map(item => char64[item])41 return res.reverse().join('')42}43let originNum = 12.89012345671234567844originNum = 123456789.1232345645originNum = 1234567891232345646let num64 = encode(originNum)47console.log(num64)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const result64 = require("fast-check-monorepo");3const result = fc.check(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));4console.log(result64(result));5const fc = require("fast-check");6const result64 = require("fast-check");7const result = fc.check(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));8console.log(result64(result));9{10 "compilerOptions": {11 },12}13{14 "compilerOptions": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const result64 = require('fast-check-monorepo').result64;3const { result64: result64b } = require('fast-check-monorepo');4const arb = fc.integer(0, 10000);5const arb2 = fc.integer(0, 10000);6const r = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a));7console.log(result64(r));8const r2 = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a), {9});10console.log(result64b(r2));11const r3 = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a), {12});13console.log(result64b(r3));14const r4 = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a), {15});16console.log(result64b(r4));17const r5 = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a), {18});19console.log(result64b(r5));20const r6 = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a), {21});22console.log(result64b(r6));23const r7 = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a), {24});25console.log(result64b(r7));26const r8 = fc.check(fc.property(arb, arb2, (a, b) => a + b >= a), {

Full Screen

Using AI Code Generation

copy

Full Screen

1import {asyncProperty} from 'fast-check';2import {result64} from 'fast-check';3async function main() {4 const p = asyncProperty(5 async (n: number) => {6 return n > 0;7 },8 async (n: number) => {9 return n > 0;10 },11 async (n: number, m: number) => {12 return n + m > 0;13 }14 );15 const r = await p.result64();16 console.log(r);17}18main();19{20 "compilerOptions": {21 },22}23{24 "scripts": {25 },26 "dependencies": {27 },28 "devDependencies": {29 }30}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { result64 } from 'fast-check';2const result = result64(0.5);3console.log(result);4import { result64 } from 'fast-check';5const result = result64(0.5);6console.log(result);7import { result64 } from 'fast-check';8const result = result64(0.5);9console.log(result);10import { result64 } from 'fast-check';11const result = result64(0.5);12console.log(result);13import { result64 } from 'fast-check';14const result = result64(0.5);15console.log(result);16import { result64 } from 'fast-check';17const result = result64(0.5);18console.log(result);19import { result64 } from 'fast-check';20const result = result64(0.5);21console.log(result);22import { result64 } from 'fast-check';23const result = result64(0.5);24console.log(result);25import { result64 } from 'fast-check';26const result = result64(0.5);27console.log(result);28import { result64 } from 'fast-check';29const result = result64(0.5);30console.log(result);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful