Commit 57cd8c85 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[API] Test more structs for copyability

It's difficult to say which structs might in the future have deprecated
fields, so this CL adds tests for two more for now.
Once we add deprecated fields, we then need to define copy/move
constructs and assignment operators via
{ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS} (same as for other structs
which are not tested yet).

R=mlippautz@chromium.org

Bug: v8:13092
Change-Id: I89a330661a02d86d3d48e216b69cb6f77f02cff2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3789508Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82098}
parent ba7d9e5f
......@@ -29492,21 +29492,34 @@ TEST(EmbedderInstanceTypes) {
CHECK_EQ(1, res->ToInt32(env.local()).ToLocalChecked()->Value());
}
UNINITIALIZED_TEST(IsolateCreateParamsIsMovableAndCopyable) {
template <typename T>
void TestCopyAndMoveConstructionAndAssignment() {
// A struct with deprecated fields will trigger a deprecation warning when
// using the copy or move constructor (without special care), see
// https://crbug.com/v8/13092.
// Test that we can use the move- and copy constructor of
// Isolate::CreateParams.
v8::Isolate::CreateParams params;
T orig;
// Use move constructor.
v8::Isolate::CreateParams params2{std::move(params)};
T moved{std::move(orig)};
// Use copy constructor.
v8::Isolate::CreateParams params3{params2};
T copied{moved};
// Use move assignment.
params = std::move(params2);
orig = std::move(moved);
// Use copy assignment.
params = params2;
orig = copied;
}
UNINITIALIZED_TEST(IsolateCreateParamsIsMovableAndCopyable) {
// Test that we can use the move- and copy constructor of
// Isolate::CreateParams.
TestCopyAndMoveConstructionAndAssignment<v8::Isolate::CreateParams>();
}
UNINITIALIZED_TEST(OOMDetailsAreMovableAndCopyable) {
TestCopyAndMoveConstructionAndAssignment<v8::OOMDetails>();
}
UNINITIALIZED_TEST(JitCodeEventIsMovableAndCopyable) {
TestCopyAndMoveConstructionAndAssignment<v8::JitCodeEvent>();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment