diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-13 19:21:41 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-13 19:21:41 +0530 |
| commit | 8ba316461d2dc0a1372af16836ce14ceabc2bf4f (patch) | |
| tree | afcd80654b1e83fe78fcb4bf69a71f730ee3e299 /examples/test-runner.ts | |
| parent | fe710f58a982e31e64c02d887567bcd9a4108b24 (diff) | |
| download | ts-types-lang-8ba316461d2dc0a1372af16836ce14ceabc2bf4f.tar.gz ts-types-lang-8ba316461d2dc0a1372af16836ce14ceabc2bf4f.zip | |
feat: adds test to stdlib + refactors runtime environment
Diffstat (limited to 'examples/test-runner.ts')
| -rw-r--r-- | examples/test-runner.ts | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/examples/test-runner.ts b/examples/test-runner.ts index fecd3e4..3302fbb 100644 --- a/examples/test-runner.ts +++ b/examples/test-runner.ts @@ -1,44 +1,29 @@ -import { Do, Effect } from '../stdlib/effect' -import { PutStringLn } from '../stdlib/stdio' -import { DefineEffect } from '../stdlib/sys' +import { Do, Kind1 } from '../stdlib/effect' +import { Print, PutStringLn } from '../stdlib/stdio' +import { SetEvalEnvironment } from '../stdlib/sys' +import { Test, Assert } from '../stdlib/test' +import { Equals, Not } from '../stdlib/util' -type Test<m extends string, effs extends Effect[]> = [ - PutStringLn<`* ${m}`>, - ...effs, -] - -type Equals<Left, Right> = - [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false - -type Not<B extends boolean> = B extends true ? false : true - -interface TestConfig { - CompileTestFailures: false +interface PrintK extends Kind1 { + return: Print<this['input']> } -type Assertion = TestConfig['CompileTestFailures'] extends true ? true : boolean -interface Assert<_B extends Assertion> extends Effect { } - export type main = [ - DefineEffect<'Assert', `([b], ctx) => { - if (!ctx.getTypeValue(b)) { - throw new Error('AAAAAAA') - } - }`>, + SetEvalEnvironment<'test.node'>, PutStringLn<"Running tests...">, Do<[ - ...Test<"should do some stuff", [ - Assert<Equals<1, 1>>, + Test<"should do some stuff", [ + Assert<Equals<1, 2>>, Assert<Not<Equals<2, 1>>>, ]>, - ...Test<"hello world", [ + Test<"hello world", [ Assert<Equals<1, 1>>, ]>, - ...Test<"should do some other stuff", [ + Test<"should do some other stuff", [ Assert<Equals<1, 1>>, ]>, ]>, |
