import { tsst, the } from 'tsst-tycho'; import { NumberToString, StringToNumber, TupleToUnion, TupleIndicesToUnion, TupleToObject, TupleToList, NumObjToList, ListToNumObj, BoolToString } from '../src/cast'; import { TestArr } from './fixtures'; describe(`cast`, () => { describe(`NumberToString`, () => { it(`the<'3', NumberToString[3]>`, () => { tsst(() => { the<'3', NumberToString[3]>(); }).expectToCompile(); }); it(`the<'3', NumberToString['3']>`, () => { tsst(() => { the<'3', NumberToString['3']>(); }).expectToCompile(); }); it(`the<'3', NumberToString<3>>`, () => { tsst(() => { the<'3', NumberToString<3>>(); }).expectToFail(); }); it(`the`, () => { tsst(() => { the(); }).expectToCompile(); }); }); describe(`StringToNumber`, () => { it(`the<3, StringToNumber['3']>`, () => { tsst(() => { the<3, StringToNumber['3']>(); }).expectToCompile(); }); it(`the<3, StringToNumber[3]>`, () => { tsst(() => { the<3, StringToNumber[3]>(); }).expectToCompile(); }); it(`the`, () => { tsst(() => { the(); }).expectToCompile(); }); }); describe(`TupleToUnion`, () => { it(`the<"a" | "b" | "c", TupleToUnion>`, () => { tsst(() => { the<"a" | "b" | "c", TupleToUnion>(); }).expectToCompile(); }); }); describe(`TupleIndicesToUnion`, () => { it(`the<0 | 1 | 2, TupleIndicesToUnion>`, () => { tsst(() => { the<0 | 1 | 2, TupleIndicesToUnion>(); }).expectToCompile(); }); }); describe(`TupleToObject`, () => { it(`the<{ 0: "a"; 1: "b"; 2: "c"; }, TupleToObject>`, () => { tsst(() => { the<{ 0: "a"; 1: "b"; 2: "c"; }, TupleToObject>(); }).expectToCompile(); }); }); describe(`TupleToList`, () => { it(`the<{ 0: "a"; 1: "b"; 2: "c"; length: 3; }, TupleToList>`, () => { tsst(() => { the<{ 0: "a"; 1: "b"; 2: "c"; length: 3; }, TupleToList>(); }).expectToCompile(); }); }); describe(`NumObjToList`, () => { it(`the<{ 0: 'a', 1: 'b', length: 2 }, NumObjToList<{ 0: 'a', 1: 'b' }>>`, () => { tsst(() => { the<{ 0: 'a', 1: 'b', length: 2 }, NumObjToList<{ 0: 'a', 1: 'b' }>>(); }).expectToCompile(); }); it(`the<{ 0: 'a', 1: 'b', 2: 'c', length: 3 }, NumObjToList>>`, () => { tsst(() => { the<{ 0: 'a', 1: 'b', 2: 'c', length: 3 }, NumObjToList>>(); }).expectToCompile(); }); }); describe(`ListToNumObj`, () => { it(`the<{ 0: 'a', 1: 'b' }, ListToNumObj<{ 0: 'a', 1: 'b', length: 2 }>>`, () => { tsst(() => { the<{ 0: 'a', 1: 'b' }, ListToNumObj<{ 0: 'a', 1: 'b', length: 2 }>>(); }).expectToCompile(); }); }); describe(`BoolToString`, () => { it(`the<'1', BoolToString>`, () => { tsst(() => { the<'1', BoolToString>(); }).expectToCompile(); }); }); });