From f5e46c9bf2f50d66a953fa133161fc829cecff06 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Sat, 10 Feb 2024 13:22:13 -0700 Subject: chore: move cli/tests/ -> tests/ (#22369) This looks like a massive PR, but it's only a move from cli/tests -> tests, and updates of relative paths for files. This is the first step towards aggregate all of the integration test files under tests/, which will lead to a set of integration tests that can run without the CLI binary being built. While we could leave these tests under `cli`, it would require us to keep a more complex directory structure for the various test runners. In addition, we have a lot of complexity to ignore various test files in the `cli` project itself (cargo publish exclusion rules, autotests = false, etc). And finally, the `tests/` folder will eventually house the `test_ffi`, `test_napi` and other testing code, reducing the size of the root repo directory. For easier review, the extremely large and noisy "move" is in the first commit (with no changes -- just a move), while the remainder of the changes to actual files is in the second commit. --- .../bundle/bare_imports/error_with_bare_import.ts | 1 + .../bare_imports/error_with_bare_import.ts.out | 2 + tests/testdata/bundle/bundle.test.out | 27 ++++++++++++ .../bundle/check_local_by_default/no_errors.out | 6 +++ .../bundle/check_local_by_default/no_errors.ts | 3 ++ .../bundle/check_local_by_default/type_error.out | 4 ++ .../bundle/check_local_by_default/type_error.ts | 6 +++ tests/testdata/bundle/decorators/ts_decorators.out | 49 ++++++++++++++++++++++ tests/testdata/bundle/decorators/ts_decorators.ts | 25 +++++++++++ tests/testdata/bundle/dynamic_import.ts | 3 ++ .../file_extensions/js_without_extension.out | 8 ++++ .../file_extensions/ts_without_extension.out | 7 ++++ tests/testdata/bundle/file_tests-fixture01.ts | 3 ++ tests/testdata/bundle/file_tests-fixture02.ts | 4 ++ tests/testdata/bundle/file_tests-fixture03.ts | 3 ++ tests/testdata/bundle/file_tests-fixture04.ts | 3 ++ tests/testdata/bundle/file_tests-fixture05.ts | 3 ++ tests/testdata/bundle/file_tests-fixture06.ts | 4 ++ tests/testdata/bundle/file_tests-fixture07.ts | 4 ++ tests/testdata/bundle/file_tests-fixture08.ts | 1 + tests/testdata/bundle/file_tests-fixture09.ts | 1 + tests/testdata/bundle/file_tests-fixture10.ts | 7 ++++ tests/testdata/bundle/file_tests-fixture11.ts | 32 ++++++++++++++ tests/testdata/bundle/file_tests-fixture12.ts | 7 ++++ tests/testdata/bundle/file_tests-fixture13.ts | 11 +++++ tests/testdata/bundle/file_tests-fixture14.ts | 4 ++ tests/testdata/bundle/file_tests-fixture15.ts | 3 ++ tests/testdata/bundle/file_tests-fixture16.ts | 6 +++ tests/testdata/bundle/file_tests-fixture16_2.ts | 2 + tests/testdata/bundle/file_tests-subdir-a.ts | 1 + tests/testdata/bundle/file_tests-subdir-b.ts | 3 ++ tests/testdata/bundle/file_tests-subdir-c.ts | 2 + tests/testdata/bundle/file_tests-subdir-d.ts | 3 ++ tests/testdata/bundle/file_tests-subdir-e.ts | 1 + tests/testdata/bundle/file_tests-subdir-f.ts | 2 + tests/testdata/bundle/file_tests-subdir-g.ts | 12 ++++++ tests/testdata/bundle/file_tests-subdir-h.ts | 12 ++++++ tests/testdata/bundle/file_tests-subdir-i.ts | 3 ++ tests/testdata/bundle/file_tests-subdir-j.ts | 3 ++ tests/testdata/bundle/file_tests-subdir-k.ts | 11 +++++ tests/testdata/bundle/file_tests-subdir-l.ts | 1 + tests/testdata/bundle/file_tests-subdir-m.ts | 2 + tests/testdata/bundle/file_tests-subdir-n.ts | 3 ++ tests/testdata/bundle/file_tests-subdir-o.ts | 5 +++ tests/testdata/bundle/file_tests-subdir-p.ts | 1 + tests/testdata/bundle/file_tests-subdir-q.ts | 13 ++++++ tests/testdata/bundle/fixture01.out | 7 ++++ tests/testdata/bundle/fixture02.out | 12 ++++++ tests/testdata/bundle/fixture03.out | 5 +++ tests/testdata/bundle/fixture04.out | 2 + tests/testdata/bundle/fixture05.out | 2 + tests/testdata/bundle/fixture06.out | 12 ++++++ tests/testdata/bundle/fixture07.out | 23 ++++++++++ tests/testdata/bundle/fixture08.out | 7 ++++ tests/testdata/bundle/fixture09.out | 19 +++++++++ tests/testdata/bundle/fixture10.out | 5 +++ tests/testdata/bundle/fixture11.out | 30 +++++++++++++ tests/testdata/bundle/fixture12.out | 7 ++++ tests/testdata/bundle/fixture13.out | 17 ++++++++ tests/testdata/bundle/fixture14.out | 2 + tests/testdata/bundle/fixture15.out | 4 ++ tests/testdata/bundle/fixture16.out | 6 +++ tests/testdata/bundle/https_deno.land-x-lib-a.ts | 1 + tests/testdata/bundle/https_deno.land-x-lib-b.js | 1 + tests/testdata/bundle/https_deno.land-x-lib-c.d.ts | 1 + tests/testdata/bundle/https_deno.land-x-lib-c.js | 3 ++ .../testdata/bundle/https_deno.land-x-lib-mod.d.ts | 9 ++++ tests/testdata/bundle/https_deno.land-x-lib-mod.js | 5 +++ tests/testdata/bundle/ignore_directives.test.out | 6 +++ tests/testdata/bundle/import_map/import_map.json | 5 +++ tests/testdata/bundle/import_map/main.ts | 17 ++++++++ tests/testdata/bundle/jsx.out | 9 ++++ tests/testdata/bundle/lockfile/check_error.json | 5 +++ tests/testdata/bundle/lockfile/check_error.out | 4 ++ tests/testdata/bundle/shebang_file.bundle.out | 12 ++++++ 75 files changed, 555 insertions(+) create mode 100644 tests/testdata/bundle/bare_imports/error_with_bare_import.ts create mode 100644 tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out create mode 100644 tests/testdata/bundle/bundle.test.out create mode 100644 tests/testdata/bundle/check_local_by_default/no_errors.out create mode 100644 tests/testdata/bundle/check_local_by_default/no_errors.ts create mode 100644 tests/testdata/bundle/check_local_by_default/type_error.out create mode 100644 tests/testdata/bundle/check_local_by_default/type_error.ts create mode 100644 tests/testdata/bundle/decorators/ts_decorators.out create mode 100644 tests/testdata/bundle/decorators/ts_decorators.ts create mode 100644 tests/testdata/bundle/dynamic_import.ts create mode 100644 tests/testdata/bundle/file_extensions/js_without_extension.out create mode 100644 tests/testdata/bundle/file_extensions/ts_without_extension.out create mode 100644 tests/testdata/bundle/file_tests-fixture01.ts create mode 100644 tests/testdata/bundle/file_tests-fixture02.ts create mode 100644 tests/testdata/bundle/file_tests-fixture03.ts create mode 100644 tests/testdata/bundle/file_tests-fixture04.ts create mode 100644 tests/testdata/bundle/file_tests-fixture05.ts create mode 100644 tests/testdata/bundle/file_tests-fixture06.ts create mode 100644 tests/testdata/bundle/file_tests-fixture07.ts create mode 100644 tests/testdata/bundle/file_tests-fixture08.ts create mode 100644 tests/testdata/bundle/file_tests-fixture09.ts create mode 100644 tests/testdata/bundle/file_tests-fixture10.ts create mode 100644 tests/testdata/bundle/file_tests-fixture11.ts create mode 100644 tests/testdata/bundle/file_tests-fixture12.ts create mode 100644 tests/testdata/bundle/file_tests-fixture13.ts create mode 100644 tests/testdata/bundle/file_tests-fixture14.ts create mode 100644 tests/testdata/bundle/file_tests-fixture15.ts create mode 100644 tests/testdata/bundle/file_tests-fixture16.ts create mode 100644 tests/testdata/bundle/file_tests-fixture16_2.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-a.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-b.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-c.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-d.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-e.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-f.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-g.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-h.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-i.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-j.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-k.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-l.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-m.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-n.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-o.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-p.ts create mode 100644 tests/testdata/bundle/file_tests-subdir-q.ts create mode 100644 tests/testdata/bundle/fixture01.out create mode 100644 tests/testdata/bundle/fixture02.out create mode 100644 tests/testdata/bundle/fixture03.out create mode 100644 tests/testdata/bundle/fixture04.out create mode 100644 tests/testdata/bundle/fixture05.out create mode 100644 tests/testdata/bundle/fixture06.out create mode 100644 tests/testdata/bundle/fixture07.out create mode 100644 tests/testdata/bundle/fixture08.out create mode 100644 tests/testdata/bundle/fixture09.out create mode 100644 tests/testdata/bundle/fixture10.out create mode 100644 tests/testdata/bundle/fixture11.out create mode 100644 tests/testdata/bundle/fixture12.out create mode 100644 tests/testdata/bundle/fixture13.out create mode 100644 tests/testdata/bundle/fixture14.out create mode 100644 tests/testdata/bundle/fixture15.out create mode 100644 tests/testdata/bundle/fixture16.out create mode 100644 tests/testdata/bundle/https_deno.land-x-lib-a.ts create mode 100644 tests/testdata/bundle/https_deno.land-x-lib-b.js create mode 100644 tests/testdata/bundle/https_deno.land-x-lib-c.d.ts create mode 100644 tests/testdata/bundle/https_deno.land-x-lib-c.js create mode 100644 tests/testdata/bundle/https_deno.land-x-lib-mod.d.ts create mode 100644 tests/testdata/bundle/https_deno.land-x-lib-mod.js create mode 100644 tests/testdata/bundle/ignore_directives.test.out create mode 100644 tests/testdata/bundle/import_map/import_map.json create mode 100644 tests/testdata/bundle/import_map/main.ts create mode 100644 tests/testdata/bundle/jsx.out create mode 100644 tests/testdata/bundle/lockfile/check_error.json create mode 100644 tests/testdata/bundle/lockfile/check_error.out create mode 100644 tests/testdata/bundle/shebang_file.bundle.out (limited to 'tests/testdata/bundle') diff --git a/tests/testdata/bundle/bare_imports/error_with_bare_import.ts b/tests/testdata/bundle/bare_imports/error_with_bare_import.ts new file mode 100644 index 000000000..c0748305d --- /dev/null +++ b/tests/testdata/bundle/bare_imports/error_with_bare_import.ts @@ -0,0 +1 @@ +import "foo"; diff --git a/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out b/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out new file mode 100644 index 000000000..44d063a5e --- /dev/null +++ b/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out @@ -0,0 +1,2 @@ +[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ + at file:///[WILDCARD]/error_with_bare_import.ts:[WILDCARD] diff --git a/tests/testdata/bundle/bundle.test.out b/tests/testdata/bundle/bundle.test.out new file mode 100644 index 000000000..6b1c109d3 --- /dev/null +++ b/tests/testdata/bundle/bundle.test.out @@ -0,0 +1,27 @@ +[WILDCARD] +function printHello() { + console.log("Hello"); +} +function returnsFoo() { + return "Foo"; +} +function printHello2() { + printHello(); +} +function returnsHi() { + return "Hi"; +} +function returnsFoo2() { + return returnsFoo(); +} +function printHello3() { + printHello2(); +} +function throwsError() { + throw Error("exception from mod1"); +} +export { returnsHi as returnsHi }; +export { returnsFoo2 as returnsFoo2 }; +export { printHello3 as printHello3 }; +export { throwsError as throwsError }; + diff --git a/tests/testdata/bundle/check_local_by_default/no_errors.out b/tests/testdata/bundle/check_local_by_default/no_errors.out new file mode 100644 index 000000000..c4559d1fa --- /dev/null +++ b/tests/testdata/bundle/check_local_by_default/no_errors.out @@ -0,0 +1,6 @@ +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +console.log(12); + diff --git a/tests/testdata/bundle/check_local_by_default/no_errors.ts b/tests/testdata/bundle/check_local_by_default/no_errors.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/tests/testdata/bundle/check_local_by_default/no_errors.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/tests/testdata/bundle/check_local_by_default/type_error.out b/tests/testdata/bundle/check_local_by_default/type_error.out new file mode 100644 index 000000000..6d53e9498 --- /dev/null +++ b/tests/testdata/bundle/check_local_by_default/type_error.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]bundle/check_local_by_default/type_error.ts:3:7 diff --git a/tests/testdata/bundle/check_local_by_default/type_error.ts b/tests/testdata/bundle/check_local_by_default/type_error.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/tests/testdata/bundle/check_local_by_default/type_error.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/tests/testdata/bundle/decorators/ts_decorators.out b/tests/testdata/bundle/decorators/ts_decorators.out new file mode 100644 index 000000000..e988aadd3 --- /dev/null +++ b/tests/testdata/bundle/decorators/ts_decorators.out @@ -0,0 +1,49 @@ +[WILDCARD] +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +function _ts_decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} +function a() { + console.log("a(): evaluated"); + return (_target, _propertyKey, _descriptor)=>{ + console.log("a(): called"); + }; +} +class B { + method() { + console.log("method"); + } +} +_ts_decorate([ + a() +], B.prototype, "method", null); +function _ts_decorate1(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} +function Decorator() { + return function(target, propertyKey, descriptor) { + const originalFn = descriptor.value; + descriptor.value = async function(...args) { + return await originalFn.apply(this, args); + }; + return descriptor; + }; +} +class SomeClass { + async test() {} +} +_ts_decorate1([ + Decorator() +], SomeClass.prototype, "test", null); +new SomeClass().test(); +new B().method(); +[WILDCARD] \ No newline at end of file diff --git a/tests/testdata/bundle/decorators/ts_decorators.ts b/tests/testdata/bundle/decorators/ts_decorators.ts new file mode 100644 index 000000000..61299bccf --- /dev/null +++ b/tests/testdata/bundle/decorators/ts_decorators.ts @@ -0,0 +1,25 @@ +// deno-lint-ignore-file + +import { B } from "../../subdir/more_decorators.ts"; + +function Decorator() { + return function ( + target: Record, + propertyKey: string, + descriptor: TypedPropertyDescriptor, + ) { + const originalFn: Function = descriptor.value as Function; + descriptor.value = async function (...args: any[]) { + return await originalFn.apply(this, args); + }; + return descriptor; + }; +} + +class SomeClass { + @Decorator() + async test() {} +} + +new SomeClass().test(); +new B().method(); diff --git a/tests/testdata/bundle/dynamic_import.ts b/tests/testdata/bundle/dynamic_import.ts new file mode 100644 index 000000000..d8c7d08ec --- /dev/null +++ b/tests/testdata/bundle/dynamic_import.ts @@ -0,0 +1,3 @@ +const mod1 = await import("http://localhost:4545/subdir/mod1.ts"); + +mod1.printHello3(); diff --git a/tests/testdata/bundle/file_extensions/js_without_extension.out b/tests/testdata/bundle/file_extensions/js_without_extension.out new file mode 100644 index 000000000..0273e6207 --- /dev/null +++ b/tests/testdata/bundle/file_extensions/js_without_extension.out @@ -0,0 +1,8 @@ +[WILDCARD] +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +"hello"; +console.log("executing javascript with no extension"); + diff --git a/tests/testdata/bundle/file_extensions/ts_without_extension.out b/tests/testdata/bundle/file_extensions/ts_without_extension.out new file mode 100644 index 000000000..39e355d14 --- /dev/null +++ b/tests/testdata/bundle/file_extensions/ts_without_extension.out @@ -0,0 +1,7 @@ +[WILDCARD] +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +console.log("executing typescript with no extension"); + diff --git a/tests/testdata/bundle/file_tests-fixture01.ts b/tests/testdata/bundle/file_tests-fixture01.ts new file mode 100644 index 000000000..3598d0298 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture01.ts @@ -0,0 +1,3 @@ +import * as a from "./subdir/a.ts"; + +console.log(a); diff --git a/tests/testdata/bundle/file_tests-fixture02.ts b/tests/testdata/bundle/file_tests-fixture02.ts new file mode 100644 index 000000000..0cd291329 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture02.ts @@ -0,0 +1,4 @@ +import * as b from "./subdir/b.ts"; + +console.log(b.b); // "b" +console.log(b.c); // { c: "c", default: class C } diff --git a/tests/testdata/bundle/file_tests-fixture03.ts b/tests/testdata/bundle/file_tests-fixture03.ts new file mode 100644 index 000000000..78365ce13 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture03.ts @@ -0,0 +1,3 @@ +import { d } from "./subdir/d.ts"; + +console.log(d); diff --git a/tests/testdata/bundle/file_tests-fixture04.ts b/tests/testdata/bundle/file_tests-fixture04.ts new file mode 100644 index 000000000..590f4fef9 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture04.ts @@ -0,0 +1,3 @@ +const a = await import("./subdir/a.ts"); + +console.log(a); diff --git a/tests/testdata/bundle/file_tests-fixture05.ts b/tests/testdata/bundle/file_tests-fixture05.ts new file mode 100644 index 000000000..19541ce59 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture05.ts @@ -0,0 +1,3 @@ +import { a } from "./subdir/e.ts"; + +console.log(a); diff --git a/tests/testdata/bundle/file_tests-fixture06.ts b/tests/testdata/bundle/file_tests-fixture06.ts new file mode 100644 index 000000000..3d94332df --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture06.ts @@ -0,0 +1,4 @@ +import { isMain, modUrl } from "./subdir/f.ts"; + +console.log(isMain, modUrl); +console.log(import.meta.main, import.meta.url); diff --git a/tests/testdata/bundle/file_tests-fixture07.ts b/tests/testdata/bundle/file_tests-fixture07.ts new file mode 100644 index 000000000..0475a6c53 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture07.ts @@ -0,0 +1,4 @@ +import { G } from "./subdir/g.ts"; +import { H } from "./subdir/h.ts"; + +console.log(new G(true), new H(true)); diff --git a/tests/testdata/bundle/file_tests-fixture08.ts b/tests/testdata/bundle/file_tests-fixture08.ts new file mode 100644 index 000000000..6af5d172e --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture08.ts @@ -0,0 +1 @@ +export * as a from "./subdir/a.ts"; diff --git a/tests/testdata/bundle/file_tests-fixture09.ts b/tests/testdata/bundle/file_tests-fixture09.ts new file mode 100644 index 000000000..30ba983ee --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture09.ts @@ -0,0 +1 @@ +export { a } from "./subdir/k.ts"; diff --git a/tests/testdata/bundle/file_tests-fixture10.ts b/tests/testdata/bundle/file_tests-fixture10.ts new file mode 100644 index 000000000..bec555da8 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture10.ts @@ -0,0 +1,7 @@ +import { a as defaultA } from "./subdir/l.ts"; + +const o: { a?: string } = {}; + +const { a = defaultA } = o; + +console.log(a); diff --git a/tests/testdata/bundle/file_tests-fixture11.ts b/tests/testdata/bundle/file_tests-fixture11.ts new file mode 100644 index 000000000..1c361438f --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture11.ts @@ -0,0 +1,32 @@ +import { a as defaultA, O } from "./subdir/m.ts"; +export { O } from "./subdir/m.ts"; + +interface AOptions { + a?(); + c?: O; +} + +class A { + #a: () => void; + #c?: O; + constructor(o: AOptions = {}) { + const { + a = defaultA, + c, + } = o; + this.#a = a; + this.#c = c; + } + + a() { + this.#a(); + } + + c() { + console.log(this.#c); + } +} + +const a = new A(); +a.a(); +a.c(); diff --git a/tests/testdata/bundle/file_tests-fixture12.ts b/tests/testdata/bundle/file_tests-fixture12.ts new file mode 100644 index 000000000..32b9566bd --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture12.ts @@ -0,0 +1,7 @@ +import { a } from "./subdir/p.ts"; + +function b() { + a(); +} + +b(); diff --git a/tests/testdata/bundle/file_tests-fixture13.ts b/tests/testdata/bundle/file_tests-fixture13.ts new file mode 100644 index 000000000..7dc13534c --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture13.ts @@ -0,0 +1,11 @@ +import { D, d } from "./subdir/q.ts"; + +class A { + private s: D = d(); + + a() { + this.s.resolve(); + } +} + +new A(); diff --git a/tests/testdata/bundle/file_tests-fixture14.ts b/tests/testdata/bundle/file_tests-fixture14.ts new file mode 100644 index 000000000..aa8eef1b8 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture14.ts @@ -0,0 +1,4 @@ +// @deno-types="https://deno.land/x/lib/mod.d.ts" +import * as lib from "https://deno.land/x/lib/mod.js"; + +console.log(lib); diff --git a/tests/testdata/bundle/file_tests-fixture15.ts b/tests/testdata/bundle/file_tests-fixture15.ts new file mode 100644 index 000000000..c1dd3bc89 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture15.ts @@ -0,0 +1,3 @@ +export function getIndex(c: string): number { + return "\x00\r\n\x85\u2028\u2029".indexOf(c); +} diff --git a/tests/testdata/bundle/file_tests-fixture16.ts b/tests/testdata/bundle/file_tests-fixture16.ts new file mode 100644 index 000000000..5d0b05e92 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture16.ts @@ -0,0 +1,6 @@ +// todo(dsherret): use ./subdir/a.ts once fixtures are restored +export { a as test1 } from "./file_tests-fixture16_2.ts"; +export { a as test2 } from "./file_tests-fixture16_2.ts"; +import { a } from "./file_tests-fixture16_2.ts"; + +console.log(a); diff --git a/tests/testdata/bundle/file_tests-fixture16_2.ts b/tests/testdata/bundle/file_tests-fixture16_2.ts new file mode 100644 index 000000000..7115949c9 --- /dev/null +++ b/tests/testdata/bundle/file_tests-fixture16_2.ts @@ -0,0 +1,2 @@ +// todo(dsherret): delete this and use ./subdir/a.ts in the file once fixtures are restored +export const a = "a"; diff --git a/tests/testdata/bundle/file_tests-subdir-a.ts b/tests/testdata/bundle/file_tests-subdir-a.ts new file mode 100644 index 000000000..9233cce2f --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-a.ts @@ -0,0 +1 @@ +export const a = "a"; diff --git a/tests/testdata/bundle/file_tests-subdir-b.ts b/tests/testdata/bundle/file_tests-subdir-b.ts new file mode 100644 index 000000000..1cf751c22 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-b.ts @@ -0,0 +1,3 @@ +export * as c from "./c.ts"; + +export const b = "b"; diff --git a/tests/testdata/bundle/file_tests-subdir-c.ts b/tests/testdata/bundle/file_tests-subdir-c.ts new file mode 100644 index 000000000..7cc01f993 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-c.ts @@ -0,0 +1,2 @@ +export const c = "c"; +export default class C {} diff --git a/tests/testdata/bundle/file_tests-subdir-d.ts b/tests/testdata/bundle/file_tests-subdir-d.ts new file mode 100644 index 000000000..9f1ba7f67 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-d.ts @@ -0,0 +1,3 @@ +import { a } from "./a.ts"; + +export const d = { a }; diff --git a/tests/testdata/bundle/file_tests-subdir-e.ts b/tests/testdata/bundle/file_tests-subdir-e.ts new file mode 100644 index 000000000..55e8e0e18 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-e.ts @@ -0,0 +1 @@ +export * from "./a.ts"; diff --git a/tests/testdata/bundle/file_tests-subdir-f.ts b/tests/testdata/bundle/file_tests-subdir-f.ts new file mode 100644 index 000000000..8bc8d9bf4 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-f.ts @@ -0,0 +1,2 @@ +export const isMain = import.meta.main; +export const modUrl = import.meta.url; diff --git a/tests/testdata/bundle/file_tests-subdir-g.ts b/tests/testdata/bundle/file_tests-subdir-g.ts new file mode 100644 index 000000000..3eb4cd3cc --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-g.ts @@ -0,0 +1,12 @@ +const g: number[] = []; + +export class G { + #g!: number[]; + constructor(shared: boolean) { + if (shared) { + this.#g = g; + } else { + this.#g = []; + } + } +} diff --git a/tests/testdata/bundle/file_tests-subdir-h.ts b/tests/testdata/bundle/file_tests-subdir-h.ts new file mode 100644 index 000000000..9c86dd5c5 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-h.ts @@ -0,0 +1,12 @@ +const g: number[] = []; + +export class H { + #g!: number[]; + constructor(shared: boolean) { + if (shared) { + this.#g = g; + } else { + this.#g = []; + } + } +} diff --git a/tests/testdata/bundle/file_tests-subdir-i.ts b/tests/testdata/bundle/file_tests-subdir-i.ts new file mode 100644 index 000000000..4ad9ce449 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-i.ts @@ -0,0 +1,3 @@ +export function a(...d: string[]): string { + return d.join(" "); +} diff --git a/tests/testdata/bundle/file_tests-subdir-j.ts b/tests/testdata/bundle/file_tests-subdir-j.ts new file mode 100644 index 000000000..ac7bce0ea --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-j.ts @@ -0,0 +1,3 @@ +export function a(...d: string[]): string { + return d.join("/"); +} diff --git a/tests/testdata/bundle/file_tests-subdir-k.ts b/tests/testdata/bundle/file_tests-subdir-k.ts new file mode 100644 index 000000000..1b8a533f1 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-k.ts @@ -0,0 +1,11 @@ +import * as _i from "./i.ts"; +import * as _j from "./j.ts"; + +const k = globalThis.value ? _i : _j; + +export const i = _i; +export const j = _j; + +export const { + a, +} = k; diff --git a/tests/testdata/bundle/file_tests-subdir-l.ts b/tests/testdata/bundle/file_tests-subdir-l.ts new file mode 100644 index 000000000..d767e6ad0 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-l.ts @@ -0,0 +1 @@ +export { a } from "./a.ts"; diff --git a/tests/testdata/bundle/file_tests-subdir-m.ts b/tests/testdata/bundle/file_tests-subdir-m.ts new file mode 100644 index 000000000..21e86d07c --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-m.ts @@ -0,0 +1,2 @@ +export { a } from "./n.ts"; +export { O } from "./o.ts"; diff --git a/tests/testdata/bundle/file_tests-subdir-n.ts b/tests/testdata/bundle/file_tests-subdir-n.ts new file mode 100644 index 000000000..ac3c37005 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-n.ts @@ -0,0 +1,3 @@ +export function a() { + console.log("a"); +} diff --git a/tests/testdata/bundle/file_tests-subdir-o.ts b/tests/testdata/bundle/file_tests-subdir-o.ts new file mode 100644 index 000000000..ab9753fea --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-o.ts @@ -0,0 +1,5 @@ +export enum O { + A, + B, + C, +} diff --git a/tests/testdata/bundle/file_tests-subdir-p.ts b/tests/testdata/bundle/file_tests-subdir-p.ts new file mode 100644 index 000000000..19b486f71 --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-p.ts @@ -0,0 +1 @@ +export * from "./i.ts"; diff --git a/tests/testdata/bundle/file_tests-subdir-q.ts b/tests/testdata/bundle/file_tests-subdir-q.ts new file mode 100644 index 000000000..eebe0a38b --- /dev/null +++ b/tests/testdata/bundle/file_tests-subdir-q.ts @@ -0,0 +1,13 @@ +// deno-lint-ignore-file +export interface D { + resolve: any; + reject: any; +} + +export function d(): D { + let methods; + const promise = new Promise((resolve, reject) => { + methods = { resolve, reject }; + }); + return Object.assign(promise, methods); +} diff --git a/tests/testdata/bundle/fixture01.out b/tests/testdata/bundle/fixture01.out new file mode 100644 index 000000000..a825140b7 --- /dev/null +++ b/tests/testdata/bundle/fixture01.out @@ -0,0 +1,7 @@ +const a = "a"; +const mod = function() { + return { + a: a + }; +}(); +console.log(mod); diff --git a/tests/testdata/bundle/fixture02.out b/tests/testdata/bundle/fixture02.out new file mode 100644 index 000000000..5c502e2f0 --- /dev/null +++ b/tests/testdata/bundle/fixture02.out @@ -0,0 +1,12 @@ +const c = "c"; +class C { +} +const mod = function() { + return { + default: C, + c: c + }; +}(); +const b = "b"; +console.log(b); +console.log(mod); diff --git a/tests/testdata/bundle/fixture03.out b/tests/testdata/bundle/fixture03.out new file mode 100644 index 000000000..524e77abb --- /dev/null +++ b/tests/testdata/bundle/fixture03.out @@ -0,0 +1,5 @@ +const a = "a"; +const d = { + a +}; +console.log(d); diff --git a/tests/testdata/bundle/fixture04.out b/tests/testdata/bundle/fixture04.out new file mode 100644 index 000000000..37869205b --- /dev/null +++ b/tests/testdata/bundle/fixture04.out @@ -0,0 +1,2 @@ +const a = await import("./subdir/a.ts"); +console.log(a); diff --git a/tests/testdata/bundle/fixture05.out b/tests/testdata/bundle/fixture05.out new file mode 100644 index 000000000..1289cca5f --- /dev/null +++ b/tests/testdata/bundle/fixture05.out @@ -0,0 +1,2 @@ +const a = "a"; +console.log(a); diff --git a/tests/testdata/bundle/fixture06.out b/tests/testdata/bundle/fixture06.out new file mode 100644 index 000000000..47288d5e4 --- /dev/null +++ b/tests/testdata/bundle/fixture06.out @@ -0,0 +1,12 @@ +const importMeta = { + url: "file:///tests/subdir/f.ts", + main: false +}; +const isMain = importMeta.main; +const modUrl = importMeta.url; +const importMeta1 = { + url: "file:///tests/fixture06.ts", + main: import.meta.main +}; +console.log(isMain, modUrl); +console.log(importMeta1.main, importMeta1.url); diff --git a/tests/testdata/bundle/fixture07.out b/tests/testdata/bundle/fixture07.out new file mode 100644 index 000000000..39e6a11e8 --- /dev/null +++ b/tests/testdata/bundle/fixture07.out @@ -0,0 +1,23 @@ +const g = []; +class G { + #g; + constructor(shared){ + if (shared) { + this.#g = g; + } else { + this.#g = []; + } + } +} +const g1 = []; +class H { + #g; + constructor(shared1){ + if (shared1) { + this.#g = g1; + } else { + this.#g = []; + } + } +} +console.log(new G(true), new H(true)); diff --git a/tests/testdata/bundle/fixture08.out b/tests/testdata/bundle/fixture08.out new file mode 100644 index 000000000..bfe40aa37 --- /dev/null +++ b/tests/testdata/bundle/fixture08.out @@ -0,0 +1,7 @@ +const a1 = "a"; +const mod = function() { + return { + a: a1 + }; +}(); +export { mod as a }; diff --git a/tests/testdata/bundle/fixture09.out b/tests/testdata/bundle/fixture09.out new file mode 100644 index 000000000..e06cc92de --- /dev/null +++ b/tests/testdata/bundle/fixture09.out @@ -0,0 +1,19 @@ +function a3(...d) { + return d.join(" "); +} +const mod = function() { + return { + a: a3 + }; +}(); +function a1(...d) { + return d.join("/"); +} +const mod1 = function() { + return { + a: a1 + }; +}(); +const k = globalThis.value ? mod : mod1; +const { a: a2 , } = k; +export { a2 as a }; diff --git a/tests/testdata/bundle/fixture10.out b/tests/testdata/bundle/fixture10.out new file mode 100644 index 000000000..5491e5e7f --- /dev/null +++ b/tests/testdata/bundle/fixture10.out @@ -0,0 +1,5 @@ +const a = "a"; +const o = { +}; +const { a: a1 = a } = o; +console.log(a1); diff --git a/tests/testdata/bundle/fixture11.out b/tests/testdata/bundle/fixture11.out new file mode 100644 index 000000000..4f333a513 --- /dev/null +++ b/tests/testdata/bundle/fixture11.out @@ -0,0 +1,30 @@ +function a() { + console.log("a"); +} +var O1; +(function(O) { + O[O["A"] = 0] = "A"; + O[O["B"] = 1] = "B"; + O[O["C"] = 2] = "C"; +})(O1 || (O1 = { +})); +export { O1 as O }; +class A { + #a; + #c; + constructor(o = { + }){ + const { a: a1 = a , c , } = o; + this.#a = a1; + this.#c = c; + } + a() { + this.#a(); + } + c() { + console.log(this.#c); + } +} +const a2 = new A(); +a2.a(); +a2.c(); diff --git a/tests/testdata/bundle/fixture12.out b/tests/testdata/bundle/fixture12.out new file mode 100644 index 000000000..64e2d6cdb --- /dev/null +++ b/tests/testdata/bundle/fixture12.out @@ -0,0 +1,7 @@ +function a(...d) { + return d.join(" "); +} +function b() { + a(); +} +b(); diff --git a/tests/testdata/bundle/fixture13.out b/tests/testdata/bundle/fixture13.out new file mode 100644 index 000000000..1c7a8c991 --- /dev/null +++ b/tests/testdata/bundle/fixture13.out @@ -0,0 +1,17 @@ +function d() { + let methods; + const promise = new Promise((resolve, reject)=>{ + methods = { + resolve, + reject + }; + }); + return Object.assign(promise, methods); +} +class A { + s = d(); + a() { + this.s.resolve(); + } +} +new A(); diff --git a/tests/testdata/bundle/fixture14.out b/tests/testdata/bundle/fixture14.out new file mode 100644 index 000000000..392bb6478 --- /dev/null +++ b/tests/testdata/bundle/fixture14.out @@ -0,0 +1,2 @@ +const mod = []; +console.log(mod); diff --git a/tests/testdata/bundle/fixture15.out b/tests/testdata/bundle/fixture15.out new file mode 100644 index 000000000..dc72fdeff --- /dev/null +++ b/tests/testdata/bundle/fixture15.out @@ -0,0 +1,4 @@ +function getIndex1(c) { + return "\x00\r\n\x85\u2028\u2029".indexOf(c); +} +export { getIndex1 as getIndex }; diff --git a/tests/testdata/bundle/fixture16.out b/tests/testdata/bundle/fixture16.out new file mode 100644 index 000000000..5e21c2a71 --- /dev/null +++ b/tests/testdata/bundle/fixture16.out @@ -0,0 +1,6 @@ +[WILDCARD] +const a = "a"; +export { a as test1 }; +export { a as test2 }; +console.log(a); + diff --git a/tests/testdata/bundle/https_deno.land-x-lib-a.ts b/tests/testdata/bundle/https_deno.land-x-lib-a.ts new file mode 100644 index 000000000..a0a6f8e94 --- /dev/null +++ b/tests/testdata/bundle/https_deno.land-x-lib-a.ts @@ -0,0 +1 @@ +export const a: string[] = []; diff --git a/tests/testdata/bundle/https_deno.land-x-lib-b.js b/tests/testdata/bundle/https_deno.land-x-lib-b.js new file mode 100644 index 000000000..13cacdd8b --- /dev/null +++ b/tests/testdata/bundle/https_deno.land-x-lib-b.js @@ -0,0 +1 @@ +export const b = []; diff --git a/tests/testdata/bundle/https_deno.land-x-lib-c.d.ts b/tests/testdata/bundle/https_deno.land-x-lib-c.d.ts new file mode 100644 index 000000000..fac988e49 --- /dev/null +++ b/tests/testdata/bundle/https_deno.land-x-lib-c.d.ts @@ -0,0 +1 @@ +export const c: string[]; diff --git a/tests/testdata/bundle/https_deno.land-x-lib-c.js b/tests/testdata/bundle/https_deno.land-x-lib-c.js new file mode 100644 index 000000000..620ca0b66 --- /dev/null +++ b/tests/testdata/bundle/https_deno.land-x-lib-c.js @@ -0,0 +1,3 @@ +/// + +export const c = []; diff --git a/tests/testdata/bundle/https_deno.land-x-lib-mod.d.ts b/tests/testdata/bundle/https_deno.land-x-lib-mod.d.ts new file mode 100644 index 000000000..76ed81df0 --- /dev/null +++ b/tests/testdata/bundle/https_deno.land-x-lib-mod.d.ts @@ -0,0 +1,9 @@ +export * as a from "./a.ts"; +export * as b from "./b.js"; +export * as c from "./c.js"; + +export interface A { + a: string; +} + +export const mod: A[]; diff --git a/tests/testdata/bundle/https_deno.land-x-lib-mod.js b/tests/testdata/bundle/https_deno.land-x-lib-mod.js new file mode 100644 index 000000000..505162094 --- /dev/null +++ b/tests/testdata/bundle/https_deno.land-x-lib-mod.js @@ -0,0 +1,5 @@ +export * as a from "./a.ts"; +export * as b from "./b.js"; +export * as c from "./c.js"; + +export const mod = []; diff --git a/tests/testdata/bundle/ignore_directives.test.out b/tests/testdata/bundle/ignore_directives.test.out new file mode 100644 index 000000000..b69c2632c --- /dev/null +++ b/tests/testdata/bundle/ignore_directives.test.out @@ -0,0 +1,6 @@ +[WILDCARD] +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +[WILDCARD] diff --git a/tests/testdata/bundle/import_map/import_map.json b/tests/testdata/bundle/import_map/import_map.json new file mode 100644 index 000000000..c02f72718 --- /dev/null +++ b/tests/testdata/bundle/import_map/import_map.json @@ -0,0 +1,5 @@ +{ + "imports": { + "mod2": "../../subdir/subdir2/mod2.ts" + } +} diff --git a/tests/testdata/bundle/import_map/main.ts b/tests/testdata/bundle/import_map/main.ts new file mode 100644 index 000000000..74834de20 --- /dev/null +++ b/tests/testdata/bundle/import_map/main.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "mod2"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/testdata/bundle/jsx.out b/tests/testdata/bundle/jsx.out new file mode 100644 index 000000000..da83cde82 --- /dev/null +++ b/tests/testdata/bundle/jsx.out @@ -0,0 +1,9 @@ +[WILDCARD] +const React = { + createElement () {} +}; +function app() { + return React.createElement("div", null, React.createElement("h2", null, "asdf")); +} +console.log(app); + diff --git a/tests/testdata/bundle/lockfile/check_error.json b/tests/testdata/bundle/lockfile/check_error.json new file mode 100644 index 000000000..a218d7000 --- /dev/null +++ b/tests/testdata/bundle/lockfile/check_error.json @@ -0,0 +1,5 @@ +{ + "http://127.0.0.1:4545/subdir/mod1.ts": "bfc1037b02c99abc20367f739bca7455813a5950066abd77965bff33b6eece0f", + "http://127.0.0.1:4545/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c", + "http://127.0.0.1:4545/subdir/subdir2/mod2.ts": "bad" +} diff --git a/tests/testdata/bundle/lockfile/check_error.out b/tests/testdata/bundle/lockfile/check_error.out new file mode 100644 index 000000000..9299bc27e --- /dev/null +++ b/tests/testdata/bundle/lockfile/check_error.out @@ -0,0 +1,4 @@ +[WILDCARD] +error: The source code is invalid, as it does not match the expected hash in the lock file. + Specifier: http://127.0.0.1:4545/subdir/subdir2/mod2.ts + Lock file: bundle/lockfile/check_error.json diff --git a/tests/testdata/bundle/shebang_file.bundle.out b/tests/testdata/bundle/shebang_file.bundle.out new file mode 100644 index 000000000..d3369bc9c --- /dev/null +++ b/tests/testdata/bundle/shebang_file.bundle.out @@ -0,0 +1,12 @@ +⚠️ Warning: `deno bundle` is deprecated and will be removed in Deno 2.0. +Use an alternative bundler like "deno_emit", "esbuild" or "rollup" instead. +Bundle file:///[WILDCARD]/subdir/shebang_file.js +#!/usr/bin/env -S deno run --allow-read +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +for (const item of Deno.readDirSync(".")){ + console.log(item.name); +} + -- cgit v1.2.3