Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1770)

Unified Diff: test/unittests/object-unittest.cc

Issue 2578573002: Add unittests to keep InstanceType lists in sync (Closed)
Patch Set: fix merge artifacts Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/heap/heap-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/object-unittest.cc
diff --git a/test/unittests/object-unittest.cc b/test/unittests/object-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b09b97dea6991f2ee23651bd58d2a20137982798
--- /dev/null
+++ b/test/unittests/object-unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2016 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 <cmath>
+#include <iostream>
+#include <limits>
+
+#include "src/objects-inl.h"
+#include "src/objects.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+TEST(Object, InstanceTypeListOrder) {
+ int current = 0;
+ int last = -1;
+ InstanceType current_type = static_cast<InstanceType>(current);
+ EXPECT_EQ(current_type, InstanceType::FIRST_TYPE);
+ EXPECT_EQ(current_type, InstanceType::INTERNALIZED_STRING_TYPE);
+#define TEST_INSTANCE_TYPE(type) \
+ current_type = InstanceType::type; \
+ current = static_cast<int>(current_type); \
+ if (current > static_cast<int>(LAST_NAME_TYPE)) { \
+ EXPECT_EQ(last + 1, current); \
+ } \
+ EXPECT_LT(last, current) << " INSTANCE_TYPE_LIST is not ordered: " \
+ << "last = " << static_cast<InstanceType>(last) \
+ << " vs. current = " << current_type; \
+ last = current;
+
+ INSTANCE_TYPE_LIST(TEST_INSTANCE_TYPE)
+#undef TEST_INSTANCE_TYPE
+}
+
+TEST(Object, StructListOrder) {
+ int current = static_cast<int>(InstanceType::ACCESSOR_INFO_TYPE);
+ int last = current - 1;
+ ASSERT_LT(0, last);
+ InstanceType current_type = static_cast<InstanceType>(current);
+#define TEST_STRUCT(type, class, name) \
+ current_type = InstanceType::type##_TYPE; \
+ current = static_cast<int>(current_type); \
+ EXPECT_EQ(last + 1, current) \
+ << " STRUCT_LIST is not ordered: " \
+ << " last = " << static_cast<InstanceType>(last) \
+ << " vs. current = " << current_type; \
+ last = current;
+
+ STRUCT_LIST(TEST_STRUCT)
+#undef TEST_STRUCT
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/unittests/heap/heap-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698