chromium/v8/test/cctest/test-property-details.cc

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <limits>

#include "src/objects/property-details.h"
#include "test/cctest/cctest.h"

namespace v8 {
namespace internal {

namespace {

std::vector<PropertyDetails> make_details() {}

}  // namespace

#ifndef DEBUG
// This test will trigger a DCHECK failure in debug mode. We must ensure that in
// release mode, the enum index doesn't interfere with other fields once it
// becomes too large.
TEST(ExceedMaxEnumerationIndex) {
  int too_large_enum_index = std::numeric_limits<int>::max();

  for (PropertyDetails d : make_details()) {
    PropertyDetails copy(d);

    d = d.set_index(too_large_enum_index);
    CHECK_EQ(copy.kind(), d.kind());
    CHECK_EQ(copy.location(), d.location());
    CHECK_EQ(copy.attributes(), d.attributes());
    CHECK_EQ(copy.cell_type(), d.cell_type());
    CHECK_EQ(PropertyDetails::DictionaryStorageField::kMax,
             d.dictionary_index());
  }
}
#endif

TEST(AsByte) {}

}  // namespace internal
}  // namespace v8