diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-14 17:12:48 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-14 17:12:48 +0530 |
| commit | cd11925707c42843df195d9b2efb3c77b5de793b (patch) | |
| tree | 0871b0041597096fdbf7c49416f96fa70da00e3c /tests | |
| parent | d362ef26db894ea52c6abd34489aa9efdbc0c89b (diff) | |
| download | ts-types-lang-cd11925707c42843df195d9b2efb3c77b5de793b.tar.gz ts-types-lang-cd11925707c42843df195d9b2efb3c77b5de793b.zip | |
feat: adds cleanup of result nodes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/builtins.spec.ts | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/tests/builtins.spec.ts b/tests/builtins.spec.ts index cd4b5c4..cbac0d3 100644 --- a/tests/builtins.spec.ts +++ b/tests/builtins.spec.ts @@ -4,93 +4,93 @@ import { PutStringLn } from '../stdlib/stdio' import { DefineEffect, JsExpr, SetEvalEnvironment } from '../stdlib/sys' import { Test, AssertEqualsK, AssertEquals } from '../stdlib/test' -type testBind = Do<[ - PutStringLn<'Bind & BindTo'>, +interface MyEffect<_a extends number, _b extends string, _c extends unknown> extends Effect {} - Test<'should bind value to function and kind', [ - Bind<Pure<[1,2,3]>, <val extends number[]>() => - AssertEquals<val, [1, 2, 3]>>, +export type main = [ + SetEvalEnvironment<'test.node'>, - Bind<Pure<[1,2,3]>, AssertEqualsK<[1,2,3]>>, - ]>, + PutStringLn<'====================='>, + PutStringLn<'=== Running tests ==='>, + PutStringLn<'=====================\n\n'>, - Test<'should bind label correctly', [ - BindTo<"value", Pure<{ a: 'b', c: { d: 1 } }>>, + Do<[ + PutStringLn<'Bind & BindTo'>, - Bind<Label<"value">, AssertEqualsK<{ a: 'b', c: { d: 1 } }>>, - ]>, + Test<'should bind value to function and kind', [ + Bind<Pure<[1,2,3]>, <val extends number[]>() => + AssertEquals<val, [1, 2, 3]>>, - Test<'should bind only inside Do scope', [ - Do<[ - BindTo<"value", Pure<"some value">>, - Bind<Label<"value">, AssertEqualsK<"some value">>, + Bind<Pure<[1,2,3]>, AssertEqualsK<[1,2,3]>>, ]>, - Bind< - Try<Label<"value">, <_>() => Pure<"none">>, - AssertEqualsK<"none"> - >, - ]>, + Test<'should bind label correctly', [ + BindTo<"value", Pure<{ a: 'b', c: { d: 1 } }>>, - Test<'should bind only inside Bind scope', [ - Bind< - BindTo<"value", Pure<"some value">>, - <_>() => Bind<Label<"value">, AssertEqualsK<"some value">> - >, + Bind<Label<"value">, AssertEqualsK<{ a: 'b', c: { d: 1 } }>>, + ]>, - Bind< - Try<Label<"value">, <_>() => Pure<"none">>, - AssertEqualsK<"none"> - >, - ]>, -]> + Test<'should bind only inside Do scope', [ + Do<[ + BindTo<"value", Pure<"some value">>, + Bind<Label<"value">, AssertEqualsK<"some value">>, + ]>, -type testExcpt = Do<[ - PutStringLn<'Try/Throw'>, + Bind< + Try<Label<"value">, <_>() => Pure<"none">>, + AssertEqualsK<"none"> + >, + ]>, + + Test<'should bind only inside Bind scope', [ + Bind< + BindTo<"value", Pure<"some value">>, + <_>() => Bind<Label<"value">, AssertEqualsK<"some value">> + >, - Test<'should return the result of effect', [ - Bind<Try<Pure<20>, <_>() => Pure<0>>, - AssertEqualsK<20>>, + Bind< + Try<Label<"value">, <_>() => Pure<"none">>, + AssertEqualsK<"none"> + >, + ]>, ]>, - Test<'should return the result of error handler', [ - Bind<Try<Do<[ Throw<"wow">, Pure<20> ]>, <_>() => Pure<0>>, - AssertEqualsK<0>>, + Do<[ + PutStringLn<'Try/Throw'>, - Bind<Try<Do<[ Throw<"wow">, Pure<20> ]>, <e>() => Pure<e>>, - AssertEqualsK<"wow">>, - ]>, -]> + Test<'should return the result of effect', [ + Bind<Try<Pure<20>, <_>() => Pure<0>>, + AssertEqualsK<20>>, + ]>, -interface MyEffect<_a extends number, _b extends string, _c extends unknown> extends Effect {} -type testFFI = Do<[ - PutStringLn<'FFI'>, + Test<'should return the result of error handler', [ + Bind<Try<Do<[ Throw<"wow">, Pure<20> ]>, <_>() => Pure<0>>, + AssertEqualsK<0>>, - Test<'should return the result of js expression', [ - Bind<JsExpr<'69 * 420'>, AssertEqualsK<28980>>, + Bind<Try<Do<[ Throw<"wow">, Pure<20> ]>, <e>() => Pure<e>>, + AssertEqualsK<"wow">>, + ]>, ]>, - Test<'should test custom effect', [ - DefineEffect<'MyEffect', `([a, b, c], ctx) => { - return [ - ctx.getTypeValue(a) * 2, - ctx.getTypeValue(b) + '!', - [...ctx.getTypeValue(c), 'wow'], - ] - }`>, - Bind<MyEffect<4, "hey", [1, 2]>, AssertEqualsK<[ - 8, "hey!", [1, 2, 'wow'], - ]>>, - ]>, -]> + Do<[ + PutStringLn<'FFI'>, -export type main = [ - SetEvalEnvironment<'test.node'>, + Test<'should return the result of js expression', [ + Bind<JsExpr<'69 * 420'>, AssertEqualsK<28980>>, + ]>, - PutStringLn<'====================='>, - PutStringLn<'=== Running tests ==='>, - PutStringLn<'=====================\n\n'>, - testBind, - testExcpt, - testFFI, + Test<'should test custom effect', [ + DefineEffect<'MyEffect', `([a, b, c], ctx) => { + return [ + ctx.getTypeValue(a) * 2, + ctx.getTypeValue(b) + '!', + [...ctx.getTypeValue(c), 'wow'], + ] + }`>, + Bind<MyEffect<4, "hey", [1, 2]>, AssertEqualsK<[ + 8, "hey!", [1, 2, 'wow'], + ]>>, + ]>, + ]>, + + PutStringLn<"">, ] |
