diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-09 17:12:43 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-09 17:12:43 +0530 |
| commit | efdcf6119e5de99a837189a06a2a23a088432f2d (patch) | |
| tree | 1875530fa513baccc6d3c843a0b0357d8d7bea95 | |
| parent | 580ef150778326262d04018460f672bda53d5696 (diff) | |
| download | ts-types-lang-efdcf6119e5de99a837189a06a2a23a088432f2d.tar.gz ts-types-lang-efdcf6119e5de99a837189a06a2a23a088432f2d.zip | |
feat: wow
| -rw-r--r-- | examples/guess-number.ts | 3 | ||||
| -rw-r--r-- | examples/test-runner.ts | 35 | ||||
| -rw-r--r-- | src/eval.ts | 2 |
3 files changed, 37 insertions, 3 deletions
diff --git a/examples/guess-number.ts b/examples/guess-number.ts index d08c616..f03ee10 100644 --- a/examples/guess-number.ts +++ b/examples/guess-number.ts @@ -1,5 +1,4 @@ import { - Print, PutString, Bind, Kind1, @@ -21,7 +20,7 @@ interface AskForGuess<N extends number, Attempts extends 0[]> : Do< [ PutString<'Wrong guess. Total attempts'>, - Print<`${[...Attempts, 0] extends infer Ls extends 0[] + PutStringLn<` ${[...Attempts, 0] extends infer Ls extends 0[] ? Ls['length'] : 0}/5`>, (StartGuessing<[...Attempts, 0]> & { input: N })['return'] diff --git a/examples/test-runner.ts b/examples/test-runner.ts new file mode 100644 index 0000000..c0eb4c4 --- /dev/null +++ b/examples/test-runner.ts @@ -0,0 +1,35 @@ +import { DefineEffect, Do, Effect, Print, PutString, PutStringLn } from '../stdlib' + +type Testi<m extends string, effs extends Effect[]> = [ + PutStringLn<m>, + ...effs, +] + +type Equals<Left, Right> = + [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false + +interface Assert<_B extends true> extends Effect { } + +type testCases = [ + ...Testi<"should do some stuff", [ + Assert<Equals<1, 2>>, + ]>, + + ...Testi<"hello world", [ + Print<2>, + ]>, + + ...Testi<"should do some other stuff", [ + Print<5>, + ]>, +] + +export type main = [ + DefineEffect<'Assert', `(b) => { + if (!b.getLiteralValue()) { + throw new Error('AAAAAAA') + } + }`>, + PutStringLn<"Running tests...">, + Do<testCases>, +] diff --git a/src/eval.ts b/src/eval.ts index 9829194..dc33fbe 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -148,7 +148,7 @@ export const evaluateType = async ( return ctx.runCustomEffect(name, effTyp.getTypeArguments()) } - console.log(`${name} result effect is unhandled`) + console.log(`${name} effect is not handled`) return [] }, }) |
