summaryrefslogtreecommitdiff
path: root/tests/specs/test/doc_duplicate_identifier/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/specs/test/doc_duplicate_identifier/main.ts')
-rw-r--r--tests/specs/test/doc_duplicate_identifier/main.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/specs/test/doc_duplicate_identifier/main.ts b/tests/specs/test/doc_duplicate_identifier/main.ts
new file mode 100644
index 000000000..df78294d0
--- /dev/null
+++ b/tests/specs/test/doc_duplicate_identifier/main.ts
@@ -0,0 +1,33 @@
+// `deno test --doc` tries to convert the example code snippets into pseudo
+// test files in a way that all the exported items are available without
+// explicit import statements. Therefore, in the test code, you don't have to
+// write like `import { add } from "./main.ts";`.
+// However, this automatic import resolution might conflict with other
+// explicitly declared identifiers in the test code you write. This spec test
+// makes sure that such cases will not cause any issues - explicit identifiers
+// take precedence.
+
+/**
+ * ```ts
+ * import { assertEquals } from "@std/assert/equals";
+ * import { getModuleName, createFoo } from "./mod.ts";
+ *
+ * const foo = createFoo();
+ * assertEquals(getModuleName(), "mod.ts");
+ * assertEquals(add(1, 2), foo());
+ * ```
+ */
+export function add(a: number, b: number): number {
+ return a + b;
+}
+
+/**
+ * ```ts
+ * import { assertEquals } from "@std/assert/equals";
+ *
+ * assertEquals(getModuleName(), "main.ts");
+ * ```
+ */
+export const getModuleName = () => "main.ts";
+
+export let foo = 1234;