-
-
Save caitp/59d1939d60d40906e8c0aa1ff61cca1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto CheckObjectEq = [&env]( | |
v8::Local<v8::Value> expected, v8::Local<v8::Value> actual, | |
const char* expected_str, const char* actual_str, int line) { | |
v8::String::Utf8Value details( | |
actual->ToDetailString(env.local()).ToLocalChecked()); | |
if (!actual->IsObject()) { | |
V8_Fatal(__FILE__, line, "Expected %s to be an Object, but found %s", | |
actual_str, *details); | |
} | |
if (actual != expected) { | |
v8::String::Utf8Value actual_json( | |
v8::JSON::Stringify(env.local(), v8::Local<v8::Object>::Cast(actual)) | |
.ToLocalChecked()); | |
v8::String::Utf8Value expected_json( | |
v8::JSON::Stringify(env.local(), | |
v8::Local<v8::Object>::Cast(expected)) | |
.ToLocalChecked()); | |
V8_Fatal(__FILE__, line, "%p != %p (Expected %s (%s) to be %s (%s))", | |
*actual, *expected, actual_str, *actual_json, expected_str, | |
*expected_json); | |
} | |
}; | |
#define CHECK_OBJ_EQ(expected, actual) \ | |
CheckObjectEq(expected, actual, #expected, #actual, __LINE__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment