diff --git a/src/__tests__/vm.test.ts b/src/__tests__/vm.test.ts index 24e8391..169961e 100644 --- a/src/__tests__/vm.test.ts +++ b/src/__tests__/vm.test.ts @@ -1,3 +1,4 @@ +import type { Recurse } from "../util"; import type { Brainfuck } from "../vm"; import type { Assert, Equal } from "./assert"; @@ -29,3 +30,24 @@ type Output_2 = Brainfuck; export type Test_Brainfuck_2 = Assert< Equal >; + +type Repeat = Recurse>; +type RepeatSub< + S extends string, + N extends number, + R extends string, + L extends unknown[], +> = L["length"] extends N ? R : { __rec: RepeatSub }; + +type Reverse = Recurse>; +// prettier-ignore +type ReverseSub = + S extends "" ? R + : S extends `${infer A}${infer B}` ? { __rec: ReverseSub } + : never; + +type Program_3 = ">,[>,]<[.<]"; +type Input_3 = Repeat<"ABCD", 1000>; +type Output_3 = Brainfuck; +type Expected_3 = Reverse; +export type Test_Brainfuck_3 = Assert>;