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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « test/unittests/heap/heap-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <cmath>
6 #include <iostream>
7 #include <limits>
8
9 #include "src/objects-inl.h"
10 #include "src/objects.h"
11
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace v8 {
15 namespace internal {
16
17 TEST(Object, InstanceTypeListOrder) {
18 int current = 0;
19 int last = -1;
20 InstanceType current_type = static_cast<InstanceType>(current);
21 EXPECT_EQ(current_type, InstanceType::FIRST_TYPE);
22 EXPECT_EQ(current_type, InstanceType::INTERNALIZED_STRING_TYPE);
23 #define TEST_INSTANCE_TYPE(type) \
24 current_type = InstanceType::type; \
25 current = static_cast<int>(current_type); \
26 if (current > static_cast<int>(LAST_NAME_TYPE)) { \
27 EXPECT_EQ(last + 1, current); \
28 } \
29 EXPECT_LT(last, current) << " INSTANCE_TYPE_LIST is not ordered: " \
30 << "last = " << static_cast<InstanceType>(last) \
31 << " vs. current = " << current_type; \
32 last = current;
33
34 INSTANCE_TYPE_LIST(TEST_INSTANCE_TYPE)
35 #undef TEST_INSTANCE_TYPE
36 }
37
38 TEST(Object, StructListOrder) {
39 int current = static_cast<int>(InstanceType::ACCESSOR_INFO_TYPE);
40 int last = current - 1;
41 ASSERT_LT(0, last);
42 InstanceType current_type = static_cast<InstanceType>(current);
43 #define TEST_STRUCT(type, class, name) \
44 current_type = InstanceType::type##_TYPE; \
45 current = static_cast<int>(current_type); \
46 EXPECT_EQ(last + 1, current) \
47 << " STRUCT_LIST is not ordered: " \
48 << " last = " << static_cast<InstanceType>(last) \
49 << " vs. current = " << current_type; \
50 last = current;
51
52 STRUCT_LIST(TEST_STRUCT)
53 #undef TEST_STRUCT
54 }
55
56 } // namespace internal
57 } // namespace v8
OLDNEW
« 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