diff options
Diffstat (limited to 'cli/tests')
20 files changed, 132 insertions, 33 deletions
diff --git a/cli/tests/044_bad_resource.ts.out b/cli/tests/044_bad_resource.ts.out index 026beb341..a54c800f8 100644 --- a/cli/tests/044_bad_resource.ts.out +++ b/cli/tests/044_bad_resource.ts.out @@ -2,5 +2,5 @@ error: Uncaught BadResource: Bad resource ID [WILDCARD]dispatch_json.ts:[WILDCARD] at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD]) + at Object.sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD]) at async main ([WILDCARD]tests/044_bad_resource.ts:[WILDCARD]) diff --git a/cli/tests/error_004_missing_module.ts.out b/cli/tests/error_004_missing_module.ts.out index 691d5ce5a..e82cb00da 100644 --- a/cli/tests/error_004_missing_module.ts.out +++ b/cli/tests/error_004_missing_module.ts.out @@ -1,9 +1,9 @@ [WILDCARD]error: Uncaught NotFound: Cannot resolve module "[WILDCARD]/bad-module.ts" from "[WILDCARD]/error_004_missing_module.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at async processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at Object.sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD]) at async processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at async Object.processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) at async compile ([WILDCARD]compiler.ts:[WILDCARD]) at async tsCompilerOnMessage ([WILDCARD]compiler.ts:[WILDCARD]) at async workerMessageRecvCallback ([WILDCARD]runtime_worker.ts:[WILDCARD]) diff --git a/cli/tests/error_005_missing_dynamic_import.ts.out b/cli/tests/error_005_missing_dynamic_import.ts.out index 4a7822e43..a67241ec1 100644 --- a/cli/tests/error_005_missing_dynamic_import.ts.out +++ b/cli/tests/error_005_missing_dynamic_import.ts.out @@ -1,9 +1,9 @@ [WILDCARD]error: Uncaught NotFound: Cannot resolve module "[WILDCARD]/bad-module.ts" from "[WILDCARD]/error_005_missing_dynamic_import.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at async processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at Object.sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD]) at async processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at async Object.processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) at async compile ([WILDCARD]compiler.ts:[WILDCARD]) at async tsCompilerOnMessage ([WILDCARD]compiler.ts:[WILDCARD]) at async workerMessageRecvCallback ([WILDCARD]runtime_worker.ts:[WILDCARD]) diff --git a/cli/tests/error_006_import_ext_failure.ts.out b/cli/tests/error_006_import_ext_failure.ts.out index c4e6a1037..57830c405 100644 --- a/cli/tests/error_006_import_ext_failure.ts.out +++ b/cli/tests/error_006_import_ext_failure.ts.out @@ -1,9 +1,9 @@ [WILDCARD]error: Uncaught NotFound: Cannot resolve module "[WILDCARD]/non-existent" from "[WILDCARD]/error_006_import_ext_failure.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at async processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at Object.sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD]) at async processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at async Object.processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) at async compile ([WILDCARD]compiler.ts:[WILDCARD]) at async tsCompilerOnMessage ([WILDCARD]compiler.ts:[WILDCARD]) at async workerMessageRecvCallback ([WILDCARD]runtime_worker.ts:[WILDCARD]) diff --git a/cli/tests/error_011_bad_module_specifier.ts.out b/cli/tests/error_011_bad_module_specifier.ts.out index 5ac95002f..d85177dc1 100644 --- a/cli/tests/error_011_bad_module_specifier.ts.out +++ b/cli/tests/error_011_bad_module_specifier.ts.out @@ -1,10 +1,10 @@ [WILDCARD]error: Uncaught URIError: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_011_bad_module_specifier.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] at unwrapResponse ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) - at sendSync ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) + at Object.sendSync ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) at resolveModules ([WILDCARD]compiler/imports.ts:[WILDCARD]) at processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) - at processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at Object.processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) at async compile ([WILDCARD]compiler.ts:[WILDCARD]) at async tsCompilerOnMessage ([WILDCARD]compiler.ts:[WILDCARD]) at async workerMessageRecvCallback ([WILDCARD]runtime_worker.ts:[WILDCARD]) diff --git a/cli/tests/error_012_bad_dynamic_import_specifier.ts.out b/cli/tests/error_012_bad_dynamic_import_specifier.ts.out index 505f29f82..59b968e81 100644 --- a/cli/tests/error_012_bad_dynamic_import_specifier.ts.out +++ b/cli/tests/error_012_bad_dynamic_import_specifier.ts.out @@ -1,10 +1,10 @@ [WILDCARD]error: Uncaught URIError: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_012_bad_dynamic_import_specifier.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] at unwrapResponse ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) - at sendSync ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) + at Object.sendSync ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) at resolveModules ([WILDCARD]compiler/imports.ts:[WILDCARD]) at processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) - at processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at Object.processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) at async compile ([WILDCARD]compiler.ts:[WILDCARD]) at async tsCompilerOnMessage ([WILDCARD]compiler.ts:[WILDCARD]) at async workerMessageRecvCallback ([WILDCARD]runtime_worker.ts:[WILDCARD]) diff --git a/cli/tests/error_019_stack_function.ts b/cli/tests/error_019_stack_function.ts new file mode 100644 index 000000000..c5eeae8f4 --- /dev/null +++ b/cli/tests/error_019_stack_function.ts @@ -0,0 +1,10 @@ +function foo(): never { + throw new Error("function"); +} + +try { + foo(); +} catch (error) { + console.log(error.stack); + throw error; +} diff --git a/cli/tests/error_019_stack_function.ts.out b/cli/tests/error_019_stack_function.ts.out new file mode 100644 index 000000000..a360e7d8e --- /dev/null +++ b/cli/tests/error_019_stack_function.ts.out @@ -0,0 +1,6 @@ +[WILDCARD]Error: function + at foo ([WILDCARD]tests/error_019_stack_function.ts:[WILDCARD]) + at [WILDCARD]tests/error_019_stack_function.ts:[WILDCARD] +error: Uncaught Error: function + at foo ([WILDCARD]tests/error_019_stack_function.ts:[WILDCARD]) + at [WILDCARD]tests/error_019_stack_function.ts:[WILDCARD] diff --git a/cli/tests/error_020_stack_constructor.ts b/cli/tests/error_020_stack_constructor.ts new file mode 100644 index 000000000..49988280b --- /dev/null +++ b/cli/tests/error_020_stack_constructor.ts @@ -0,0 +1,12 @@ +class A { + constructor() { + throw new Error("constructor"); + } +} + +try { + new A(); +} catch (error) { + console.log(error.stack); + throw error; +} diff --git a/cli/tests/error_020_stack_constructor.ts.out b/cli/tests/error_020_stack_constructor.ts.out new file mode 100644 index 000000000..a60e375d7 --- /dev/null +++ b/cli/tests/error_020_stack_constructor.ts.out @@ -0,0 +1,6 @@ +[WILDCARD]Error: constructor + at new A ([WILDCARD]tests/error_020_stack_constructor.ts:[WILDCARD]) + at [WILDCARD]tests/error_020_stack_constructor.ts:[WILDCARD] +error: Uncaught Error: constructor + at new A ([WILDCARD]tests/error_020_stack_constructor.ts:[WILDCARD]) + at [WILDCARD]tests/error_020_stack_constructor.ts:[WILDCARD] diff --git a/cli/tests/error_021_stack_method.ts b/cli/tests/error_021_stack_method.ts new file mode 100644 index 000000000..a52d00deb --- /dev/null +++ b/cli/tests/error_021_stack_method.ts @@ -0,0 +1,12 @@ +class A { + m(): never { + throw new Error("method"); + } +} + +try { + new A().m(); +} catch (error) { + console.log(error.stack); + throw error; +} diff --git a/cli/tests/error_021_stack_method.ts.out b/cli/tests/error_021_stack_method.ts.out new file mode 100644 index 000000000..fff3e193b --- /dev/null +++ b/cli/tests/error_021_stack_method.ts.out @@ -0,0 +1,6 @@ +[WILDCARD]Error: method + at A.m ([WILDCARD]tests/error_021_stack_method.ts:[WILDCARD]) + at [WILDCARD]tests/error_021_stack_method.ts:[WILDCARD] +error: Uncaught Error: method + at A.m ([WILDCARD]tests/error_021_stack_method.ts:[WILDCARD]) + at [WILDCARD]tests/error_021_stack_method.ts:[WILDCARD] diff --git a/cli/tests/error_022_stack_custom_error.ts b/cli/tests/error_022_stack_custom_error.ts new file mode 100644 index 000000000..6f3c1b0bd --- /dev/null +++ b/cli/tests/error_022_stack_custom_error.ts @@ -0,0 +1,10 @@ +class CustomError extends Error { + constructor(message: string) { + super(message); + this.name = "CustomError"; + } +} + +const error = new CustomError("custom error"); +console.log(error.stack); +throw error; diff --git a/cli/tests/error_022_stack_custom_error.ts.out b/cli/tests/error_022_stack_custom_error.ts.out new file mode 100644 index 000000000..89c536ddb --- /dev/null +++ b/cli/tests/error_022_stack_custom_error.ts.out @@ -0,0 +1,4 @@ +[WILDCARD]CustomError: custom error + at [WILDCARD]tests/error_022_stack_custom_error.ts:[WILDCARD] +error: Uncaught CustomError: custom error + at [WILDCARD]tests/error_022_stack_custom_error.ts:[WILDCARD] diff --git a/cli/tests/error_023_stack_async.ts b/cli/tests/error_023_stack_async.ts new file mode 100644 index 000000000..621933576 --- /dev/null +++ b/cli/tests/error_023_stack_async.ts @@ -0,0 +1,12 @@ +const p = (async (): Promise<void> => { + await Promise.resolve().then((): never => { + throw new Error("async"); + }); +})(); + +try { + await p; +} catch (error) { + console.log(error.stack); + throw error; +} diff --git a/cli/tests/error_023_stack_async.ts.out b/cli/tests/error_023_stack_async.ts.out new file mode 100644 index 000000000..e5b707ce4 --- /dev/null +++ b/cli/tests/error_023_stack_async.ts.out @@ -0,0 +1,8 @@ +[WILDCARD]Error: async + at [WILDCARD]tests/error_023_stack_async.ts:[WILDCARD] + at async [WILDCARD]tests/error_023_stack_async.ts:[WILDCARD] + at async [WILDCARD]tests/error_023_stack_async.ts:[WILDCARD] +error: Uncaught Error: async + at [WILDCARD]tests/error_023_stack_async.ts:[WILDCARD] + at async [WILDCARD]tests/error_023_stack_async.ts:[WILDCARD] + at async [WILDCARD]tests/error_023_stack_async.ts:[WILDCARD] diff --git a/cli/tests/error_stack.ts b/cli/tests/error_stack.ts deleted file mode 100644 index f2125d662..000000000 --- a/cli/tests/error_stack.ts +++ /dev/null @@ -1,10 +0,0 @@ -function foo(): never { - throw new Error("foo"); -} - -try { - foo(); -} catch (e) { - console.log(e); - throw e; -} diff --git a/cli/tests/error_stack.ts.out b/cli/tests/error_stack.ts.out deleted file mode 100644 index 2bb629e2d..000000000 --- a/cli/tests/error_stack.ts.out +++ /dev/null @@ -1,6 +0,0 @@ -[WILDCARD]Error: foo - at foo ([WILDCARD]tests/error_stack.ts:2:9) - at [WILDCARD]tests/error_stack.ts:6:3 -error: Uncaught Error: foo - at foo ([WILDCARD]tests/error_stack.ts:2:9) - at [WILDCARD]tests/error_stack.ts:6:3 diff --git a/cli/tests/error_type_definitions.ts.out b/cli/tests/error_type_definitions.ts.out index 59773ac35..55d0e4dad 100644 --- a/cli/tests/error_type_definitions.ts.out +++ b/cli/tests/error_type_definitions.ts.out @@ -1,11 +1,12 @@ [WILDCARD]error: Uncaught URIError: relative import path "baz" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/type_definitions/bar.d.ts" -[WILDCARD]dispatch_json.ts:[WILDCARD] +[WILDCARD]ops/dispatch_json.ts:[WILDCARD] at unwrapResponse ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) - at sendSync ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) + at Object.sendSync ([WILDCARD]ops/dispatch_json.ts:[WILDCARD]) + at Object.resolveModules ([WILDCARD]ops/compiler.ts:[WILDCARD]) at resolveModules ([WILDCARD]compiler/imports.ts:[WILDCARD]) at processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) at processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) - at async processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) + at async Object.processImports ([WILDCARD]compiler/imports.ts:[WILDCARD]) at async compile ([WILDCARD]compiler.ts:[WILDCARD]) at async tsCompilerOnMessage ([WILDCARD]compiler.ts:[WILDCARD]) at async workerMessageRecvCallback ([WILDCARD]runtime_worker.ts:[WILDCARD]) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 31a4a9c66..d043958a9 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1371,11 +1371,39 @@ itest!(error_018_hide_long_source_js { exit_code: 1, }); -itest!(error_stack { - args: "run --reload error_stack.ts", +itest!(error_019_stack_function { + args: "error_019_stack_function.ts", + output: "error_019_stack_function.ts.out", + check_stderr: true, + exit_code: 1, +}); + +itest!(error_020_stack_constructor { + args: "error_020_stack_constructor.ts", + output: "error_020_stack_constructor.ts.out", + check_stderr: true, + exit_code: 1, +}); + +itest!(error_021_stack_method { + args: "error_021_stack_method.ts", + output: "error_021_stack_method.ts.out", + check_stderr: true, + exit_code: 1, +}); + +itest!(error_022_stack_custom_error { + args: "error_022_stack_custom_error.ts", + output: "error_022_stack_custom_error.ts.out", + check_stderr: true, + exit_code: 1, +}); + +itest!(error_023_stack_async { + args: "error_023_stack_async.ts", + output: "error_023_stack_async.ts.out", check_stderr: true, exit_code: 1, - output: "error_stack.ts.out", }); itest!(error_syntax { |