From fcc5d508c7c39e4d50567b367d0d0694e997f5ba Mon Sep 17 00:00:00 2001 From: Tomer Aberbach Date: Wed, 25 Dec 2024 23:08:06 -0500 Subject: [PATCH] feat: support min/max exclusive (fixes #50) --- src/arbitrary.ts | 17 ++- src/components.ts | 46 ++++--- src/constraints.ts | 10 ++ src/convert.ts | 76 +++++++++-- src/numerics.ts | 73 +++++----- test/index.ts | 162 ++++++++++++++++++++++- test/snapshots/decimal/arbitraries.js | 9 ++ test/snapshots/decimal/samples.js | 21 +++ test/snapshots/decimal128/arbitraries.js | 9 ++ test/snapshots/decimal128/samples.js | 21 +++ test/snapshots/float32/arbitraries.js | 15 ++- test/snapshots/float32/samples.js | 45 ++++++- test/snapshots/float64/arbitraries.js | 9 ++ test/snapshots/float64/samples.js | 21 +++ test/snapshots/int16/arbitraries.js | 19 +++ test/snapshots/int16/samples.js | 35 +++++ test/snapshots/int32/arbitraries.js | 13 ++ test/snapshots/int32/samples.js | 35 +++++ test/snapshots/int64/arbitraries.js | 10 ++ test/snapshots/int64/samples.js | 14 ++ test/snapshots/int8/arbitraries.js | 19 +++ test/snapshots/int8/samples.js | 35 +++++ test/snapshots/integer/arbitraries.js | 13 +- test/snapshots/integer/samples.js | 40 +++++- test/snapshots/numeric/arbitraries.js | 9 ++ test/snapshots/numeric/samples.js | 21 +++ test/snapshots/safeint/arbitraries.js | 22 +++ test/snapshots/safeint/samples.js | 35 +++++ 28 files changed, 766 insertions(+), 88 deletions(-) diff --git a/src/arbitrary.ts b/src/arbitrary.ts index 7766f6b..f12af2d 100644 --- a/src/arbitrary.ts +++ b/src/arbitrary.ts @@ -57,8 +57,14 @@ export const numberArbitrary = ( export type NumberArbitrary = { type: `number` - min: number - max: number + min: { + value: number + exclusive: boolean + } + max: { + value: number + exclusive: boolean + } isInteger: boolean } @@ -244,6 +250,13 @@ const getArbitraryKey = (arbitrary: Arbitrary): ArbitraryKey => { case `constant`: return keyalesce([arbitrary.type, arbitrary.value]) case `number`: + return keyalesce([ + arbitrary.type, + arbitrary.min.value, + arbitrary.min.exclusive, + arbitrary.max.value, + arbitrary.max.exclusive, + ]) case `bigint`: return keyalesce([arbitrary.type, arbitrary.min, arbitrary.max]) case `string`: diff --git a/src/components.ts b/src/components.ts index f1b5a84..b22ce89 100644 --- a/src/components.ts +++ b/src/components.ts @@ -371,50 +371,62 @@ const NumberArbitrary = ({ filter( ([, { isInteger, min, max }]) => arbitrary.isInteger === isInteger && - (arbitrary.min === min.value || + ((!arbitrary.min.exclusive && arbitrary.min.value === min.value) || min.configurable === true || - (min.configurable === `higher` && arbitrary.min >= min.value)) && - (arbitrary.max === max.value || + (min.configurable === `higher` && + arbitrary.min.value >= min.value)) && + ((!arbitrary.max.exclusive && arbitrary.max.value === max.value) || max.configurable === true || - (max.configurable === `lower` && arbitrary.max <= max.value)), + (max.configurable === `lower` && arbitrary.max.value <= max.value)), ), minBy(([, a], [, b]) => { const matchCount1 = - Number(arbitrary.min === a.min.value) + - Number(arbitrary.max === a.max.value) + Number(arbitrary.min.value === a.min.value) + + Number(arbitrary.max.value === a.max.value) const matchCount2 = - Number(arbitrary.min === b.min.value) + - Number(arbitrary.max === b.max.value) + Number(arbitrary.min.value === b.min.value) + + Number(arbitrary.max.value === b.max.value) if (matchCount1 !== matchCount2) { return matchCount2 - matchCount1 } const delta1 = - Math.abs(arbitrary.min - a.min.value) + - Math.abs(arbitrary.max - a.max.value) + Math.abs(arbitrary.min.value - a.min.value) + + Math.abs(arbitrary.max.value - a.max.value) const delta2 = - Math.abs(arbitrary.min - b.min.value) + - Math.abs(arbitrary.max - b.max.value) + Math.abs(arbitrary.min.value - b.min.value) + + Math.abs(arbitrary.max.value - b.max.value) return delta1 - delta2 }), get, ) - let arbitraryMin = arbitrary.min === min.value ? null : arbitrary.min + let arbitraryMin = + !arbitrary.min.exclusive && arbitrary.min.value === min.value + ? null + : arbitrary.min if (arbitraryMin !== null && min.normalize) { - arbitraryMin = min.normalize(arbitraryMin) + arbitraryMin = { ...arbitraryMin, value: min.normalize(arbitraryMin.value) } } - let arbitraryMax = arbitrary.max === max.value ? null : arbitrary.max + let arbitraryMax = + !arbitrary.max.exclusive && arbitrary.max.value === max.value + ? null + : arbitrary.max if (arbitraryMax !== null && max.normalize) { - arbitraryMax = max.normalize(arbitraryMax) + arbitraryMax = { ...arbitraryMax, value: max.normalize(arbitraryMax.value) } } return CallExpression({ name: `fc.${name}`, args: [ ObjectExpression({ - properties: { min: arbitraryMin, max: arbitraryMax }, + properties: { + [arbitraryMin?.exclusive ? `minExclusive` : `min`]: + arbitraryMin?.value, + [arbitraryMax?.exclusive ? `maxExclusive` : `max`]: + arbitraryMax?.value, + }, singlePropertyOneLine: true, }), ], diff --git a/src/constraints.ts b/src/constraints.ts index ee896ee..4f89783 100644 --- a/src/constraints.ts +++ b/src/constraints.ts @@ -2,9 +2,11 @@ import { getMaxItemsAsNumeric, getMaxLengthAsNumeric, getMaxValueAsNumeric, + getMaxValueExclusiveAsNumeric, getMinItemsAsNumeric, getMinLengthAsNumeric, getMinValueAsNumeric, + getMinValueExclusiveAsNumeric, } from '@typespec/compiler' import type { Numeric, Program, Type } from '@typespec/compiler' import keyalesce from 'keyalesce' @@ -21,6 +23,8 @@ export const getConstraints = (program: Program, type: Type): Constraints => entries({ min: getMinValueAsNumeric(program, type), max: getMaxValueAsNumeric(program, type), + minExclusive: getMinValueExclusiveAsNumeric(program, type), + maxExclusive: getMaxValueExclusiveAsNumeric(program, type), minLength: getMinLengthAsNumeric(program, type), maxLength: getMaxLengthAsNumeric(program, type), minItems: getMinItemsAsNumeric(program, type), @@ -34,6 +38,8 @@ export const getConstraints = (program: Program, type: Type): Constraints => export type Constraints = { min?: Numeric max?: Numeric + minExclusive?: Numeric + maxExclusive?: Numeric minLength?: Numeric maxLength?: Numeric minItems?: Numeric @@ -53,6 +59,8 @@ const memoize = (constraints: Constraints): Constraints => { const getConstraintsKey = ({ min, max, + minExclusive, + maxExclusive, minLength, maxLength, minItems, @@ -61,6 +69,8 @@ const getConstraintsKey = ({ keyalesce([ min?.asBigInt(), max?.asBigInt(), + minExclusive?.asBigInt(), + maxExclusive?.asBigInt(), minLength?.asBigInt(), maxLength?.asBigInt(), minItems?.asBigInt(), diff --git a/src/convert.ts b/src/convert.ts index 5638b5f..b67fe1d 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -71,10 +71,11 @@ import type { } from './arbitrary.ts' import { fastCheckNumerics, - maxOrUndefined, - minOrUndefined, + maxOfMinBounds, + minOfMaxBounds, numerics, } from './numerics.ts' +import type { Bound } from './numerics.ts' import normalizeArbitrary from './normalize.ts' import { collectSharedArbitraries } from './dependency-graph.ts' import type { SharedArbitraries } from './dependency-graph.ts' @@ -345,13 +346,38 @@ const convertNumber = ( constraints: Constraints, { min, max, isInteger }: { min: number; max: number; isInteger: boolean }, ): Arbitrary => { - const arbitrary = numberArbitrary({ - min: maxOrUndefined(constraints.min?.asNumber() ?? undefined, min), - max: minOrUndefined(constraints.max?.asNumber() ?? undefined, max), - isInteger, - }) + const minBound = [ + { value: constraints.min?.asNumber(), exclusive: false }, + { value: constraints.minExclusive?.asNumber(), exclusive: true }, + { value: min, exclusive: false }, + ] + .filter((bound): bound is Bound => bound.value != null) + .reduce(maxOfMinBounds) + const maxBound = [ + { value: constraints.max?.asNumber(), exclusive: false }, + { value: constraints.maxExclusive?.asNumber(), exclusive: true }, + { value: max, exclusive: false }, + ] + .filter((bound): bound is Bound => bound.value != null) + .reduce(minOfMaxBounds) + if (isInteger) { + if (minBound.exclusive) { + minBound.exclusive = false + minBound.value++ + } + if (maxBound.exclusive) { + maxBound.exclusive = false + maxBound.value-- + } + } + + const arbitrary = numberArbitrary({ min: minBound, max: maxBound, isInteger }) - const hasDefaultConstraints = arbitrary.min === min && arbitrary.max === max + const hasDefaultConstraints = + !arbitrary.min.exclusive && + arbitrary.min.value === min && + !arbitrary.max.exclusive && + arbitrary.max.value === max if (!hasDefaultConstraints) { return arbitrary } @@ -360,8 +386,10 @@ const convertNumber = ( values(fastCheckNumerics), any( numeric => - arbitrary.min === numeric.min.value && - arbitrary.max === numeric.max.value && + !arbitrary.min.exclusive && + arbitrary.min.value === numeric.min.value && + !arbitrary.max.exclusive && + arbitrary.max.value === numeric.max.value && arbitrary.isInteger === numeric.isInteger, ), ) @@ -377,9 +405,33 @@ const convertBigInt = ( constraints: Constraints, { min, max }: { min?: bigint; max?: bigint } = {}, ): Arbitrary => { + const minBounds = [ + { value: constraints.min?.asBigInt(), exclusive: false }, + { value: constraints.minExclusive?.asBigInt(), exclusive: true }, + { value: min, exclusive: false }, + ].filter((bound): bound is Bound => bound.value != null) + const minBound = + minBounds.length === 0 ? undefined : minBounds.reduce(maxOfMinBounds) + if (minBound?.exclusive) { + minBound.value++ + minBound.exclusive = false + } + + const maxBounds = [ + { value: constraints.max?.asBigInt(), exclusive: false }, + { value: constraints.maxExclusive?.asBigInt(), exclusive: true }, + { value: max, exclusive: false }, + ].filter((bound): bound is Bound => bound.value != null) + const maxBound = + maxBounds.length === 0 ? undefined : maxBounds.reduce(minOfMaxBounds) + if (maxBound?.exclusive) { + maxBound.value-- + maxBound.exclusive = false + } + const arbitrary = bigintArbitrary({ - min: maxOrUndefined(constraints.min?.asBigInt() ?? undefined, min), - max: minOrUndefined(constraints.max?.asBigInt() ?? undefined, max), + min: minBound?.value, + max: maxBound?.value, }) const hasDefaultConstraints = diff --git a/src/numerics.ts b/src/numerics.ts index 2d55a08..aa2f2a7 100644 --- a/src/numerics.ts +++ b/src/numerics.ts @@ -93,50 +93,39 @@ export type FastCheckNumeric = { isInteger: boolean } -export const minOrUndefined = < - const A extends bigint | number | undefined, - const B extends bigint | number | undefined, +export const maxOfMinBounds = < + A extends bigint | number, + B extends bigint | number, >( - a: A, - b: B, -): A extends undefined - ? B extends undefined - ? undefined - : Exclude - : Exclude => { - const min = (() => { - if (a === undefined) { - return b - } else if (b === undefined) { - return a - } else { - return a < b ? a : b - } - })() - // eslint-disable-next-line typescript/no-unsafe-return - return min as any + min1: Bound, + min2: Bound, +): Bound => { + if (min1.value > min2.value) { + return min1 + } else if (min2.value > min1.value) { + return min2 + } else { + return { value: min1.value, exclusive: min1.exclusive || min2.exclusive } + } } -export const maxOrUndefined = < - const A extends bigint | number | undefined, - const B extends bigint | number | undefined, +export const minOfMaxBounds = < + A extends bigint | number, + B extends bigint | number, >( - a: A, - b: B, -): A extends undefined - ? B extends undefined - ? undefined - : Exclude - : Exclude => { - const max = (() => { - if (a === undefined) { - return b - } else if (b === undefined) { - return a - } else { - return a > b ? a : b - } - })() - // eslint-disable-next-line typescript/no-unsafe-return - return max as any + min1: Bound, + min2: Bound, +): Bound => { + if (min1.value < min2.value) { + return min1 + } else if (min2.value < min1.value) { + return min2 + } else { + return { value: min1.value, exclusive: min1.exclusive || min2.exclusive } + } +} + +export type Bound = { + value: N + exclusive: boolean } diff --git a/test/index.ts b/test/index.ts index 5cba5b4..4434823 100644 --- a/test/index.ts +++ b/test/index.ts @@ -133,19 +133,36 @@ test.each([ @minValue(-10) scalar MinValueInt8 extends int8; + @minValueExclusive(-10) + scalar MinValueExclusiveInt8 extends int8; + @minValue(0) scalar Min0ValueInt8 extends int8; + @minValueExclusive(-1) + scalar MinNegative1ValueExclusiveInt8 extends int8; + @maxValue(20) scalar MaxValueInt8 extends int8; + @maxValueExclusive(20) + scalar MaxValueExclusiveInt8 extends int8; + @minValue(-10) @maxValue(20) scalar MinMaxValueInt8 extends int8; + @minValueExclusive(-10) + @maxValueExclusive(20) + scalar MinMaxValueExclusiveInt8 extends int8; + @minValue(-300) @maxValue(400) scalar RedundantlyMinMaxValueInt8 extends int8; + + @minValueExclusive(-300) + @maxValueExclusive(400) + scalar RedundantlyMinMaxValueExclusiveInt8 extends int8; `, }, { @@ -156,19 +173,36 @@ test.each([ @minValue(-200) scalar MinValueInt16 extends int16; + @minValueExclusive(-200) + scalar MinValueExclusiveInt16 extends int16; + @minValue(0) scalar Min0ValueInt16 extends int16; + @minValueExclusive(-1) + scalar MinNegative1ValueExclusiveInt16 extends int16; + @maxValue(345) scalar MaxValueInt16 extends int16; + @maxValueExclusive(345) + scalar MaxValueExclusiveInt16 extends int16; + @minValue(-200) @maxValue(345) scalar MinMaxValueInt16 extends int16; + @minValueExclusive(-200) + @maxValueExclusive(345) + scalar MinMaxValueExclusiveInt16 extends int16; + @minValue(-40000) @maxValue(40000) scalar RedundantlyMinMaxValueInt16 extends int16; + + @minValueExclusive(-40000) + @maxValueExclusive(40000) + scalar RedundantlyMinMaxValueExclusiveInt16 extends int16; `, }, { @@ -179,19 +213,36 @@ test.each([ @minValue(-40000) scalar MinValueInt32 extends int32; + @minValueExclusive(-40000) + scalar MinValueExclusiveInt32 extends int32; + @minValue(0) scalar Min0ValueInt32 extends int32; + @minValueExclusive(-1) + scalar MinNegative1ValueExclusiveInt32 extends int32; + @maxValue(40000) scalar MaxValueInt32 extends int32; + @maxValueExclusive(40000) + scalar MaxValueExclusiveInt32 extends int32; + @minValue(-40000) @maxValue(40000) scalar MinMaxValueInt32 extends int32; + @minValueExclusive(-40000) + @maxValueExclusive(40000) + scalar MinMaxValueExclusiveInt32 extends int32; + @minValue(-2147483650) @maxValue(2147483650) scalar RedundantlyMinMaxValueInt32 extends int32; + + @minValueExclusive(-2147483650) + @maxValueExclusive(2147483650) + scalar RedundantlyMinMaxValueExclusiveInt32 extends int32; `, }, { @@ -202,19 +253,36 @@ test.each([ @minValue(-40000) scalar MinValueSafeInt extends safeint; + @minValueExclusive(-40000) + scalar MinValueExclusiveSafeInt extends safeint; + @minValue(0) scalar Min0ValueSafeInt extends safeint; + @minValueExclusive(-1) + scalar MinNegative1ValueExclusiveSafeInt extends safeint; + @maxValue(40000) scalar MaxValueSafeInt extends safeint; + @maxValueExclusive(40000) + scalar MaxValueExclusiveSafeInt extends safeint; + @minValue(-40000) @maxValue(40000) scalar MinMaxValueSafeInt extends safeint; + @minValueExclusive(-40000) + @maxValueExclusive(40000) + scalar MinMaxValueExclusiveSafeInt extends safeint; + @minValue(-2147483650) @maxValue(2147483650) scalar RedundantlyMinMaxValueSafeInt extends safeint; + + @minValueExclusive(-2147483650) + @maxValueExclusive(2147483650) + scalar RedundantlyMinMaxValueExclusiveSafeInt extends safeint; `, }, { @@ -225,22 +293,42 @@ test.each([ @minValue(-2147483650) scalar MinValueInt64 extends int64; + @minValueExclusive(-2147483650) + scalar MinValueExclusiveInt64 extends int64; + // https://github.com/microsoft/typespec/pull/5295 // @minValue(0) // scalar Min0ValueInt64 extends int64; + // https://github.com/microsoft/typespec/pull/5295 + // @minValueExclusive(-1) + // scalar MinNegative1ValueExclusiveInt64 extends int64; + @maxValue(2147483650) scalar MaxValueInt64 extends int64; + @maxValueExclusive(2147483650) + scalar MaxValueExclusiveInt64 extends int64; + // https://github.com/microsoft/typespec/pull/5295 // @minValue(-2147483650) // @maxValue(2147483650) // scalar MinMaxValueInt64 extends int64; + // https://github.com/microsoft/typespec/pull/5295 + // @minValueExclusive(-2147483650) + // @maxValueExclusive(2147483650) + // scalar MinMaxValueExclusiveInt64 extends int64; + // https://github.com/microsoft/typespec/pull/5295 // @minValue(-9223372036854775809) // @maxValue(9223372036854775809) // scalar RedundantlyMinMaxValueInt64 extends int64; + + // https://github.com/microsoft/typespec/pull/5295 + // @minValueExclusive(-9223372036854775809) + // @maxValueExclusive(9223372036854775809) + // scalar RedundantlyMinMaxValueExclusiveInt64 extends int64; `, }, { @@ -251,15 +339,28 @@ test.each([ @minValue(-92233720368547758000) scalar MinValueInteger extends integer; + @minValueExclusive(-92233720368547758000) + scalar MinValueExclusiveInteger extends integer; + @minValue(0) - scalar MinValue0Integer extends integer; + scalar Min0ValueInteger extends integer; + + @minValueExclusive(-1) + scalar MinNegative1ValueExclusiveInteger extends integer; @maxValue(922337203685477580000) scalar MaxValueInteger extends integer; + @maxValueExclusive(922337203685477580000) + scalar MaxValueExclusiveInteger extends integer; + @minValue(-92233720368547758000) @maxValue(922337203685477580000) scalar MinMaxValueInteger extends integer; + + @minValueExclusive(-92233720368547758000) + @maxValueExclusive(922337203685477580000) + scalar MinMaxValueExclusiveInteger extends integer; `, }, { @@ -270,19 +371,36 @@ test.each([ @minValue(-3.14) scalar MinValueFloat32 extends float32; + @minValueExclusive(-3.14) + scalar MinValueExclusiveFloat32 extends float32; + @minValue(0) - scalar MinValue0Float32 extends float32; + scalar Min0ValueFloat32 extends float32; + + @minValueExclusive(0) + scalar Min0ValueExclusiveFloat32 extends float32; @maxValue(3.14) scalar MaxValueFloat32 extends float32; + @maxValueExclusive(3.14) + scalar MaxValueExclusiveFloat32 extends float32; + @minValue(-3.14) @maxValue(3.14) scalar MinMaxValueFloat32 extends float32; + @minValueExclusive(-3.14) + @maxValueExclusive(3.14) + scalar MinMaxValueExclusiveFloat32 extends float32; + @minValue(-3.4e+39) @maxValue(3.4e+39) scalar RedundantlyMinMaxValueFloat32 extends float32; + + @minValueExclusive(-3.4e+39) + @maxValueExclusive(3.4e+39) + scalar RedundantlyMinMaxValueExclusiveFloat32 extends float32; `, }, { @@ -293,12 +411,22 @@ test.each([ @minValue(-3.4e+39) scalar MinValueFloat64 extends float64; + @minValueExclusive(-3.4e+39) + scalar MinValueExclusiveFloat64 extends float64; + @maxValue(3.4e+39) scalar MaxValueFloat64 extends float64; + @maxValueExclusive(3.4e+39) + scalar MaxValueExclusiveFloat64 extends float64; + @minValue(-3.4e+39) @maxValue(3.4e+39) scalar MinMaxValueFloat64 extends float64; + + @minValueExclusive(-3.4e+39) + @maxValueExclusive(3.4e+39) + scalar MinMaxValueExclusiveFloat64 extends float64; `, }, { @@ -309,12 +437,22 @@ test.each([ @minValue(-3.4e+39) scalar MinValueDecimal128 extends decimal128; + @minValueExclusive(-3.4e+39) + scalar MinValueExclusiveDecimal128 extends decimal128; + @maxValue(3.4e+39) scalar MaxValueDecimal128 extends decimal128; + @maxValueExclusive(3.4e+39) + scalar MaxValueExclusiveDecimal128 extends decimal128; + @minValue(-3.4e+39) @maxValue(3.4e+39) scalar MinMaxValueDecimal128 extends decimal128; + + @minValueExclusive(-3.4e+39) + @maxValueExclusive(3.4e+39) + scalar MinMaxValueExclusiveDecimal128 extends decimal128; `, }, { @@ -325,12 +463,22 @@ test.each([ @minValue(-3.4e+39) scalar MinValueDecimal extends decimal; + @minValueExclusive(-3.4e+39) + scalar MinValueExclusiveDecimal extends decimal; + @maxValue(3.4e+39) scalar MaxValueDecimal extends decimal; + @maxValueExclusive(3.4e+39) + scalar MaxValueExclusiveDecimal extends decimal; + @minValue(-3.4e+39) @maxValue(3.4e+39) scalar MinMaxValueDecimal extends decimal; + + @minValueExclusive(-3.4e+39) + @maxValueExclusive(3.4e+39) + scalar MinMaxValueExclusiveDecimal extends decimal; `, }, { @@ -341,13 +489,23 @@ test.each([ @minValue(-3.4e+39) scalar MinValueNumeric extends numeric; + @minValueExclusive(-3.4e+39) + scalar MinValueExclusiveNumeric extends numeric; + @maxValue(3.4e+39) scalar MaxValueNumeric extends numeric; + @maxValueExclusive(3.4e+39) + scalar MaxValueExclusiveNumeric extends numeric; + @minValue(-3.4e+39) @maxValue(3.4e+39) scalar MinMaxValueNumeric extends numeric; + @minValueExclusive(-3.4e+39) + @maxValueExclusive(3.4e+39) + scalar MinMaxValueExclusiveNumeric extends numeric; + model $Model { a: 1, b: 2, diff --git a/test/snapshots/decimal/arbitraries.js b/test/snapshots/decimal/arbitraries.js index e0c41e9..ec3f558 100644 --- a/test/snapshots/decimal/arbitraries.js +++ b/test/snapshots/decimal/arbitraries.js @@ -4,9 +4,18 @@ export const Decimal = fc.double(); export const MinValueDecimal = fc.double({ min: -3.4e+39 }); +export const MinValueExclusiveDecimal = fc.double({ minExclusive: -3.4e+39 }); + export const MaxValueDecimal = fc.double({ max: 3.4e+39 }); +export const MaxValueExclusiveDecimal = fc.double({ maxExclusive: 3.4e+39 }); + export const MinMaxValueDecimal = fc.double({ min: -3.4e+39, max: 3.4e+39, }); + +export const MinMaxValueExclusiveDecimal = fc.double({ + minExclusive: -3.4e+39, + maxExclusive: 3.4e+39, +}); diff --git a/test/snapshots/decimal/samples.js b/test/snapshots/decimal/samples.js index 69845a6..652e620 100644 --- a/test/snapshots/decimal/samples.js +++ b/test/snapshots/decimal/samples.js @@ -13,6 +13,13 @@ export const samples = { 2.47e-322, -1.7976931348623115e+308 ], + 'MaxValueExclusiveDecimal': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinMaxValueDecimal': [ -2.9e-322, -3.34565396186043e-292, @@ -20,11 +27,25 @@ export const samples = { 2.47e-322, -3.3999999999999866e+39 ], + 'MinMaxValueExclusiveDecimal': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinValueDecimal': [ -2.9e-322, -3.34565396186043e-292, -1.6090819601980502e-136, 2.47e-322, -3.3999999999999866e+39 + ], + 'MinValueExclusiveDecimal': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 ] }; diff --git a/test/snapshots/decimal128/arbitraries.js b/test/snapshots/decimal128/arbitraries.js index 04568da..a47901f 100644 --- a/test/snapshots/decimal128/arbitraries.js +++ b/test/snapshots/decimal128/arbitraries.js @@ -4,9 +4,18 @@ export const Decimal128 = fc.double(); export const MinValueDecimal128 = fc.double({ min: -3.4e+39 }); +export const MinValueExclusiveDecimal128 = fc.double({ minExclusive: -3.4e+39 }); + export const MaxValueDecimal128 = fc.double({ max: 3.4e+39 }); +export const MaxValueExclusiveDecimal128 = fc.double({ maxExclusive: 3.4e+39 }); + export const MinMaxValueDecimal128 = fc.double({ min: -3.4e+39, max: 3.4e+39, }); + +export const MinMaxValueExclusiveDecimal128 = fc.double({ + minExclusive: -3.4e+39, + maxExclusive: 3.4e+39, +}); diff --git a/test/snapshots/decimal128/samples.js b/test/snapshots/decimal128/samples.js index 94afb12..af62d35 100644 --- a/test/snapshots/decimal128/samples.js +++ b/test/snapshots/decimal128/samples.js @@ -13,6 +13,13 @@ export const samples = { 2.47e-322, -1.7976931348623115e+308 ], + 'MaxValueExclusiveDecimal128': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinMaxValueDecimal128': [ -2.9e-322, -3.34565396186043e-292, @@ -20,11 +27,25 @@ export const samples = { 2.47e-322, -3.3999999999999866e+39 ], + 'MinMaxValueExclusiveDecimal128': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinValueDecimal128': [ -2.9e-322, -3.34565396186043e-292, -1.6090819601980502e-136, 2.47e-322, -3.3999999999999866e+39 + ], + 'MinValueExclusiveDecimal128': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 ] }; diff --git a/test/snapshots/float32/arbitraries.js b/test/snapshots/float32/arbitraries.js index b0588f9..2ecc61c 100644 --- a/test/snapshots/float32/arbitraries.js +++ b/test/snapshots/float32/arbitraries.js @@ -4,13 +4,26 @@ export const Float32 = fc.float(); export const MinValueFloat32 = fc.float({ min: -3.140000104904175 }); -export const MinValue0Float32 = fc.float({ min: 0 }); +export const MinValueExclusiveFloat32 = fc.float({ minExclusive: -3.140000104904175 }); + +export const Min0ValueFloat32 = fc.float({ min: 0 }); + +export const Min0ValueExclusiveFloat32 = fc.float({ minExclusive: 0 }); export const MaxValueFloat32 = fc.float({ max: 3.140000104904175 }); +export const MaxValueExclusiveFloat32 = fc.float({ maxExclusive: 3.140000104904175 }); + export const MinMaxValueFloat32 = fc.float({ min: -3.140000104904175, max: 3.140000104904175, }); +export const MinMaxValueExclusiveFloat32 = fc.float({ + minExclusive: -3.140000104904175, + maxExclusive: 3.140000104904175, +}); + export const RedundantlyMinMaxValueFloat32 = fc.float(); + +export const RedundantlyMinMaxValueExclusiveFloat32 = fc.float(); diff --git a/test/snapshots/float32/samples.js b/test/snapshots/float32/samples.js index 94ee3dd..1e6ae1e 100644 --- a/test/snapshots/float32/samples.js +++ b/test/snapshots/float32/samples.js @@ -6,6 +6,13 @@ export const samples = { 4.0637655465419695e-44, -3.4028232635611926e+38 ], + 'MaxValueExclusiveFloat32': [ + -2.382207389352189e-44, + -0.0015161603223532438, + -43335017425797120, + 4.0637655465419695e-44, + -3.4028232635611926e+38 + ], 'MaxValueFloat32': [ -2.382207389352189e-44, -0.0015161603223532438, @@ -13,20 +20,41 @@ export const samples = { 4.0637655465419695e-44, -3.4028232635611926e+38 ], - 'MinMaxValueFloat32': [ + 'Min0ValueExclusiveFloat32': [ -2.382207389352189e-44, - 2.824875287313305e-36, - -3.7540254697494886e-22, + -0.0015161603223532438, + -43335017425797120, 4.0637655465419695e-44, - -3.1399996280670166 + -3.4028232635611926e+38 ], - 'MinValue0Float32': [ + 'Min0ValueFloat32': [ 3.402819612727464e+38, 1482.190673828125, 4.98826437665326e-17, 8.407790785948902e-45, 3.4028181929587916e+38 ], + 'MinMaxValueExclusiveFloat32': [ + -2.382207389352189e-44, + -0.0015161603223532438, + -43335017425797120, + 4.0637655465419695e-44, + -3.4028232635611926e+38 + ], + 'MinMaxValueFloat32': [ + -2.382207389352189e-44, + 2.824875287313305e-36, + -3.7540254697494886e-22, + 4.0637655465419695e-44, + -3.1399996280670166 + ], + 'MinValueExclusiveFloat32': [ + -2.382207389352189e-44, + -0.0015161603223532438, + -43335017425797120, + 4.0637655465419695e-44, + -3.4028232635611926e+38 + ], 'MinValueFloat32': [ -2.382207389352189e-44, 2.824875287313305e-36, @@ -34,6 +62,13 @@ export const samples = { 4.0637655465419695e-44, -3.1399996280670166 ], + 'RedundantlyMinMaxValueExclusiveFloat32': [ + -2.382207389352189e-44, + -0.0015161603223532438, + -43335017425797120, + 4.0637655465419695e-44, + -3.4028232635611926e+38 + ], 'RedundantlyMinMaxValueFloat32': [ -2.382207389352189e-44, -0.0015161603223532438, diff --git a/test/snapshots/float64/arbitraries.js b/test/snapshots/float64/arbitraries.js index c2bdd9d..79c7a56 100644 --- a/test/snapshots/float64/arbitraries.js +++ b/test/snapshots/float64/arbitraries.js @@ -4,9 +4,18 @@ export const Float64 = fc.double(); export const MinValueFloat64 = fc.double({ min: -3.4e+39 }); +export const MinValueExclusiveFloat64 = fc.double({ minExclusive: -3.4e+39 }); + export const MaxValueFloat64 = fc.double({ max: 3.4e+39 }); +export const MaxValueExclusiveFloat64 = fc.double({ maxExclusive: 3.4e+39 }); + export const MinMaxValueFloat64 = fc.double({ min: -3.4e+39, max: 3.4e+39, }); + +export const MinMaxValueExclusiveFloat64 = fc.double({ + minExclusive: -3.4e+39, + maxExclusive: 3.4e+39, +}); diff --git a/test/snapshots/float64/samples.js b/test/snapshots/float64/samples.js index f110eea..c1959f4 100644 --- a/test/snapshots/float64/samples.js +++ b/test/snapshots/float64/samples.js @@ -6,6 +6,13 @@ export const samples = { 2.47e-322, -1.7976931348623115e+308 ], + 'MaxValueExclusiveFloat64': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MaxValueFloat64': [ -2.9e-322, -1.8798639108070244e-23, @@ -13,6 +20,13 @@ export const samples = { 2.47e-322, -1.7976931348623115e+308 ], + 'MinMaxValueExclusiveFloat64': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinMaxValueFloat64': [ -2.9e-322, -3.34565396186043e-292, @@ -20,6 +34,13 @@ export const samples = { 2.47e-322, -3.3999999999999866e+39 ], + 'MinValueExclusiveFloat64': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinValueFloat64': [ -2.9e-322, -3.34565396186043e-292, diff --git a/test/snapshots/int16/arbitraries.js b/test/snapshots/int16/arbitraries.js index 7f51ff4..2a9d821 100644 --- a/test/snapshots/int16/arbitraries.js +++ b/test/snapshots/int16/arbitraries.js @@ -12,16 +12,35 @@ export const MinValueInt16 = fc.integer({ max: 32767, }); +export const MinValueExclusiveInt16 = fc.integer({ + min: -199, + max: 32767, +}); + export const Min0ValueInt16 = fc.nat({ max: 32767 }); +export const MinNegative1ValueExclusiveInt16 = fc.nat({ max: 32767 }); + export const MaxValueInt16 = fc.integer({ min: -32768, max: 345, }); +export const MaxValueExclusiveInt16 = fc.integer({ + min: -32768, + max: 344, +}); + export const MinMaxValueInt16 = fc.integer({ min: -200, max: 345, }); +export const MinMaxValueExclusiveInt16 = fc.integer({ + min: -199, + max: 344, +}); + export const RedundantlyMinMaxValueInt16 = int16; + +export const RedundantlyMinMaxValueExclusiveInt16 = int16; diff --git a/test/snapshots/int16/samples.js b/test/snapshots/int16/samples.js index 2ef84a7..bbabe47 100644 --- a/test/snapshots/int16/samples.js +++ b/test/snapshots/int16/samples.js @@ -6,6 +6,13 @@ export const samples = { -5, -32762 ], + 'MaxValueExclusiveInt16': [ + -7, + -1521, + -2329, + -5, + -32762 + ], 'MaxValueInt16': [ -7, -3226, @@ -20,6 +27,13 @@ export const samples = { 10, 32760 ], + 'MinMaxValueExclusiveInt16': [ + 1, + -173, + -127, + -5, + -193 + ], 'MinMaxValueInt16': [ 1, 26, @@ -27,6 +41,20 @@ export const samples = { -5, -194 ], + 'MinNegative1ValueExclusiveInt16': [ + 32767, + 17946, + 2824, + 10, + 32760 + ], + 'MinValueExclusiveInt16': [ + -5, + 4737, + 19332, + 13, + -193 + ], 'MinValueInt16': [ -5, 2730, @@ -34,6 +62,13 @@ export const samples = { 13, -194 ], + 'RedundantlyMinMaxValueExclusiveInt16': [ + -1, + -14822, + -29944, + -5, + -32762 + ], 'RedundantlyMinMaxValueInt16': [ -1, -14822, diff --git a/test/snapshots/int32/arbitraries.js b/test/snapshots/int32/arbitraries.js index 296de8a..634db11 100644 --- a/test/snapshots/int32/arbitraries.js +++ b/test/snapshots/int32/arbitraries.js @@ -4,13 +4,26 @@ export const Int32 = fc.integer(); export const MinValueInt32 = fc.integer({ min: -40000 }); +export const MinValueExclusiveInt32 = fc.integer({ min: -39999 }); + export const Min0ValueInt32 = fc.nat(); +export const MinNegative1ValueExclusiveInt32 = fc.nat(); + export const MaxValueInt32 = fc.integer({ max: 40000 }); +export const MaxValueExclusiveInt32 = fc.integer({ max: 39999 }); + export const MinMaxValueInt32 = fc.integer({ min: -40000, max: 40000, }); +export const MinMaxValueExclusiveInt32 = fc.integer({ + min: -39999, + max: 39999, +}); + export const RedundantlyMinMaxValueInt32 = fc.integer(); + +export const RedundantlyMinMaxValueExclusiveInt32 = fc.integer(); diff --git a/test/snapshots/int32/samples.js b/test/snapshots/int32/samples.js index e10a034..0790b3f 100644 --- a/test/snapshots/int32/samples.js +++ b/test/snapshots/int32/samples.js @@ -6,6 +6,13 @@ export const samples = { -25, -2147483626 ], + 'MaxValueExclusiveInt32': [ + 1, + -994490854, + -1536816376, + -8, + -2147483626 + ], 'MaxValueInt32': [ 1, -994490854, @@ -20,6 +27,13 @@ export const samples = { 6, 2147483619 ], + 'MinMaxValueExclusiveInt32': [ + -6, + 7207, + -5094, + -9, + -39993 + ], 'MinMaxValueInt32': [ -6, -21618, @@ -27,6 +41,20 @@ export const samples = { -9, -39994 ], + 'MinNegative1ValueExclusiveInt32': [ + 2147483626, + 1152992794, + 610667272, + 6, + 2147483619 + ], + 'MinValueExclusiveInt32': [ + -9, + 1152952795, + 610627273, + 3, + -39993 + ], 'MinValueInt32': [ -9, 1152952794, @@ -34,6 +62,13 @@ export const samples = { 3, -39994 ], + 'RedundantlyMinMaxValueExclusiveInt32': [ + 9, + -994490854, + -1536816376, + -25, + -2147483626 + ], 'RedundantlyMinMaxValueInt32': [ 9, -994490854, diff --git a/test/snapshots/int64/arbitraries.js b/test/snapshots/int64/arbitraries.js index 1bb53d2..e8b89ec 100644 --- a/test/snapshots/int64/arbitraries.js +++ b/test/snapshots/int64/arbitraries.js @@ -10,7 +10,17 @@ export const MinValueInt64 = fc.bigInt({ max: 9223372036854775807n, }); +export const MinValueExclusiveInt64 = fc.bigInt({ + min: 2147483651n, + max: 9223372036854775807n, +}); + export const MaxValueInt64 = fc.bigInt({ min: -9223372036854775808n, max: 2147483650n, }); + +export const MaxValueExclusiveInt64 = fc.bigInt({ + min: -9223372036854775808n, + max: 2147483649n, +}); diff --git a/test/snapshots/int64/samples.js b/test/snapshots/int64/samples.js index 4083baa..b8c14fd 100644 --- a/test/snapshots/int64/samples.js +++ b/test/snapshots/int64/samples.js @@ -6,6 +6,13 @@ export const samples = { 12n, -9223372036854775806n ], + 'MaxValueExclusiveInt64': [ + -5n, + -4271305692530446374n, + -6600576071973771910n, + -9n, + -9223372036854775806n + ], 'MaxValueInt64': [ -5n, -4271305692530446374n, @@ -13,6 +20,13 @@ export const samples = { -9n, -9223372036854775806n ], + 'MinValueExclusiveInt64': [ + 9223372036854775792n, + 4952066346471813085n, + 2622795967028487549n, + 2147483661n, + 9223372036854775790n + ], 'MinValueInt64': [ 9223372036854775792n, 4952066346471813084n, diff --git a/test/snapshots/int8/arbitraries.js b/test/snapshots/int8/arbitraries.js index cc5da49..63cac11 100644 --- a/test/snapshots/int8/arbitraries.js +++ b/test/snapshots/int8/arbitraries.js @@ -12,16 +12,35 @@ export const MinValueInt8 = fc.integer({ max: 127, }); +export const MinValueExclusiveInt8 = fc.integer({ + min: -9, + max: 127, +}); + export const Min0ValueInt8 = fc.nat({ max: 127 }); +export const MinNegative1ValueExclusiveInt8 = fc.nat({ max: 127 }); + export const MaxValueInt8 = fc.integer({ min: -128, max: 20, }); +export const MaxValueExclusiveInt8 = fc.integer({ + min: -128, + max: 19, +}); + export const MinMaxValueInt8 = fc.integer({ min: -10, max: 20, }); +export const MinMaxValueExclusiveInt8 = fc.integer({ + min: -9, + max: 19, +}); + export const RedundantlyMinMaxValueInt8 = int8; + +export const RedundantlyMinMaxValueExclusiveInt8 = int8; diff --git a/test/snapshots/int8/samples.js b/test/snapshots/int8/samples.js index 1775dfb..40cbb20 100644 --- a/test/snapshots/int8/samples.js +++ b/test/snapshots/int8/samples.js @@ -6,6 +6,13 @@ export const samples = { -7, -122 ], + 'MaxValueExclusiveInt8': [ + 1, + -2, + -96, + 3, + -122 + ], 'MaxValueInt8': [ 1, -28, @@ -20,6 +27,13 @@ export const samples = { 0, 127 ], + 'MinMaxValueExclusiveInt8': [ + -3, + -3, + -5, + -1, + -7 + ], 'MinMaxValueInt8': [ -3, 19, @@ -27,6 +41,20 @@ export const samples = { -1, -8 ], + 'MinNegative1ValueExclusiveInt8': [ + 123, + 26, + 8, + 0, + 127 + ], + 'MinValueExclusiveInt8': [ + 1, + 100, + 38, + -3, + -7 + ], 'MinValueInt8': [ 1, 24, @@ -34,6 +62,13 @@ export const samples = { -3, -8 ], + 'RedundantlyMinMaxValueExclusiveInt8': [ + -5, + -102, + -120, + -7, + -122 + ], 'RedundantlyMinMaxValueInt8': [ -5, -102, diff --git a/test/snapshots/integer/arbitraries.js b/test/snapshots/integer/arbitraries.js index ccca74c..3c47b95 100644 --- a/test/snapshots/integer/arbitraries.js +++ b/test/snapshots/integer/arbitraries.js @@ -4,11 +4,22 @@ export const Integer = fc.bigInt(); export const MinValueInteger = fc.bigInt({ min: 92233720368547758000n }); -export const MinValue0Integer = fc.bigInt({ min: 0n }); +export const MinValueExclusiveInteger = fc.bigInt({ min: 92233720368547758001n }); + +export const Min0ValueInteger = fc.bigInt({ min: 0n }); + +export const MinNegative1ValueExclusiveInteger = fc.bigInt({ min: 2n }); export const MaxValueInteger = fc.bigInt({ max: 922337203685477580000n }); +export const MaxValueExclusiveInteger = fc.bigInt({ max: 922337203685477579999n }); + export const MinMaxValueInteger = fc.bigInt({ min: 92233720368547758000n, max: 922337203685477580000n, }); + +export const MinMaxValueExclusiveInteger = fc.bigInt({ + min: 92233720368547758001n, + max: 922337203685477579999n, +}); diff --git a/test/snapshots/integer/samples.js b/test/snapshots/integer/samples.js index 8135239..c6f49c5 100644 --- a/test/snapshots/integer/samples.js +++ b/test/snapshots/integer/samples.js @@ -6,6 +6,13 @@ export const samples = { 53n, -57896044618658097711785492504343953926634992332820282019728792003956564819904n ], + 'MaxValueExclusiveInteger': [ + -75n, + -26811420374949873220459578427973905722491267353767128852212759259818188893304n, + -41432487515938364327065946798100351211572912006011611184534856508514021872561n, + -46n, + -57896044618658097711785492504343953926634992332820282019728792003956564819904n + ], 'MaxValueInteger': [ -75n, -26811420374949873220459578427973905722491267353767128852212759259818188893304n, @@ -13,6 +20,20 @@ export const samples = { -46n, -57896044618658097711785492504343953926634992332820282019728792003956564819904n ], + 'Min0ValueInteger': [ + 57896044618658097711785492504343953926634992332820282019728792003956564819952n, + 31084624243708224491325914076370048204143724979053153167516032744138375926664n, + 16463557102719733384719545706243602715062080326808670835193935495442542947407n, + 70n, + 57896044618658097711785492504343953926634992332820282019728792003956564819954n + ], + 'MinMaxValueExclusiveInteger': [ + 922337203685477579980n, + 172766648957076081654n, + 787233548574112396934n, + 92233720368547758021n, + 922337203685477579978n + ], 'MinMaxValueInteger': [ 922337203685477579981n, 172766648957024837529n, @@ -20,12 +41,19 @@ export const samples = { 92233720368547758020n, 922337203685477579979n ], - 'MinValue0Integer': [ - 57896044618658097711785492504343953926634992332820282019728792003956564819952n, - 31084624243708224491325914076370048204143724979053153167516032744138375926664n, - 16463557102719733384719545706243602715062080326808670835193935495442542947407n, - 70n, - 57896044618658097711785492504343953926634992332820282019728792003956564819954n + 'MinNegative1ValueExclusiveInteger': [ + 57896044618658097711785492504343953926634992332820282019728792003956564819956n, + 31084624243708224491325914076370048204143724979053153167516032744138375926666n, + 16463557102719733384719545706243602715062080326808670835193935495442542947409n, + 72n, + 57896044618658097711785492504343953926634992332820282019728792003956564819958n + ], + 'MinValueExclusiveInteger': [ + 57896044618658097711785492504343953935142051505843743591740229371520224335953n, + 31084624243708224491325914076370048204143724979053153167608266464506923684665n, + 16463557102719733384719545706243602715062080326808670835286169215811090705408n, + 92233720368547758071n, + 57896044618658097711785492504343953935142051505843743591740229371520224335955n ], 'MinValueInteger': [ 57896044618658097711785492504343953935142051505843743591555761930783128819952n, diff --git a/test/snapshots/numeric/arbitraries.js b/test/snapshots/numeric/arbitraries.js index f6b218e..17b366c 100644 --- a/test/snapshots/numeric/arbitraries.js +++ b/test/snapshots/numeric/arbitraries.js @@ -4,13 +4,22 @@ export const Numeric = fc.double(); export const MinValueNumeric = fc.double({ min: -3.4e+39 }); +export const MinValueExclusiveNumeric = fc.double({ minExclusive: -3.4e+39 }); + export const MaxValueNumeric = fc.double({ max: 3.4e+39 }); +export const MaxValueExclusiveNumeric = fc.double({ maxExclusive: 3.4e+39 }); + export const MinMaxValueNumeric = fc.double({ min: -3.4e+39, max: 3.4e+39, }); +export const MinMaxValueExclusiveNumeric = fc.double({ + minExclusive: -3.4e+39, + maxExclusive: 3.4e+39, +}); + export const $Model = fc.record({ a: fc.constant(1), b: fc.constant(2), diff --git a/test/snapshots/numeric/samples.js b/test/snapshots/numeric/samples.js index fbd0956..2a6f4e5 100644 --- a/test/snapshots/numeric/samples.js +++ b/test/snapshots/numeric/samples.js @@ -26,6 +26,13 @@ export const samples = { 'c': 2.2 } ], + 'MaxValueExclusiveNumeric': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MaxValueNumeric': [ -2.9e-322, -1.8798639108070244e-23, @@ -33,6 +40,13 @@ export const samples = { 2.47e-322, -1.7976931348623115e+308 ], + 'MinMaxValueExclusiveNumeric': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinMaxValueNumeric': [ -2.9e-322, -3.34565396186043e-292, @@ -40,6 +54,13 @@ export const samples = { 2.47e-322, -3.3999999999999866e+39 ], + 'MinValueExclusiveNumeric': [ + -2.9e-322, + -1.8798639108070244e-23, + -9.212148074874359e+132, + 2.47e-322, + -1.7976931348623115e+308 + ], 'MinValueNumeric': [ -2.9e-322, -3.34565396186043e-292, diff --git a/test/snapshots/safeint/arbitraries.js b/test/snapshots/safeint/arbitraries.js index 5a0b43d..977b1b8 100644 --- a/test/snapshots/safeint/arbitraries.js +++ b/test/snapshots/safeint/arbitraries.js @@ -7,19 +7,41 @@ export const MinValueSafeInt = fc.integer({ max: 9007199254740991, }); +export const MinValueExclusiveSafeInt = fc.integer({ + min: -39999, + max: 9007199254740991, +}); + export const Min0ValueSafeInt = fc.maxSafeNat(); +export const MinNegative1ValueExclusiveSafeInt = fc.maxSafeNat(); + export const MaxValueSafeInt = fc.integer({ min: -9007199254740991, max: 40000, }); +export const MaxValueExclusiveSafeInt = fc.integer({ + min: -9007199254740991, + max: 39999, +}); + export const MinMaxValueSafeInt = fc.integer({ min: -40000, max: 40000, }); +export const MinMaxValueExclusiveSafeInt = fc.integer({ + min: -39999, + max: 39999, +}); + export const RedundantlyMinMaxValueSafeInt = fc.integer({ min: -2147483650, max: 2147483650, }); + +export const RedundantlyMinMaxValueExclusiveSafeInt = fc.integer({ + min: -2147483649, + max: 2147483649, +}); diff --git a/test/snapshots/safeint/samples.js b/test/snapshots/safeint/samples.js index f6a211a..5535a3f 100644 --- a/test/snapshots/safeint/samples.js +++ b/test/snapshots/safeint/samples.js @@ -1,4 +1,11 @@ export const samples = { + 'MaxValueExclusiveSafeInt': [ + -24, + -1895603720261669, + -7307467338848901, + 11, + -9007199254740945 + ], 'MaxValueSafeInt': [ -24, -1895603720261669, @@ -13,6 +20,13 @@ export const samples = { 4, 9007199254740984 ], + 'MinMaxValueExclusiveSafeInt': [ + -6, + 7207, + -5094, + -9, + -39993 + ], 'MinMaxValueSafeInt': [ -6, -21618, @@ -20,6 +34,20 @@ export const samples = { -9, -39994 ], + 'MinNegative1ValueExclusiveSafeInt': [ + 9007199254740940, + 7111595534479322, + 1699731915892090, + 4, + 9007199254740984 + ], + 'MinValueExclusiveSafeInt': [ + 14, + 7111595534439323, + 1699731915852091, + 49, + -39993 + ], 'MinValueSafeInt': [ 14, 7111595534439322, @@ -27,6 +55,13 @@ export const samples = { 49, -39994 ], + 'RedundantlyMinMaxValueExclusiveSafeInt': [ + -29, + -576819239, + 755983737, + 18, + -2147483627 + ], 'RedundantlyMinMaxValueSafeInt': [ -29, -576819240,