diff options
author | 2023-06-20 19:06:58 -0700 | |
---|---|---|
committer | 2023-06-20 19:06:58 -0700 | |
commit | 50064352346f48da74f66caca9d30b81a77c89b9 (patch) | |
tree | be2738fbad1b0d0208daa18cb40d247b41c4d0dd /src/bun.js/bindings/ZigGlobalObject.cpp | |
parent | adb451eec6b8286a4ee18b16b5b87644d5ef3020 (diff) | |
download | bun-50064352346f48da74f66caca9d30b81a77c89b9.tar.gz bun-50064352346f48da74f66caca9d30b81a77c89b9.tar.zst bun-50064352346f48da74f66caca9d30b81a77c89b9.zip |
enable asymmetric matchers in `expect.toEqual`, `expect.toStrictEqual`, and `expect.toHaveProperty` (#3367)
* add asymmetric matchers to `deepEquals`
* fix comparison of a few jstypes
* clean up and tests
* fix merge
* improve `expect.any` for primitives
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 9b3bfd2a2..5589d2add 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -2077,11 +2077,11 @@ JSC_DEFINE_HOST_FUNCTION(functionBunDeepEquals, (JSGlobalObject * globalObject, Vector<std::pair<JSValue, JSValue>, 16> stack; if (arg3.isBoolean() && arg3.asBoolean()) { - bool isEqual = Bun__deepEquals<true>(globalObject, arg1, arg2, stack, &scope, true); + bool isEqual = Bun__deepEquals<true, false>(globalObject, arg1, arg2, stack, &scope, true); RETURN_IF_EXCEPTION(scope, {}); return JSValue::encode(jsBoolean(isEqual)); } else { - bool isEqual = Bun__deepEquals<false>(globalObject, arg1, arg2, stack, &scope, true); + bool isEqual = Bun__deepEquals<false, false>(globalObject, arg1, arg2, stack, &scope, true); RETURN_IF_EXCEPTION(scope, {}); return JSValue::encode(jsBoolean(isEqual)); } @@ -2107,13 +2107,13 @@ JSC_DEFINE_HOST_FUNCTION(functionBunDeepMatch, (JSGlobalObject * globalObject, J if (!subset.isObject() || !object.isObject()) { auto throwScope = DECLARE_THROW_SCOPE(vm); - throwTypeError(globalObject, throwScope, "Expected 2 object to match"_s); + throwTypeError(globalObject, throwScope, "Expected 2 objects to match"_s); return JSValue::encode(jsUndefined()); } - bool isEqual = Bun__deepMatch(object, subset, globalObject, &scope, false); + bool match = Bun__deepMatch<false>(object, subset, globalObject, &scope, false); RETURN_IF_EXCEPTION(scope, {}); - return JSValue::encode(jsBoolean(isEqual)); + return JSValue::encode(jsBoolean(match)); } JSC_DECLARE_HOST_FUNCTION(functionBunNanoseconds); |