From b51071942dfbab6f406d39e88915474cdea0d0cd Mon Sep 17 00:00:00 2001 From: Irfan Bunjaku Date: Tue, 17 Jun 2025 15:37:04 +0200 Subject: [PATCH] [RAI-38714] Remove Rational test cases --- README.md | 2 - src/results/resultUtils.test.ts | 12 - src/results/resultUtils.ts | 71 ---- src/results/tests.ts | 608 -------------------------------- src/results/types.ts | 50 --- 5 files changed, 743 deletions(-) diff --git a/README.md b/README.md index f996376..4099c89 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,6 @@ their corresponding JavaScript equivalents. Full mapping: | UInt8, UInt16, UInt32 | number | | UInt64, UInt128 | bigint | | Float16, Float32, Float64 | number | -| Rational8, Rational16, Rational32 | `{ numerator: number; denominator: number; }` | -| Rational64, Rational128 | `{ numerator: bigint; denominator: bigint; }` | | FixedDecimal all bit sizes(16, 32, 64, 128) | [decimal.js](https://github.com/MikeMcl/decimal.js/) | | Char | string | | String | string | diff --git a/src/results/resultUtils.test.ts b/src/results/resultUtils.test.ts index 7dc8cf7..e80caef 100644 --- a/src/results/resultUtils.test.ts +++ b/src/results/resultUtils.test.ts @@ -31,18 +31,6 @@ describe('resultUtils', () => { ).toEqual('String(:foo)'); }); - it('should get display name for rational constant type def', () => { - expect( - getDisplayName({ - type: 'Constant', - value: { - type: 'Rational32', - value: { numerator: 1, denominator: 2 }, - }, - }), - ).toEqual('Rational32(1/2)'); - }); - it('should get display name for value type type def', () => { expect( getDisplayName({ diff --git a/src/results/resultUtils.ts b/src/results/resultUtils.ts index 56a5591..fcd4b3c 100644 --- a/src/results/resultUtils.ts +++ b/src/results/resultUtils.ts @@ -227,25 +227,6 @@ export function convertValue( Math.pow(10, typeDef.places), ); } - case 'Rational8': - case 'Rational16': - case 'Rational32': - case 'Rational64': { - value = Array.from(value); - - return { - numerator: value[0], - denominator: value[1], - }; - } - case 'Rational128': { - value = Array.from(value); - - return { - numerator: int128ToBigInt(Array.from(value[0])), - denominator: int128ToBigInt(Array.from(value[1])), - }; - } case 'Constant': { return typeDef.value.value; } @@ -357,12 +338,6 @@ export function getDisplayValue( case 'Decimal64': case 'Decimal128': return val.value.toFixed(val.places); - case 'Rational8': - case 'Rational16': - case 'Rational32': - case 'Rational64': - case 'Rational128': - return `${val.value.numerator}/${val.value.denominator}`; case 'ValueType': { const displayValue = val.typeDefs .map((td, index) => { @@ -536,47 +511,6 @@ function mapValueType(typeDef: Omit): RelTypeDef { } break; } - case 'Rational': { - // TODO remove later, this's legacy Rational representation - if (typeDef.typeDefs.length === 5 && typeDef.typeDefs[3]) { - const tp = typeDef.typeDefs[3]; - - switch (tp.type) { - case 'Int8': - return { type: 'Rational8' }; - case 'Int16': - return { type: 'Rational16' }; - case 'Int32': - return { type: 'Rational32' }; - case 'Int64': - return { type: 'Rational64' }; - case 'Int128': - return { type: 'Rational128' }; - } - } - - if ( - typeDef.typeDefs.length === 6 && - typeDef.typeDefs[3] && - typeDef.typeDefs[3].type === 'Constant' && - typeDef.typeDefs[3].value.type === 'Int64' - ) { - const bits = typeDef.typeDefs[3].value.value; - - switch (bits) { - case 8n: - return { type: 'Rational8' }; - case 16n: - return { type: 'Rational16' }; - case 32n: - return { type: 'Rational32' }; - case 64n: - return { type: 'Rational64' }; - case 128n: - return { type: 'Rational128' }; - } - } - } } return typeDef; @@ -601,11 +535,6 @@ function unflattenConstantValue(typeDef: RelTypeDef, value: PrimitiveValue[]) { case 'Missing': result.push(null); break; - case 'Rational8': - case 'Rational16': - case 'Rational32': - case 'Rational64': - case 'Rational128': case 'SHA1': // These types take 2 values result.push(values.splice(0, 2)); diff --git a/src/results/tests.ts b/src/results/tests.ts index e742ec5..86044f0 100644 --- a/src/results/tests.ts +++ b/src/results/tests.ts @@ -496,86 +496,6 @@ export const standardTypeTests: Test[] = [ values: [new Decimal('123456789010111213141516171819202122.34')], displayValues: ['123456789010111213141516171819202122.34'], }, - { - name: 'Rational8', - query: `def output {rational[8, 1, 2]}`, - typeDefs: [ - { - type: 'Rational8', - }, - ], - values: [ - { - numerator: 1, - denominator: 2, - }, - ], - displayValues: ['1/2'], - }, - { - name: 'Rational16', - query: `def output {rational[16, 1, 2]}`, - typeDefs: [ - { - type: 'Rational16', - }, - ], - values: [ - { - numerator: 1, - denominator: 2, - }, - ], - displayValues: ['1/2'], - }, - { - name: 'Rational32', - query: `def output {rational[32, 1, 2]}`, - typeDefs: [ - { - type: 'Rational32', - }, - ], - values: [ - { - numerator: 1, - denominator: 2, - }, - ], - displayValues: ['1/2'], - }, - { - name: 'Rational64', - query: `def output {rational[64, 1, 2]}`, - typeDefs: [ - { - type: 'Rational64', - }, - ], - values: [ - { - numerator: 1n, - denominator: 2n, - }, - ], - displayValues: ['1/2'], - }, - { - name: 'Rational128', - query: `def output {rational[128, 123456789101112313, 9123456789101112313]}`, - typeDefs: [ - { - type: 'Rational128', - }, - ], - values: [ - { - numerator: 123456789101112313n, - denominator: 9123456789101112313n, - }, - ], - displayValues: ['123456789101112313/9123456789101112313'], - }, { name: 'UUID', query: ` @@ -1283,124 +1203,6 @@ export const specializationTests: Test[] = [ values: [new Decimal('123456789010111213141516171819202122.34')], displayValues: ['123456789010111213141516171819202122.34'], }, - { - name: 'Rational8', - values: [ - { - numerator: 1, - denominator: 2, - }, - ], - typeDefs: [ - { - type: 'Constant', - value: { - type: 'Rational8', - value: { numerator: 1, denominator: 2 }, - }, - }, - ], - query: ` - def v {rational[8, 1, 2]} - def output {::std::mirror::lift[v]} - `, - displayValues: ['1/2'], - }, - { - name: 'Rational16', - query: ` - def v {rational[16, 1, 2]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'Rational16', - value: { numerator: 1, denominator: 2 }, - }, - }, - ], - values: [ - { - numerator: 1, - denominator: 2, - }, - ], - displayValues: ['1/2'], - }, - { - name: 'Rational32', - query: ` - def v {rational[32, 1, 2]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'Rational32', - value: { numerator: 1, denominator: 2 }, - }, - }, - ], - values: [ - { - numerator: 1, - denominator: 2, - }, - ], - displayValues: ['1/2'], - }, - { - name: 'Rational64', - query: ` - def v {rational[64, 1, 2]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'Rational64', - value: { numerator: 1n, denominator: 2n }, - }, - }, - ], - values: [ - { - numerator: 1n, - denominator: 2n, - }, - ], - displayValues: ['1/2'], - }, - { - name: 'Rational128', - query: ` - def v {rational[128, 123456789101112313, 9123456789101112313]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'Rational128', - value: { - numerator: 123456789101112313n, - denominator: 9123456789101112313n, - }, - }, - }, - ], - values: [ - { - numerator: 123456789101112313n, - denominator: 9123456789101112313n, - }, - ], - displayValues: ['123456789101112313/9123456789101112313'], - }, { name: 'UUID', query: ` @@ -2388,181 +2190,6 @@ export const valueTypeTests: Test[] = [ ], displayValues: ['(:MyType, 1, 123456789010111213141516171819202122.34)'], }, - { - name: 'Rational8', - query: ` - value type MyType {(Int, Rational[8])} - def output {^MyType[1, rational[8, 1, 2]]} - `, - typeDefs: [ - { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Int64', - }, - { - type: 'Rational8', - }, - ], - }, - ], - values: [ - [ - ':MyType', - 1n, - { - numerator: 1, - denominator: 2, - }, - ], - ], - displayValues: ['(:MyType, 1, 1/2)'], - }, - { - name: 'Rational16', - query: ` - value type MyType {(Int, Rational[16])} - def output {^MyType[1, rational[16, 1, 2]]} - `, - typeDefs: [ - { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Int64', - }, - { - type: 'Rational16', - }, - ], - }, - ], - values: [ - [ - ':MyType', - 1n, - { - numerator: 1, - denominator: 2, - }, - ], - ], - displayValues: ['(:MyType, 1, 1/2)'], - }, - { - name: 'Rational32', - query: ` - value type MyType {(Int, Rational[32])} - def output {^MyType[1, rational[32, 1, 2]]} - `, - typeDefs: [ - { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Int64', - }, - { - type: 'Rational32', - }, - ], - }, - ], - values: [ - [ - ':MyType', - 1n, - { - numerator: 1, - denominator: 2, - }, - ], - ], - displayValues: ['(:MyType, 1, 1/2)'], - }, - { - name: 'Rational64', - query: ` - value type MyType {(Int, Rational[64])} - def output {^MyType[1, rational[64, 1, 2]]} - `, - typeDefs: [ - { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Int64', - }, - { - type: 'Rational64', - }, - ], - }, - ], - values: [ - [ - ':MyType', - 1n, - { - numerator: 1n, - denominator: 2n, - }, - ], - ], - displayValues: ['(:MyType, 1, 1/2)'], - }, - { - name: 'Rational128', - query: ` - value type MyType {(Int, Rational[128])} - def output {^MyType[1, rational[128, 123456789101112313, 9123456789101112313]]} - `, - typeDefs: [ - { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Int64', - }, - { - type: 'Rational128', - }, - ], - }, - ], - values: [ - [ - ':MyType', - 1n, - { - numerator: 123456789101112313n, - denominator: 9123456789101112313n, - }, - ], - ], - displayValues: ['(:MyType, 1, 123456789101112313/9123456789101112313)'], - }, { name: 'UUID', query: ` @@ -3903,241 +3530,6 @@ export const valueTypeSpecializationTests: Test[] = [ ], displayValues: ['(:MyType, 123456789010111213141516171819202122.34, 1)'], }, - { - name: 'Rational8', - query: ` - value type MyType {(Rational[8], Int)} - def v {^MyType[rational[8, 1, 2], 1]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Rational8', - }, - { - type: 'Int64', - }, - ], - value: [ - ':MyType', - { - numerator: 1, - denominator: 2, - }, - 1n, - ], - }, - }, - ], - values: [ - [ - ':MyType', - { - numerator: 1, - denominator: 2, - }, - 1n, - ], - ], - displayValues: ['(:MyType, 1/2, 1)'], - }, - { - name: 'Rational16', - query: ` - value type MyType {(Rational[16], Int)} - def v {^MyType[rational[16, 1, 2], 1]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Rational16', - }, - { - type: 'Int64', - }, - ], - value: [ - ':MyType', - { - numerator: 1, - denominator: 2, - }, - 1n, - ], - }, - }, - ], - values: [ - [ - ':MyType', - { - numerator: 1, - denominator: 2, - }, - 1n, - ], - ], - displayValues: ['(:MyType, 1/2, 1)'], - }, - { - name: 'Rational32', - query: ` - value type MyType {(Rational[32], Int)} - def v {^MyType[rational[32, 1, 2], 1]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Rational32', - }, - { - type: 'Int64', - }, - ], - value: [ - ':MyType', - { - numerator: 1, - denominator: 2, - }, - 1n, - ], - }, - }, - ], - values: [ - [ - ':MyType', - { - numerator: 1, - denominator: 2, - }, - 1n, - ], - ], - displayValues: ['(:MyType, 1/2, 1)'], - }, - { - name: 'Rational64', - query: ` - value type MyType {(Rational[64], Int)} - def v {^MyType[rational[64, 1, 2], 1]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Rational64', - }, - { - type: 'Int64', - }, - ], - value: [ - ':MyType', - { - numerator: 1n, - denominator: 2n, - }, - 1n, - ], - }, - }, - ], - values: [ - [ - ':MyType', - { - numerator: 1n, - denominator: 2n, - }, - 1n, - ], - ], - displayValues: ['(:MyType, 1/2, 1)'], - }, - { - name: 'Rational128', - query: ` - value type MyType {(Rational[128], Int)} - def v {^MyType[rational[128, 123456789101112313, 9123456789101112313], 1]} - def output {::std::mirror::lift[v]} - `, - typeDefs: [ - { - type: 'Constant', - value: { - type: 'ValueType', - typeDefs: [ - { - type: 'Constant', - value: { type: 'String', value: ':MyType' }, - }, - { - type: 'Rational128', - }, - { - type: 'Int64', - }, - ], - value: [ - ':MyType', - { - numerator: 123456789101112313n, - denominator: 9123456789101112313n, - }, - 1n, - ], - }, - }, - ], - values: [ - [ - ':MyType', - { - numerator: 123456789101112313n, - denominator: 9123456789101112313n, - }, - 1n, - ], - ], - displayValues: ['(:MyType, 123456789101112313/9123456789101112313, 1)'], - }, { name: 'UUID', query: ` diff --git a/src/results/types.ts b/src/results/types.ts index 9620347..ed0a28d 100644 --- a/src/results/types.ts +++ b/src/results/types.ts @@ -55,11 +55,6 @@ export type RelBaseTypedValue = | Decimal32Value | Decimal64Value | Decimal128Value - | Rational8Value - | Rational16Value - | Rational32Value - | Rational64Value - | Rational128Value | AutoNumber | UUID | SHA1; @@ -102,11 +97,6 @@ export type RelTypeDef = | Omit | Omit | Omit - | Omit - | Omit - | Omit - | Omit - | Omit | Omit | Omit | Omit @@ -304,46 +294,6 @@ export type Decimal128Value = { places: number; }; -export type Rational8Value = { - type: 'Rational8'; - value: { - numerator: number; - denominator: number; - }; -}; - -export type Rational16Value = { - type: 'Rational16'; - value: { - numerator: number; - denominator: number; - }; -}; - -export type Rational32Value = { - type: 'Rational32'; - value: { - numerator: number; - denominator: number; - }; -}; - -export type Rational64Value = { - type: 'Rational64'; - value: { - numerator: bigint; - denominator: bigint; - }; -}; - -export type Rational128Value = { - type: 'Rational128'; - value: { - numerator: bigint; - denominator: bigint; - }; -}; - export type AutoNumber = { type: 'AutoNumber'; value: bigint;