aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-09 17:12:43 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-09 17:12:43 +0530
commitefdcf6119e5de99a837189a06a2a23a088432f2d (patch)
tree1875530fa513baccc6d3c843a0b0357d8d7bea95 /examples
parent580ef150778326262d04018460f672bda53d5696 (diff)
downloadts-types-lang-efdcf6119e5de99a837189a06a2a23a088432f2d.tar.gz
ts-types-lang-efdcf6119e5de99a837189a06a2a23a088432f2d.zip
feat: wow
Diffstat (limited to 'examples')
-rw-r--r--examples/guess-number.ts3
-rw-r--r--examples/test-runner.ts35
2 files changed, 36 insertions, 2 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>,
+]