From 1464b756a4ef091ef97d1bf7340188ab5fe5492a Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 19 Sep 2022 09:32:21 -0500 Subject: refactor: move out test files from root testdata directory into sub directories (#15949) --- .../bundle/bare_imports/error_with_bare_import.ts | 1 + .../bare_imports/error_with_bare_import.ts.out | 2 + cli/tests/testdata/bundle/bundle.test.out | 27 ++++++++++++ .../testdata/bundle/check_local_by_default.out | 6 --- .../testdata/bundle/check_local_by_default.ts | 3 -- .../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 +++ .../testdata/bundle/check_local_by_default2.out | 4 -- .../testdata/bundle/check_local_by_default2.ts | 6 --- .../testdata/bundle/decorators/ts_decorators.out | 49 ++++++++++++++++++++++ .../testdata/bundle/decorators/ts_decorators.ts | 25 +++++++++++ cli/tests/testdata/bundle/dynamic_import.ts | 3 ++ .../testdata/bundle/ignore_directives.test.out | 6 +++ .../testdata/bundle/import_map/import_map.json | 5 +++ cli/tests/testdata/bundle/import_map/main.ts | 17 ++++++++ cli/tests/testdata/bundle/jsx.out | 9 ++++ .../testdata/bundle/lockfile/check_error.json | 5 +++ cli/tests/testdata/bundle/lockfile/check_error.out | 4 ++ 20 files changed, 172 insertions(+), 19 deletions(-) create mode 100644 cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts create mode 100644 cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out create mode 100644 cli/tests/testdata/bundle/bundle.test.out delete mode 100644 cli/tests/testdata/bundle/check_local_by_default.out delete mode 100644 cli/tests/testdata/bundle/check_local_by_default.ts create mode 100644 cli/tests/testdata/bundle/check_local_by_default/no_errors.out create mode 100644 cli/tests/testdata/bundle/check_local_by_default/no_errors.ts create mode 100644 cli/tests/testdata/bundle/check_local_by_default/type_error.out create mode 100644 cli/tests/testdata/bundle/check_local_by_default/type_error.ts delete mode 100644 cli/tests/testdata/bundle/check_local_by_default2.out delete mode 100644 cli/tests/testdata/bundle/check_local_by_default2.ts create mode 100644 cli/tests/testdata/bundle/decorators/ts_decorators.out create mode 100644 cli/tests/testdata/bundle/decorators/ts_decorators.ts create mode 100644 cli/tests/testdata/bundle/dynamic_import.ts create mode 100644 cli/tests/testdata/bundle/ignore_directives.test.out create mode 100644 cli/tests/testdata/bundle/import_map/import_map.json create mode 100644 cli/tests/testdata/bundle/import_map/main.ts create mode 100644 cli/tests/testdata/bundle/jsx.out create mode 100644 cli/tests/testdata/bundle/lockfile/check_error.json create mode 100644 cli/tests/testdata/bundle/lockfile/check_error.out (limited to 'cli/tests/testdata/bundle') diff --git a/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts b/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts new file mode 100644 index 000000000..c0748305d --- /dev/null +++ b/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts @@ -0,0 +1 @@ +import "foo"; diff --git a/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out b/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out new file mode 100644 index 000000000..44d063a5e --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/bundle.test.out b/cli/tests/testdata/bundle/bundle.test.out new file mode 100644 index 000000000..6b1c109d3 --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/check_local_by_default.out b/cli/tests/testdata/bundle/check_local_by_default.out deleted file mode 100644 index c4559d1fa..000000000 --- a/cli/tests/testdata/bundle/check_local_by_default.out +++ /dev/null @@ -1,6 +0,0 @@ -// 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/cli/tests/testdata/bundle/check_local_by_default.ts b/cli/tests/testdata/bundle/check_local_by_default.ts deleted file mode 100644 index 2ae8c2692..000000000 --- a/cli/tests/testdata/bundle/check_local_by_default.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as a from "http://localhost:4545/subdir/type_error.ts"; - -console.log(a.a); diff --git a/cli/tests/testdata/bundle/check_local_by_default/no_errors.out b/cli/tests/testdata/bundle/check_local_by_default/no_errors.out new file mode 100644 index 000000000..c4559d1fa --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/check_local_by_default/no_errors.ts b/cli/tests/testdata/bundle/check_local_by_default/no_errors.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/check_local_by_default/type_error.out b/cli/tests/testdata/bundle/check_local_by_default/type_error.out new file mode 100644 index 000000000..6d53e9498 --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/check_local_by_default/type_error.ts b/cli/tests/testdata/bundle/check_local_by_default/type_error.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/check_local_by_default2.out b/cli/tests/testdata/bundle/check_local_by_default2.out deleted file mode 100644 index 60f5760f8..000000000 --- a/cli/tests/testdata/bundle/check_local_by_default2.out +++ /dev/null @@ -1,4 +0,0 @@ -error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. -const b: "b" = 12; - ^ - at [WILDCARD]bundle/check_local_by_default2.ts:3:7 diff --git a/cli/tests/testdata/bundle/check_local_by_default2.ts b/cli/tests/testdata/bundle/check_local_by_default2.ts deleted file mode 100644 index 5177ff944..000000000 --- a/cli/tests/testdata/bundle/check_local_by_default2.ts +++ /dev/null @@ -1,6 +0,0 @@ -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/cli/tests/testdata/bundle/decorators/ts_decorators.out b/cli/tests/testdata/bundle/decorators/ts_decorators.out new file mode 100644 index 000000000..2f503fdd0 --- /dev/null +++ b/cli/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 + +var __decorate = this && this.__decorate || function(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"); + } +} +__decorate([ + a() +], B.prototype, "method", null); +var __decorate1 = this && this.__decorate || function(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() {} +} +__decorate1([ + Decorator() +], SomeClass.prototype, "test", null); +new SomeClass().test(); +new B().method(); +[WILDCARD] \ No newline at end of file diff --git a/cli/tests/testdata/bundle/decorators/ts_decorators.ts b/cli/tests/testdata/bundle/decorators/ts_decorators.ts new file mode 100644 index 000000000..61299bccf --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/dynamic_import.ts b/cli/tests/testdata/bundle/dynamic_import.ts new file mode 100644 index 000000000..d8c7d08ec --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/ignore_directives.test.out b/cli/tests/testdata/bundle/ignore_directives.test.out new file mode 100644 index 000000000..b69c2632c --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/import_map/import_map.json b/cli/tests/testdata/bundle/import_map/import_map.json new file mode 100644 index 000000000..c02f72718 --- /dev/null +++ b/cli/tests/testdata/bundle/import_map/import_map.json @@ -0,0 +1,5 @@ +{ + "imports": { + "mod2": "../../subdir/subdir2/mod2.ts" + } +} diff --git a/cli/tests/testdata/bundle/import_map/main.ts b/cli/tests/testdata/bundle/import_map/main.ts new file mode 100644 index 000000000..74834de20 --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/jsx.out b/cli/tests/testdata/bundle/jsx.out new file mode 100644 index 000000000..da83cde82 --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/lockfile/check_error.json b/cli/tests/testdata/bundle/lockfile/check_error.json new file mode 100644 index 000000000..a218d7000 --- /dev/null +++ b/cli/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/cli/tests/testdata/bundle/lockfile/check_error.out b/cli/tests/testdata/bundle/lockfile/check_error.out new file mode 100644 index 000000000..9299bc27e --- /dev/null +++ b/cli/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 -- cgit v1.2.3