From 49d6379c3d40b684b28f4a957ff1ffb81a2560ee Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 11 Jan 2023 16:02:26 +0530 Subject: refactor: minor refactor all around --- examples/test-runner.ts | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'examples/test-runner.ts') diff --git a/examples/test-runner.ts b/examples/test-runner.ts index 7093bf7..fecd3e4 100644 --- a/examples/test-runner.ts +++ b/examples/test-runner.ts @@ -1,39 +1,45 @@ import { Do, Effect } from '../stdlib/effect' -import { Print, PutStringLn } from '../stdlib/stdio' +import { PutStringLn } from '../stdlib/stdio' import { DefineEffect } from '../stdlib/sys' -type Testi = [ - PutStringLn, +type Test = [ + PutStringLn<`* ${m}`>, ...effs, ] type Equals = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false +type Not = B extends true ? false : true -type CompileTimeErrors = false -interface Assert<_B extends (CompileTimeErrors extends true ? true : boolean)> extends Effect { } +interface TestConfig { + CompileTestFailures: false +} -type testCases = [ - ...Testi<"should do some stuff", [ - Assert>, - ]>, - - ...Testi<"hello world", [ - Print<2>, - ]>, - - ...Testi<"should do some other stuff", [ - Print<5>, - ]>, -] +type Assertion = TestConfig['CompileTestFailures'] extends true ? true : boolean +interface Assert<_B extends Assertion> extends Effect { } export type main = [ - DefineEffect<'Assert', `(b) => { - if (!b.getLiteralValue()) { + DefineEffect<'Assert', `([b], ctx) => { + if (!ctx.getTypeValue(b)) { throw new Error('AAAAAAA') } }`>, + PutStringLn<"Running tests...">, - Do, + + Do<[ + ...Test<"should do some stuff", [ + Assert>, + Assert>>, + ]>, + + ...Test<"hello world", [ + Assert>, + ]>, + + ...Test<"should do some other stuff", [ + Assert>, + ]>, + ]>, ] -- cgit v1.3.1