Skip to content

Commit d7f7153

Browse files
authored
[RAI-38714] Remove Rational test cases (#113)
Remove testcases for Rationals, as the support for Rational types has been removed.
1 parent 3817209 commit d7f7153

File tree

5 files changed

+0
-743
lines changed

5 files changed

+0
-743
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ their corresponding JavaScript equivalents. Full mapping:
104104
| UInt8, UInt16, UInt32 | number |
105105
| UInt64, UInt128 | bigint |
106106
| Float16, Float32, Float64 | number |
107-
| Rational8, Rational16, Rational32 | `{ numerator: number; denominator: number; }` |
108-
| Rational64, Rational128 | `{ numerator: bigint; denominator: bigint; }` |
109107
| FixedDecimal all bit sizes(16, 32, 64, 128) | [decimal.js](https://github.com/MikeMcl/decimal.js/) |
110108
| Char | string |
111109
| String | string |

src/results/resultUtils.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ describe('resultUtils', () => {
3131
).toEqual('String(:foo)');
3232
});
3333

34-
it('should get display name for rational constant type def', () => {
35-
expect(
36-
getDisplayName({
37-
type: 'Constant',
38-
value: {
39-
type: 'Rational32',
40-
value: { numerator: 1, denominator: 2 },
41-
},
42-
}),
43-
).toEqual('Rational32(1/2)');
44-
});
45-
4634
it('should get display name for value type type def', () => {
4735
expect(
4836
getDisplayName({

src/results/resultUtils.ts

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -227,25 +227,6 @@ export function convertValue<T extends RelTypedValue>(
227227
Math.pow(10, typeDef.places),
228228
);
229229
}
230-
case 'Rational8':
231-
case 'Rational16':
232-
case 'Rational32':
233-
case 'Rational64': {
234-
value = Array.from(value);
235-
236-
return {
237-
numerator: value[0],
238-
denominator: value[1],
239-
};
240-
}
241-
case 'Rational128': {
242-
value = Array.from(value);
243-
244-
return {
245-
numerator: int128ToBigInt(Array.from(value[0])),
246-
denominator: int128ToBigInt(Array.from(value[1])),
247-
};
248-
}
249230
case 'Constant': {
250231
return typeDef.value.value;
251232
}
@@ -357,12 +338,6 @@ export function getDisplayValue(
357338
case 'Decimal64':
358339
case 'Decimal128':
359340
return val.value.toFixed(val.places);
360-
case 'Rational8':
361-
case 'Rational16':
362-
case 'Rational32':
363-
case 'Rational64':
364-
case 'Rational128':
365-
return `${val.value.numerator}/${val.value.denominator}`;
366341
case 'ValueType': {
367342
const displayValue = val.typeDefs
368343
.map((td, index) => {
@@ -536,47 +511,6 @@ function mapValueType(typeDef: Omit<ValueTypeValue, 'value'>): RelTypeDef {
536511
}
537512
break;
538513
}
539-
case 'Rational': {
540-
// TODO remove later, this's legacy Rational representation
541-
if (typeDef.typeDefs.length === 5 && typeDef.typeDefs[3]) {
542-
const tp = typeDef.typeDefs[3];
543-
544-
switch (tp.type) {
545-
case 'Int8':
546-
return { type: 'Rational8' };
547-
case 'Int16':
548-
return { type: 'Rational16' };
549-
case 'Int32':
550-
return { type: 'Rational32' };
551-
case 'Int64':
552-
return { type: 'Rational64' };
553-
case 'Int128':
554-
return { type: 'Rational128' };
555-
}
556-
}
557-
558-
if (
559-
typeDef.typeDefs.length === 6 &&
560-
typeDef.typeDefs[3] &&
561-
typeDef.typeDefs[3].type === 'Constant' &&
562-
typeDef.typeDefs[3].value.type === 'Int64'
563-
) {
564-
const bits = typeDef.typeDefs[3].value.value;
565-
566-
switch (bits) {
567-
case 8n:
568-
return { type: 'Rational8' };
569-
case 16n:
570-
return { type: 'Rational16' };
571-
case 32n:
572-
return { type: 'Rational32' };
573-
case 64n:
574-
return { type: 'Rational64' };
575-
case 128n:
576-
return { type: 'Rational128' };
577-
}
578-
}
579-
}
580514
}
581515

582516
return typeDef;
@@ -601,11 +535,6 @@ function unflattenConstantValue(typeDef: RelTypeDef, value: PrimitiveValue[]) {
601535
case 'Missing':
602536
result.push(null);
603537
break;
604-
case 'Rational8':
605-
case 'Rational16':
606-
case 'Rational32':
607-
case 'Rational64':
608-
case 'Rational128':
609538
case 'SHA1':
610539
// These types take 2 values
611540
result.push(values.splice(0, 2));

0 commit comments

Comments
 (0)