summaryrefslogtreecommitdiff
path: root/core/runtime/error_builder_test.js
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-06-13 20:03:10 -0600
committerGitHub <noreply@github.com>2023-06-14 02:03:10 +0000
commitec8e9d4f5bd2c8eed5f086356c1c6dd7c8b40b7f (patch)
tree2ffda9204901bfb757e8ce6359d1fc6aa2f9964b /core/runtime/error_builder_test.js
parentfd9d6baea311d9b227b130749647a86838ba2ccc (diff)
chore(core): Refactor runtime and split out tests (#19491)
This is a quick first refactoring to split the tests out of runtime and move runtime-related code to a top-level runtime module. There will be a followup to refactor imports a bit, but this is the major change that will most likely conflict with other work and I want to merge it early.
Diffstat (limited to 'core/runtime/error_builder_test.js')
-rw-r--r--core/runtime/error_builder_test.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/runtime/error_builder_test.js b/core/runtime/error_builder_test.js
new file mode 100644
index 000000000..f442819cb
--- /dev/null
+++ b/core/runtime/error_builder_test.js
@@ -0,0 +1,32 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+const { core } = Deno;
+const { ops } = core;
+
+class DOMException {
+ constructor(message, code) {
+ this.msg = message;
+ this.code = code;
+ }
+}
+
+core.registerErrorBuilder(
+ "DOMExceptionOperationError",
+ function DOMExceptionOperationError(msg) {
+ return new DOMException(msg, "OperationError");
+ },
+);
+
+try {
+ ops.op_err();
+ throw new Error("op_err didn't throw!");
+} catch (err) {
+ if (!(err instanceof DOMException)) {
+ throw new Error("err not DOMException");
+ }
+ if (err.msg !== "abc") {
+ throw new Error("err.message is incorrect");
+ }
+ if (err.code !== "OperationError") {
+ throw new Error("err.code is incorrect");
+ }
+}