zjsunit: Remove _patched_with_set_global check.

Most of our set_global usage will disappear as our globals do, anyway.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-02-24 14:01:21 -08:00
committed by Tim Abbott
parent db50451a5a
commit aee94f141d

View File

@@ -12,12 +12,6 @@ exports.set_global = function (name, val) {
`);
}
// Add this for debugging and to allow with_overrides
// to know that we're dealing with stubbed code.
if (typeof val === "object") {
val._patched_with_set_global = true;
}
if (!(name in old_globals)) {
if (!(name in global)) {
new_globals.add(name);
@@ -116,16 +110,7 @@ exports.with_overrides = function (test_function) {
throw new TypeError(`We cannot override a function for ${typeof obj} objects`);
}
if (obj[func_name] === undefined) {
if (obj !== global.$ && !obj._patched_with_set_global) {
throw new Error(`
It looks like you are overriding ${func_name}
for a module that never defined it, which probably
indicates that you have a typo or are doing
something hacky in the test.
`);
}
} else if (typeof obj[func_name] !== "function") {
if (obj[func_name] !== undefined && typeof obj[func_name] !== "function") {
throw new TypeError(`
You are overriding a non-function with a function.
This is almost certainly an error.