Skip to content

Commit

Permalink
refactor(test): don't use reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
susisu committed Apr 27, 2024
1 parent cc5429d commit 18a115b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/vm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,15 @@ describe("Brainfuck", () => {
assert<Equal<Output, "Hello, world!" | "!dlrow ,olleH" | "Bye" | "eyB">>();
});

it("continues to run programs for at least 8,000 steps", () => {
it("continues to run programs for at least 10,000 steps", () => {
type Repeat<S extends string, N extends number> = Recurse<RepeatSub<S, N, "", []>>;
type RepeatSub<S extends string, N extends number, R extends string, L extends unknown[]> =
L["length"] extends N ? R : { __rec: RepeatSub<S, N, `${R}${S}`, [...L, unknown]> };

type Reverse<S extends string> = Recurse<ReverseSub<S, "">>;
type ReverseSub<S extends string, R extends string> =
S extends "" ? R
: S extends `${infer A}${infer B}` ? { __rec: ReverseSub<B, `${A}${R}`> }
: never;

type Program = ">,[>,]<[.<]";
type Input = Repeat<"ABCD", 1000>;
type Input = Repeat<"ABCD", 1250>;
type Output = Brainfuck<Program, Input>;
type Expected = Reverse<Input>;
type Expected = Repeat<"DCBA", 1250>;
assert<Equal<Output, Expected>>();
});
});

0 comments on commit 18a115b

Please sign in to comment.