summaryrefslogtreecommitdiff
path: root/tests/specs/check
diff options
context:
space:
mode:
Diffstat (limited to 'tests/specs/check')
-rw-r--r--tests/specs/check/typecheck_doc_duplicate_identifiers/__test__.jsonc5
-rw-r--r--tests/specs/check/typecheck_doc_duplicate_identifiers/mod.out2
-rw-r--r--tests/specs/check/typecheck_doc_duplicate_identifiers/mod.ts13
-rw-r--r--tests/specs/check/typecheck_doc_failure/__test__.jsonc5
-rw-r--r--tests/specs/check/typecheck_doc_failure/mod.out6
-rw-r--r--tests/specs/check/typecheck_doc_failure/mod.ts8
-rw-r--r--tests/specs/check/typecheck_doc_in_markdown/__test__.jsonc5
-rw-r--r--tests/specs/check/typecheck_doc_in_markdown/markdown.md31
-rw-r--r--tests/specs/check/typecheck_doc_in_markdown/markdown.out7
-rw-r--r--tests/specs/check/typecheck_doc_success/__test__.jsonc5
-rw-r--r--tests/specs/check/typecheck_doc_success/mod.out2
-rw-r--r--tests/specs/check/typecheck_doc_success/mod.ts12
12 files changed, 101 insertions, 0 deletions
diff --git a/tests/specs/check/typecheck_doc_duplicate_identifiers/__test__.jsonc b/tests/specs/check/typecheck_doc_duplicate_identifiers/__test__.jsonc
new file mode 100644
index 000000000..8596142dd
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_duplicate_identifiers/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "check --doc --config ../../../config/deno.json mod.ts",
+ "exitCode": 0,
+ "output": "mod.out"
+}
diff --git a/tests/specs/check/typecheck_doc_duplicate_identifiers/mod.out b/tests/specs/check/typecheck_doc_duplicate_identifiers/mod.out
new file mode 100644
index 000000000..d01daafa5
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_duplicate_identifiers/mod.out
@@ -0,0 +1,2 @@
+Check [WILDCARD]/mod.ts
+Check [WILDCARD]/mod.ts$2-8.ts
diff --git a/tests/specs/check/typecheck_doc_duplicate_identifiers/mod.ts b/tests/specs/check/typecheck_doc_duplicate_identifiers/mod.ts
new file mode 100644
index 000000000..576f70240
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_duplicate_identifiers/mod.ts
@@ -0,0 +1,13 @@
+/**
+ * ```ts
+ * import { assertEquals } from "@std/assert/equals";
+ *
+ * const foo = createFoo(3);
+ * assertEquals(foo, 9);
+ * ```
+ */
+export function createFoo(x: number): number {
+ return x * x;
+}
+
+export const foo = 42;
diff --git a/tests/specs/check/typecheck_doc_failure/__test__.jsonc b/tests/specs/check/typecheck_doc_failure/__test__.jsonc
new file mode 100644
index 000000000..5d95f2666
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_failure/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "check --doc mod.ts",
+ "exitCode": 1,
+ "output": "mod.out"
+}
diff --git a/tests/specs/check/typecheck_doc_failure/mod.out b/tests/specs/check/typecheck_doc_failure/mod.out
new file mode 100644
index 000000000..61fd5499e
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_failure/mod.out
@@ -0,0 +1,6 @@
+Check [WILDCARD]/mod.ts
+Check [WILDCARD]/mod.ts$2-5.ts
+error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
+const sum: string = add(1, 2);
+ ~~~
+ at [WILDCARD]/mod.ts$2-5.ts:2:7
diff --git a/tests/specs/check/typecheck_doc_failure/mod.ts b/tests/specs/check/typecheck_doc_failure/mod.ts
new file mode 100644
index 000000000..281d7f41b
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_failure/mod.ts
@@ -0,0 +1,8 @@
+/**
+ * ```ts
+ * const sum: string = add(1, 2);
+ * ```
+ */
+export function add(a: number, b: number): number {
+ return a + b;
+}
diff --git a/tests/specs/check/typecheck_doc_in_markdown/__test__.jsonc b/tests/specs/check/typecheck_doc_in_markdown/__test__.jsonc
new file mode 100644
index 000000000..00f98c4d0
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_in_markdown/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "check --doc-only markdown.md",
+ "exitCode": 1,
+ "output": "markdown.out"
+}
diff --git a/tests/specs/check/typecheck_doc_in_markdown/markdown.md b/tests/specs/check/typecheck_doc_in_markdown/markdown.md
new file mode 100644
index 000000000..d18dbd108
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_in_markdown/markdown.md
@@ -0,0 +1,31 @@
+# Documentation
+
+The following block does not have a language attribute and should be ignored:
+
+```
+This is a fenced block without attributes, it's invalid and it should be ignored.
+```
+
+The following block should be given a js extension on extraction:
+
+```js
+console.log("js");
+```
+
+The following block should be given a ts extension on extraction:
+
+```ts
+console.log("ts");
+```
+
+The following example contains the ignore attribute and will be ignored:
+
+```ts ignore
+const value: Invalid = "ignored";
+```
+
+The following example will trigger the type-checker to fail:
+
+```ts
+const a: string = 42;
+```
diff --git a/tests/specs/check/typecheck_doc_in_markdown/markdown.out b/tests/specs/check/typecheck_doc_in_markdown/markdown.out
new file mode 100644
index 000000000..acc05dc81
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_in_markdown/markdown.out
@@ -0,0 +1,7 @@
+Check [WILDCARD]/markdown.md$11-14.js
+Check [WILDCARD]/markdown.md$17-20.ts
+Check [WILDCARD]/markdown.md$29-32.ts
+error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
+const a: string = 42;
+ ^
+ at [WILDCARD]/markdown.md$29-32.ts:1:7
diff --git a/tests/specs/check/typecheck_doc_success/__test__.jsonc b/tests/specs/check/typecheck_doc_success/__test__.jsonc
new file mode 100644
index 000000000..24fee3f2c
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_success/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "check --doc mod.ts",
+ "exitCode": 0,
+ "output": "mod.out"
+}
diff --git a/tests/specs/check/typecheck_doc_success/mod.out b/tests/specs/check/typecheck_doc_success/mod.out
new file mode 100644
index 000000000..8658af4f8
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_success/mod.out
@@ -0,0 +1,2 @@
+Check [WILDCARD]/tests/specs/check/typecheck_doc_success/mod.ts
+Check [WILDCARD]/tests/specs/check/typecheck_doc_success/mod.ts$2-5.ts
diff --git a/tests/specs/check/typecheck_doc_success/mod.ts b/tests/specs/check/typecheck_doc_success/mod.ts
new file mode 100644
index 000000000..793be2711
--- /dev/null
+++ b/tests/specs/check/typecheck_doc_success/mod.ts
@@ -0,0 +1,12 @@
+/**
+ * ```ts
+ * const sum: number = add(1, 2);
+ * ```
+ *
+ * ```mts ignore
+ * const sum: boolean = add(3, 4);
+ * ```
+ */
+export function add(a: number, b: number): number {
+ return a + b;
+}