From c461f8fd2e36904b3334c9705726b713712f4a69 Mon Sep 17 00:00:00 2001 From: snek Date: Tue, 9 Jul 2024 10:07:56 -0700 Subject: fix: do not return undefined for missing global properties (#24474) accessing e.g. `Buffer` in `Mode::Deno` mode should throw, not return undefined. --------- Signed-off-by: snek --- tests/unit/globals_test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/unit') diff --git a/tests/unit/globals_test.ts b/tests/unit/globals_test.ts index 8e07cf005..e4cbe7daf 100644 --- a/tests/unit/globals_test.ts +++ b/tests/unit/globals_test.ts @@ -1,7 +1,12 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // deno-lint-ignore-file no-window-prefix no-window -import { assert, assertEquals, assertRejects } from "./test_util.ts"; +import { + assert, + assertEquals, + assertRejects, + assertThrows, +} from "./test_util.ts"; Deno.test(function globalThisExists() { assert(globalThis != null); @@ -224,3 +229,10 @@ Deno.test(function mapGroupBy() { quantity: 5, }]); }); + +Deno.test(function nodeGlobalsRaise() { + assertThrows(() => { + // @ts-ignore yes that's the point + Buffer; + }, ReferenceError); +}); -- cgit v1.2.3