From 8ba316461d2dc0a1372af16836ce14ceabc2bf4f Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 13 Jan 2023 19:21:41 +0530 Subject: feat: adds test to stdlib + refactors runtime environment --- examples/test-runner.ts | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) (limited to 'examples') 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' - -type Test = [ - PutStringLn<`* ${m}`>, - ...effs, -] - -type Equals = - [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false - -type Not = B extends true ? false : true - -interface TestConfig { - CompileTestFailures: false +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' + +interface PrintK extends Kind1 { + return: Print } -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>, + Test<"should do some stuff", [ + Assert>, Assert>>, ]>, - ...Test<"hello world", [ + Test<"hello world", [ Assert>, ]>, - ...Test<"should do some other stuff", [ + Test<"should do some other stuff", [ Assert>, ]>, ]>, -- cgit v1.3.1