Skip to content

[RAI-38714] Remove Rational test cases #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
12 changes: 0 additions & 12 deletions src/results/resultUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
71 changes: 0 additions & 71 deletions src/results/resultUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,25 +227,6 @@ export function convertValue<T extends RelTypedValue>(
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;
}
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -536,47 +511,6 @@ function mapValueType(typeDef: Omit<ValueTypeValue, 'value'>): 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;
Expand All @@ -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));
Expand Down
Loading
Loading