mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-12 02:58:53 -06:00
Add union types (#1417)
A union type is a compound type with 0 or more types. Its noms serialization is UnionKind, <number-of-types>, T0, ..., TN Its HRS is T0 | T1 | ... | TN Towards #1311
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
makeMapType,
|
||||
makeSetType,
|
||||
makeStructType,
|
||||
makeUnionType,
|
||||
stringType,
|
||||
valueType,
|
||||
Type,
|
||||
@@ -43,6 +44,12 @@ suite('Encode human readable types', () => {
|
||||
assertWriteType('Set<Number>', makeSetType(numberType));
|
||||
assertWriteType('Ref<Number>', makeRefType(numberType));
|
||||
assertWriteType('Map<Number, String>', makeMapType(numberType, stringType));
|
||||
|
||||
assertWriteType('Number | String', makeUnionType([numberType, stringType]));
|
||||
assertWriteType('Bool', makeUnionType([boolType]));
|
||||
assertWriteType('', makeUnionType([]));
|
||||
assertWriteType('List<Number | String>', makeListType(makeUnionType([numberType, stringType])));
|
||||
assertWriteType('List<>', makeListType(makeUnionType([])));
|
||||
});
|
||||
|
||||
test('struct', () => {
|
||||
|
||||
Reference in New Issue
Block a user