diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-05-17 19:50:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 13:50:31 -0400 |
commit | f57aac77ff9ce514730504066daca0a61a959d32 (patch) | |
tree | 34be59895172b93a255c933d0f2e579dbf3a3ccc /cli/tests | |
parent | 9766399a3fefcab322051b4a7af41f9d40d79150 (diff) |
BREAKING: Remove unstable Deno.emit and Deno.formatDiagnostics APIs (#14463)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/compile_tests.rs | 70 | ||||
-rw-r--r-- | cli/tests/integration/mod.rs | 16 | ||||
-rw-r--r-- | cli/tests/integration/run_tests.rs | 44 | ||||
-rw-r--r-- | cli/tests/testdata/080_deno_emit_permissions.ts | 1 | ||||
-rw-r--r-- | cli/tests/testdata/080_deno_emit_permissions.ts.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/compiler_api_test.ts | 664 | ||||
-rw-r--r-- | cli/tests/testdata/issue12453.js | 4 | ||||
-rw-r--r-- | cli/tests/testdata/lib_dom_asynciterable.ts | 23 | ||||
-rw-r--r-- | cli/tests/testdata/lib_dom_asynciterable.ts.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/lib_dom_extras.ts | 17 | ||||
-rw-r--r-- | cli/tests/testdata/lib_dom_extras.ts.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/lib_ref.ts | 16 | ||||
-rw-r--r-- | cli/tests/testdata/lib_ref.ts.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/lib_runtime_api.ts | 14 | ||||
-rw-r--r-- | cli/tests/testdata/lib_runtime_api.ts.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/standalone_compiler_ops.ts | 12 | ||||
-rw-r--r-- | cli/tests/testdata/unstable_worker.ts.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/workers/worker_unstable.ts | 2 | ||||
-rw-r--r-- | cli/tests/unit/format_error_test.ts | 39 |
19 files changed, 2 insertions, 932 deletions
diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs index 4e45adc07..2f75659cf 100644 --- a/cli/tests/integration/compile_tests.rs +++ b/cli/tests/integration/compile_tests.rs @@ -226,76 +226,6 @@ fn standalone_follow_redirects() { } #[test] -fn standalone_compiler_ops() { - let dir = TempDir::new(); - let exe = if cfg!(windows) { - dir.path().join("standalone_compiler_ops.exe") - } else { - dir.path().join("standalone_compiler_ops") - }; - let output = util::deno_cmd() - .current_dir(util::testdata_path()) - .arg("compile") - .arg("--unstable") - .arg("--output") - .arg(&exe) - .arg("./standalone_compiler_ops.ts") - .stdout(std::process::Stdio::piped()) - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - assert!(output.status.success()); - let output = Command::new(exe) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - assert!(output.status.success()); - assert_eq!(output.stdout, b"Hello, Compiler API!\n"); -} - -#[test] -fn compile_with_directory_output_flag() { - let dir = TempDir::new(); - let output_path = if cfg!(windows) { - dir.path().join(r"args\random\") - } else { - dir.path().join("args/random/") - }; - let output = util::deno_cmd() - .current_dir(util::testdata_path()) - .arg("compile") - .arg("--unstable") - .arg("--output") - .arg(&output_path) - .arg("./standalone_compiler_ops.ts") - .stdout(std::process::Stdio::piped()) - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - assert!(output.status.success()); - let exe = if cfg!(windows) { - output_path.join("standalone_compiler_ops.exe") - } else { - output_path.join("standalone_compiler_ops") - }; - assert!(&exe.exists()); - let output = Command::new(exe) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - assert!(output.status.success()); - assert_eq!(output.stdout, b"Hello, Compiler API!\n"); -} - -#[test] fn compile_with_file_exists_error() { let dir = TempDir::new(); let output_path = if cfg!(windows) { diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs index d1684e3ef..7acd92661 100644 --- a/cli/tests/integration/mod.rs +++ b/cli/tests/integration/mod.rs @@ -444,22 +444,6 @@ console.log("finish"); } #[test] -fn compiler_api() { - let status = util::deno_cmd() - .current_dir(util::testdata_path()) - .arg("test") - .arg("--unstable") - .arg("--reload") - .arg("--allow-read") - .arg("compiler_api_test.ts") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); -} - -#[test] fn broken_stdout() { let (reader, writer) = os_pipe::pipe().unwrap(); // drop the reader to create a broken pipe diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index dc158fd7a..4dc17bacb 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -450,12 +450,6 @@ itest!(_079_location_authentication { output: "079_location_authentication.ts.out", }); -itest!(_080_deno_emit_permissions { - args: "run --unstable 080_deno_emit_permissions.ts", - output: "080_deno_emit_permissions.ts.out", - exit_code: 1, -}); - itest!(_081_location_relative_fetch_redirect { args: "run --location http://127.0.0.1:4546/ --allow-net 081_location_relative_fetch_redirect.ts", output: "081_location_relative_fetch_redirect.ts.out", @@ -986,26 +980,6 @@ itest!(runtime_decorators { output: "runtime_decorators.ts.out", }); -itest!(lib_dom_asynciterable { - args: "run --quiet --unstable --reload lib_dom_asynciterable.ts", - output: "lib_dom_asynciterable.ts.out", -}); - -itest!(lib_dom_extras { - args: "run --quiet --unstable --reload lib_dom_extras.ts", - output: "lib_dom_extras.ts.out", -}); - -itest!(lib_ref { - args: "run --quiet --unstable --reload lib_ref.ts", - output: "lib_ref.ts.out", -}); - -itest!(lib_runtime_api { - args: "run --quiet --unstable --reload lib_runtime_api.ts", - output: "lib_runtime_api.ts.out", -}); - itest!(seed_random { args: "run --seed=100 seed_random.js", output: "seed_random.js.out", @@ -2417,24 +2391,6 @@ itest!(eval_context_throw_dom_exception { envs: vec![("DENO_FUTURE_CHECK".to_string(), "1".to_string())], }); -#[test] -fn issue12453() { - let _g = util::http_server(); - let deno_dir = util::new_deno_dir(); - let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir); - let status = deno_cmd - .current_dir(util::testdata_path()) - .arg("run") - .arg("--unstable") - .arg("--allow-net") - .arg("issue12453.js") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); -} - /// Regression test for https://github.com/denoland/deno/issues/12740. #[test] fn issue12740() { diff --git a/cli/tests/testdata/080_deno_emit_permissions.ts b/cli/tests/testdata/080_deno_emit_permissions.ts deleted file mode 100644 index dc550cffb..000000000 --- a/cli/tests/testdata/080_deno_emit_permissions.ts +++ /dev/null @@ -1 +0,0 @@ -await Deno.emit(new URL("001_hello.js", import.meta.url).href); diff --git a/cli/tests/testdata/080_deno_emit_permissions.ts.out b/cli/tests/testdata/080_deno_emit_permissions.ts.out deleted file mode 100644 index 4eb4fd1c1..000000000 --- a/cli/tests/testdata/080_deno_emit_permissions.ts.out +++ /dev/null @@ -1,2 +0,0 @@ -[WILDCARD]error: Uncaught (in promise) PermissionDenied: Requires read access to "[WILDCARD]001_hello.js", run again with the --allow-read flag -[WILDCARD] diff --git a/cli/tests/testdata/compiler_api_test.ts b/cli/tests/testdata/compiler_api_test.ts deleted file mode 100644 index 81f049ac1..000000000 --- a/cli/tests/testdata/compiler_api_test.ts +++ /dev/null @@ -1,664 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { - assert, - assertEquals, - assertRejects, - assertStringIncludes, -} from "../../../test_util/std/testing/asserts.ts"; - -Deno.test({ - name: "Deno.emit() - sources provided", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "/foo.ts", - { - sources: { - "/foo.ts": `import * as bar from "./bar.ts";\n\nconsole.log(bar);\n`, - "/bar.ts": `export const bar = "bar";\n`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - const keys = Object.keys(files).sort(); - assert(keys[0].endsWith("/bar.ts.js")); - assert(keys[1].endsWith("/bar.ts.js.map")); - assert(keys[2].endsWith("/foo.ts.js")); - assert(keys[3].endsWith("/foo.ts.js.map")); - }, -}); - -Deno.test({ - name: "Deno.emit() - no sources provided", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "./subdir/mod1.ts", - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - const keys = Object.keys(files).sort(); - assertEquals(keys.length, 6); - assert(keys[0].endsWith("subdir/mod1.ts.js")); - assert(keys[1].endsWith("subdir/mod1.ts.js.map")); - }, -}); - -Deno.test({ - name: "Deno.emit() - data url", - async fn() { - const data = - "data:application/javascript;base64,Y29uc29sZS5sb2coImhlbGxvIHdvcmxkIik7"; - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit(data); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 0); - const keys = Object.keys(files); - assertEquals(keys.length, 1); - assertEquals(keys[0], data); - assertStringIncludes(files[keys[0]], 'console.log("hello world");'); - }, -}); - -Deno.test({ - name: "Deno.emit() - compiler options effects emit", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "/foo.ts", - { - compilerOptions: { - module: "amd", - sourceMap: false, - }, - sources: { "/foo.ts": `export const foo = "foo";` }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - const keys = Object.keys(files); - assertEquals(keys.length, 1); - const key = keys[0]; - assert(key.endsWith("/foo.ts.js")); - assert(files[key].startsWith("define(")); - }, -}); - -Deno.test({ - name: "Deno.emit() - pass lib in compiler options", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "file:///foo.ts", - { - compilerOptions: { - lib: ["dom", "es2018", "deno.ns"], - }, - sources: { - "file:///foo.ts": `console.log(document.getElementById("foo")); - console.log(Deno.args);`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - const keys = Object.keys(files).sort(); - assertEquals(keys, ["file:///foo.ts.js", "file:///foo.ts.js.map"]); - }, -}); - -Deno.test({ - name: "Deno.emit() - type references can be loaded", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "file:///a.ts", - { - sources: { - "file:///a.ts": `/// <reference types="./b.d.ts" /> - const b = new B(); - console.log(b.b);`, - "file:///b.d.ts": `declare class B { - b: string; - }`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - const keys = Object.keys(files).sort(); - assertEquals(keys, ["file:///a.ts.js", "file:///a.ts.js.map"]); - }, -}); - -Deno.test({ - name: "Deno.emit() - compilerOptions.types", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "file:///a.ts", - { - compilerOptions: { - types: ["file:///b.d.ts"], - }, - sources: { - "file:///a.ts": `const b = new B(); - console.log(b.b);`, - "file:///b.d.ts": `declare class B { - b: string; - }`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - const keys = Object.keys(files).sort(); - assertEquals(keys, ["file:///a.ts.js", "file:///a.ts.js.map"]); - }, -}); - -Deno.test({ - name: "Deno.emit() - import maps", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "file:///a.ts", - { - importMap: { - imports: { - "b": "./b.ts", - }, - }, - importMapPath: "file:///import-map.json", - sources: { - "file:///a.ts": `import * as b from "b" - console.log(b);`, - "file:///b.ts": `export const b = "b";`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - const keys = Object.keys(files).sort(); - assertEquals( - keys, - [ - "file:///a.ts.js", - "file:///a.ts.js.map", - "file:///b.ts.js", - "file:///b.ts.js.map", - ], - ); - }, -}); - -Deno.test({ - name: "Deno.emit() - allowSyntheticDefaultImports true by default", - async fn() { - const { diagnostics, files, ignoredOptions } = await Deno.emit( - "file:///a.ts", - { - sources: { - "file:///a.ts": `import b from "./b.js";\n`, - "file:///b.js": - `/// <reference types="./b.d.ts";\n\nconst b = "b";\n\nexport default b;\n`, - "file:///b.d.ts": `declare const b: "b";\nexport = b;\n`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - const keys = Object.keys(files).sort(); - assertEquals(keys, [ - "file:///a.ts.js", - "file:///a.ts.js.map", - "file:///b.js", - ]); - }, -}); - -Deno.test({ - name: "Deno.emit() - no check", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "/foo.ts", - { - check: false, - sources: { - "/foo.ts": `export enum Foo { Foo, Bar, Baz };\n`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 3); - const keys = Object.keys(files).sort(); - assert(keys[0].endsWith("/foo.ts.js")); - assert(keys[1].endsWith("/foo.ts.js.map")); - assert(files[keys[0]].startsWith("export var Foo;")); - }, -}); - -Deno.test({ - name: "Deno.emit() - no check - config effects emit", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "/foo.ts", - { - check: false, - compilerOptions: { removeComments: true }, - sources: { - "/foo.ts": - `/** This is JSDoc */\nexport enum Foo { Foo, Bar, Baz };\n`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 3); - const keys = Object.keys(files).sort(); - assert(keys[0].endsWith("/foo.ts.js")); - assert(keys[1].endsWith("/foo.ts.js.map")); - assert(!files[keys[0]].includes("This is JSDoc")); - }, -}); - -Deno.test({ - name: "Deno.emit() - bundle as module script - with sources", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "/foo.ts", - { - bundle: "module", - sources: { - "/foo.ts": `export * from "./bar.ts";\n`, - "/bar.ts": `export const bar = "bar";\n`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - assertEquals( - Object.keys(files).sort(), - ["deno:///bundle.js", "deno:///bundle.js.map"].sort(), - ); - assert(files["deno:///bundle.js"].includes(`const bar = "bar"`)); - }, -}); - -Deno.test({ - name: "Deno.emit() - bundle as module script - no sources", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "./subdir/mod1.ts", - { - bundle: "module", - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 12); - assertEquals( - Object.keys(files).sort(), - ["deno:///bundle.js", "deno:///bundle.js.map"].sort(), - ); - assert(files["deno:///bundle.js"].length); - }, -}); - -Deno.test({ - name: "Deno.emit() - bundle as module script - include js modules", - async fn() { - const { diagnostics, files, ignoredOptions, stats } = await Deno.emit( - "/foo.js", - { - bundle: "module", - sources: { - "/foo.js": `export * from "./bar.js";\n`, - "/bar.js": `export const bar = "bar";\n`, - }, - }, - ); - assertEquals(diagnostics.length, 0); - assert(!ignoredOptions); - assertEquals(stats.length, 0); - assertEquals( - Object.keys(files).sort(), - ["deno:///bundle.js.map", "deno:///bundle.js"].sort(), - ); - assert(files["deno:///bundle.js"].includes(`const bar = "bar"`)); - }, -}); - -Deno.test({ - name: "Deno.emit() - generates diagnostics", - async fn() { - const { diagnostics, files } = await Deno.emit( - "/foo.ts", - { - sources: { - "/foo.ts": `document.getElementById("foo");`, - }, - }, - ); - assertEquals(diagnostics.length, 1); - const keys = Object.keys(files).sort(); - assert(keys[0].endsWith("/foo.ts.js")); - assert(keys[1].endsWith("/foo.ts.js.map")); - }, -}); - -// See https://github.com/denoland/deno/issues/6908 -Deno.test({ - name: "Deno.emit() - invalid syntax does not panic", - async fn() { - const { diagnostics } = await Deno.emit("/main.js", { - sources: { - "/main.js": ` - export class Foo { - constructor() { - console.log("foo"); - } - export get() { - console.log("bar"); - } - }`, - }, - }); - assertEquals(diagnostics.length, 1); - assert( - diagnostics[0].messageText!.startsWith( - "The module's source code could not be parsed: Unexpected token `get`. Expected * for generator, private key, identifier or async at file:", - ), - ); - }, -}); - -Deno.test({ - name: 'Deno.emit() - allows setting of "importsNotUsedAsValues"', - async fn() { - const { diagnostics } = await Deno.emit("/a.ts", { - sources: { - "/a.ts": `import { B } from "./b.ts"; - const b: B = { b: "b" };`, - "/b.ts": `export interface B { - b:string; - };`, - }, - compilerOptions: { - importsNotUsedAsValues: "error", - }, - }); - assert(diagnostics); - assertEquals(diagnostics.length, 1); - assert(diagnostics[0].messageText); - assert(diagnostics[0].messageText.includes("This import is never used")); - }, -}); - -Deno.test({ - name: "Deno.emit() - Unknown media type does not panic", - async fn() { - await Deno.emit("https://example.com/foo", { - sources: { - "https://example.com/foo": `let foo: string = "foo";`, - }, - }); - }, -}); - -Deno.test({ - name: "Deno.emit() - non-normalized specifier and source can compile", - async fn() { - const specifier = "https://example.com/foo//bar.ts"; - const { files } = await Deno.emit(specifier, { - sources: { - [specifier]: `export let foo: string = "foo";`, - }, - }); - assertEquals(files[`${specifier}.js`], 'export let foo = "foo";\n'); - assert(typeof files[`${specifier}.js.map`] === "string"); - }, -}); - -Deno.test({ - name: `Deno.emit() - bundle as classic script iife`, - async fn() { - const { diagnostics, files } = await Deno.emit("/a.ts", { - bundle: "classic", - sources: { - "/a.ts": `import { b } from "./b.ts"; - console.log(b);`, - "/b.ts": `export const b = "b";`, - }, - }); - const ignoreDirecives = [ - "// deno-fmt-ignore-file", - "// deno-lint-ignore-file", - "// This code was bundled using `deno bundle` and it's not recommended to edit it manually", - "", - "", - ].join("\n"); - assert(diagnostics); - assertEquals(diagnostics.length, 0); - assertEquals(Object.keys(files).length, 2); - assert( - files["deno:///bundle.js"].startsWith( - ignoreDirecives + "(function() {\n", - ), - ); - assert(files["deno:///bundle.js"].endsWith("})();\n")); - assert(files["deno:///bundle.js.map"]); - }, -}); - -Deno.test({ - name: `Deno.emit() - throws descriptive error when unable to load import map`, - async fn() { - await assertRejects( - async () => { - await Deno.emit("/a.ts", { - bundle: "classic", - sources: { - "/a.ts": `console.log("hello");`, - }, - importMapPath: "file:///import_map_does_not_exist.json", - }); - }, - Error, - "Unable to load 'file:///import_map_does_not_exist.json' import map", - ); - }, -}); - -Deno.test({ - name: `Deno.emit() - support source maps with bundle option`, - async fn() { - { - const { diagnostics, files } = await Deno.emit("/a.ts", { - bundle: "classic", - sources: { - "/a.ts": `import { b } from "./b.ts"; - console.log(b);`, - "/b.ts": `export const b = "b";`, - }, - compilerOptions: { - inlineSourceMap: true, - sourceMap: false, - }, - }); - assert(diagnostics); - assertEquals(diagnostics.length, 0); - assertEquals(Object.keys(files).length, 1); - assertStringIncludes(files["deno:///bundle.js"], "sourceMappingURL"); - } - - const { diagnostics, files } = await Deno.emit("/a.ts", { - bundle: "classic", - sources: { - "/a.ts": `import { b } from "./b.ts"; - console.log(b);`, - "/b.ts": `export const b = "b";`, - }, - }); - assert(diagnostics); - assertEquals(diagnostics.length, 0); - assertEquals(Object.keys(files).length, 2); - assert(files["deno:///bundle.js"]); - assert(files["deno:///bundle.js.map"]); - }, -}); - -Deno.test({ - name: `Deno.emit() - graph errors as diagnostics`, - ignore: Deno.build.os === "windows", - async fn() { - const { diagnostics } = await Deno.emit("/a.ts", { - sources: { - "/a.ts": `import { b } from "./b.ts"; - console.log(b);`, - }, - }); - assert(diagnostics); - assertEquals(diagnostics, [ - { - category: 1, - code: 2305, - start: { line: 0, character: 9 }, - end: { line: 0, character: 10 }, - messageText: - `Module '"deno:///missing_dependency.d.ts"' has no exported member 'b'.`, - messageChain: null, - source: null, - sourceLine: 'import { b } from "./b.ts";', - fileName: "file:///a.ts", - relatedInformation: null, - }, - { - category: 1, - code: 900001, - start: null, - end: null, - messageText: 'Module not found "file:///b.ts".', - messageChain: null, - source: null, - sourceLine: null, - fileName: "file:///b.ts", - relatedInformation: null, - }, - ]); - assert( - Deno.formatDiagnostics(diagnostics).includes( - 'Module not found "file:///b.ts".', - ), - ); - }, -}); - -Deno.test({ - name: "Deno.emit() - no check respects inlineSources compiler option", - async fn() { - const { files } = await Deno.emit( - "file:///a.ts", - { - check: false, - compilerOptions: { - types: ["file:///b.d.ts"], - inlineSources: true, - }, - sources: { - "file:///a.ts": `const b = new B(); - console.log(b.b);`, - "file:///b.d.ts": `declare class B { - b: string; - }`, - }, - }, - ); - const sourceMap: { sourcesContent?: string[] } = JSON.parse( - files["file:///a.ts.js.map"], - ); - assert(sourceMap.sourcesContent); - assertEquals(sourceMap.sourcesContent.length, 1); - }, -}); - -Deno.test({ - name: "Deno.emit() - JSX import source pragma", - async fn() { - const { files } = await Deno.emit( - "file:///a.tsx", - { - sources: { - "file:///a.tsx": `/** @jsxImportSource https://example.com/jsx */ - - export function App() { - return ( - <div><></></div> - ); - }`, - "https://example.com/jsx/jsx-runtime": `export function jsx( - _type, - _props, - _key, - _source, - _self, - ) {} - export const jsxs = jsx; - export const jsxDEV = jsx; - export const Fragment = Symbol("Fragment"); - console.log("imported", import.meta.url); - `, - }, - }, - ); - assert(files["file:///a.tsx.js"]); - assert( - files["file:///a.tsx.js"].startsWith( - `import { Fragment as _Fragment, jsx as _jsx } from "https://example.com/jsx/jsx-runtime";\n`, - ), - ); - }, -}); - -Deno.test({ - name: "Deno.emit() - JSX import source no pragma", - async fn() { - const { files } = await Deno.emit( - "file:///a.tsx", - { - compilerOptions: { - jsx: "react-jsx", - jsxImportSource: "https://example.com/jsx", - }, - sources: { - "file:///a.tsx": `export function App() { - return ( - <div><></></div> - ); - }`, - "https://example.com/jsx/jsx-runtime": `export function jsx( - _type, - _props, - _key, - _source, - _self, - ) {} - export const jsxs = jsx; - export const jsxDEV = jsx; - export const Fragment = Symbol("Fragment"); - console.log("imported", import.meta.url); - `, - }, - }, - ); - assert(files["file:///a.tsx.js"]); - assert( - files["file:///a.tsx.js"].startsWith( - `import { Fragment as _Fragment, jsx as _jsx } from "https://example.com/jsx/jsx-runtime";\n`, - ), - ); - }, -}); diff --git a/cli/tests/testdata/issue12453.js b/cli/tests/testdata/issue12453.js deleted file mode 100644 index 2ed1b5ae7..000000000 --- a/cli/tests/testdata/issue12453.js +++ /dev/null @@ -1,4 +0,0 @@ -const i = setInterval(() => { - Deno.emit("http://localhost:4545/subdir/mt_text_typescript.t1.ts"); - clearInterval(i); -}, 1); diff --git a/cli/tests/testdata/lib_dom_asynciterable.ts b/cli/tests/testdata/lib_dom_asynciterable.ts deleted file mode 100644 index d932011f4..000000000 --- a/cli/tests/testdata/lib_dom_asynciterable.ts +++ /dev/null @@ -1,23 +0,0 @@ -const { diagnostics, files } = await Deno.emit("/main.ts", { - compilerOptions: { - target: "esnext", - lib: ["esnext", "dom", "dom.iterable", "dom.asynciterable"], - }, - sources: { - "/main.ts": `const rs = new ReadableStream<string>({ - start(c) { - c.enqueue("hello"); - c.enqueue("deno"); - c.close(); - } - }); - - for await (const s of rs) { - console.log("s"); - } - `, - }, -}); - -console.log(diagnostics); -console.log(Object.keys(files).sort()); diff --git a/cli/tests/testdata/lib_dom_asynciterable.ts.out b/cli/tests/testdata/lib_dom_asynciterable.ts.out deleted file mode 100644 index 8b5e7adb6..000000000 --- a/cli/tests/testdata/lib_dom_asynciterable.ts.out +++ /dev/null @@ -1,2 +0,0 @@ -[] -[ "[WILDCARD]/main.ts.js", "[WILDCARD]/main.ts.js.map" ] diff --git a/cli/tests/testdata/lib_dom_extras.ts b/cli/tests/testdata/lib_dom_extras.ts deleted file mode 100644 index c061bd362..000000000 --- a/cli/tests/testdata/lib_dom_extras.ts +++ /dev/null @@ -1,17 +0,0 @@ -const { diagnostics, files } = await Deno.emit("/main.ts", { - compilerOptions: { - target: "esnext", - lib: ["esnext", "dom"], - }, - sources: { - "/main.ts": `const as = new AbortSignal(); - console.log(as.reason); - - const up = new URLPattern("https://example.com/books/:id"); - console.log(up); - `, - }, -}); - -console.log(diagnostics); -console.log(Object.keys(files).sort()); diff --git a/cli/tests/testdata/lib_dom_extras.ts.out b/cli/tests/testdata/lib_dom_extras.ts.out deleted file mode 100644 index 8b5e7adb6..000000000 --- a/cli/tests/testdata/lib_dom_extras.ts.out +++ /dev/null @@ -1,2 +0,0 @@ -[] -[ "[WILDCARD]/main.ts.js", "[WILDCARD]/main.ts.js.map" ] diff --git a/cli/tests/testdata/lib_ref.ts b/cli/tests/testdata/lib_ref.ts deleted file mode 100644 index 2454f8b5d..000000000 --- a/cli/tests/testdata/lib_ref.ts +++ /dev/null @@ -1,16 +0,0 @@ -const { diagnostics, files } = await Deno.emit( - "/main.ts", - { - sources: { - "/main.ts": - `/// <reference lib="dom" />\n\ndocument.getElementById("foo");\nDeno.args;`, - }, - compilerOptions: { - target: "es2018", - lib: ["es2018", "deno.ns"], - }, - }, -); - -console.log(diagnostics); -console.log(Object.keys(files).sort()); diff --git a/cli/tests/testdata/lib_ref.ts.out b/cli/tests/testdata/lib_ref.ts.out deleted file mode 100644 index 4e0f933fc..000000000 --- a/cli/tests/testdata/lib_ref.ts.out +++ /dev/null @@ -1,2 +0,0 @@ -[] -[ "file:///[WILDCARD]main.ts.js", "file:///[WILDCARD]main.ts.js.map" ] diff --git a/cli/tests/testdata/lib_runtime_api.ts b/cli/tests/testdata/lib_runtime_api.ts deleted file mode 100644 index 450d9480b..000000000 --- a/cli/tests/testdata/lib_runtime_api.ts +++ /dev/null @@ -1,14 +0,0 @@ -const { diagnostics, files } = await Deno.emit( - "/main.ts", - { - sources: { - "/main.ts": `document.getElementById("foo");`, - }, - compilerOptions: { - lib: ["dom", "esnext"], - }, - }, -); - -console.log(diagnostics); -console.log(Object.keys(files).sort()); diff --git a/cli/tests/testdata/lib_runtime_api.ts.out b/cli/tests/testdata/lib_runtime_api.ts.out deleted file mode 100644 index 4e0f933fc..000000000 --- a/cli/tests/testdata/lib_runtime_api.ts.out +++ /dev/null @@ -1,2 +0,0 @@ -[] -[ "file:///[WILDCARD]main.ts.js", "file:///[WILDCARD]main.ts.js.map" ] diff --git a/cli/tests/testdata/standalone_compiler_ops.ts b/cli/tests/testdata/standalone_compiler_ops.ts deleted file mode 100644 index b95e1222e..000000000 --- a/cli/tests/testdata/standalone_compiler_ops.ts +++ /dev/null @@ -1,12 +0,0 @@ -const { files } = await Deno.emit("/mod.ts", { - bundle: "classic", - sources: { - "/mod.ts": `import { hello } from "/hello.ts"; console.log(hello);`, - "/hello.ts": `export const hello: string = "Hello, Compiler API!"`, - }, - compilerOptions: { - sourceMap: false, - }, -}); - -eval(files["deno:///bundle.js"]); diff --git a/cli/tests/testdata/unstable_worker.ts.out b/cli/tests/testdata/unstable_worker.ts.out index ece47de97..b40bdfeb8 100644 --- a/cli/tests/testdata/unstable_worker.ts.out +++ b/cli/tests/testdata/unstable_worker.ts.out @@ -1,2 +1,2 @@ [Function: query] -[Function: emit] +[Function: setRaw] diff --git a/cli/tests/testdata/workers/worker_unstable.ts b/cli/tests/testdata/workers/worker_unstable.ts index a5b5f7ba2..5d14e228b 100644 --- a/cli/tests/testdata/workers/worker_unstable.ts +++ b/cli/tests/testdata/workers/worker_unstable.ts @@ -1,5 +1,5 @@ console.log(Deno.permissions.query); -console.log(Deno.emit); +console.log(Deno.setRaw); self.onmessage = () => { self.close(); }; diff --git a/cli/tests/unit/format_error_test.ts b/cli/tests/unit/format_error_test.ts deleted file mode 100644 index 5c9520535..000000000 --- a/cli/tests/unit/format_error_test.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { assert } from "./test_util.ts"; - -Deno.test(function formatDiagnosticBasic() { - const fixture: Deno.Diagnostic[] = [ - { - start: { - line: 0, - character: 0, - }, - end: { - line: 0, - character: 7, - }, - fileName: "test.ts", - messageText: - "Cannot find name 'console'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.", - sourceLine: `console.log("a");`, - category: 1, - code: 2584, - }, - ]; - const out = Deno.formatDiagnostics(fixture); - assert(out.includes("Cannot find name")); - assert(out.includes("test.ts")); -}); - -Deno.test(function formatDiagnosticError() { - let thrown = false; - // deno-lint-ignore no-explicit-any - const bad = ([{ hello: 123 }] as any) as Deno.Diagnostic[]; - try { - Deno.formatDiagnostics(bad); - } catch (e) { - assert(e instanceof Deno.errors.InvalidData); - thrown = true; - } - assert(thrown); -}); |