Line data Source code
1 : // Copyright 2013 the V8 project authors. All rights reserved.
2 : // Redistribution and use in source and binary forms, with or without
3 : // modification, are permitted provided that the following conditions are
4 : // met:
5 : //
6 : // * Redistributions of source code must retain the above copyright
7 : // notice, this list of conditions and the following disclaimer.
8 : // * Redistributions in binary form must reproduce the above
9 : // copyright notice, this list of conditions and the following
10 : // disclaimer in the documentation and/or other materials provided
11 : // with the distribution.
12 : // * Neither the name of Google Inc. nor the names of its
13 : // contributors may be used to endorse or promote products derived
14 : // from this software without specific prior written permission.
15 : //
16 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 : // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 :
28 : #include "test/cctest/cctest.h"
29 :
30 : #include "src/property-details.h"
31 :
32 : namespace v8 {
33 : namespace internal {
34 :
35 210 : void TestPairPositive(Representation more_general,
36 : Representation less_general) {
37 210 : CHECK(more_general.is_more_general_than(less_general));
38 210 : }
39 :
40 :
41 228 : void TestPairNegative(Representation more_general,
42 : Representation less_general) {
43 228 : CHECK(!more_general.is_more_general_than(less_general));
44 228 : }
45 :
46 :
47 23724 : TEST(RepresentationMoreGeneralThan) {
48 6 : TestPairNegative(Representation::None(), Representation::None());
49 6 : TestPairPositive(Representation::Integer8(), Representation::None());
50 6 : TestPairPositive(Representation::UInteger8(), Representation::None());
51 6 : TestPairPositive(Representation::Integer16(), Representation::None());
52 6 : TestPairPositive(Representation::UInteger16(), Representation::None());
53 6 : TestPairPositive(Representation::Smi(), Representation::None());
54 6 : TestPairPositive(Representation::Integer32(), Representation::None());
55 6 : TestPairPositive(Representation::HeapObject(), Representation::None());
56 6 : TestPairPositive(Representation::Double(), Representation::None());
57 6 : TestPairPositive(Representation::Tagged(), Representation::None());
58 :
59 6 : TestPairNegative(Representation::None(), Representation::Integer8());
60 6 : TestPairNegative(Representation::Integer8(), Representation::Integer8());
61 6 : TestPairNegative(Representation::UInteger8(), Representation::Integer8());
62 6 : TestPairPositive(Representation::Integer16(), Representation::Integer8());
63 6 : TestPairPositive(Representation::UInteger16(), Representation::Integer8());
64 6 : TestPairPositive(Representation::Smi(), Representation::Integer8());
65 6 : TestPairPositive(Representation::Integer32(), Representation::Integer8());
66 6 : TestPairNegative(Representation::HeapObject(), Representation::Integer8());
67 6 : TestPairPositive(Representation::Double(), Representation::Integer8());
68 6 : TestPairPositive(Representation::Tagged(), Representation::Integer8());
69 :
70 6 : TestPairNegative(Representation::None(), Representation::UInteger8());
71 6 : TestPairNegative(Representation::Integer8(), Representation::UInteger8());
72 6 : TestPairNegative(Representation::UInteger8(), Representation::UInteger8());
73 6 : TestPairPositive(Representation::Integer16(), Representation::UInteger8());
74 6 : TestPairPositive(Representation::UInteger16(), Representation::UInteger8());
75 6 : TestPairPositive(Representation::Smi(), Representation::UInteger8());
76 6 : TestPairPositive(Representation::Integer32(), Representation::UInteger8());
77 6 : TestPairNegative(Representation::HeapObject(), Representation::UInteger8());
78 6 : TestPairPositive(Representation::Double(), Representation::UInteger8());
79 6 : TestPairPositive(Representation::Tagged(), Representation::UInteger8());
80 :
81 6 : TestPairNegative(Representation::None(), Representation::Integer16());
82 6 : TestPairNegative(Representation::Integer8(), Representation::Integer16());
83 6 : TestPairNegative(Representation::UInteger8(), Representation::Integer16());
84 6 : TestPairNegative(Representation::Integer16(), Representation::Integer16());
85 6 : TestPairNegative(Representation::UInteger16(), Representation::Integer16());
86 6 : TestPairPositive(Representation::Smi(), Representation::Integer16());
87 6 : TestPairPositive(Representation::Integer32(), Representation::Integer16());
88 6 : TestPairNegative(Representation::HeapObject(), Representation::Integer16());
89 6 : TestPairPositive(Representation::Double(), Representation::Integer16());
90 6 : TestPairPositive(Representation::Tagged(), Representation::Integer16());
91 :
92 6 : TestPairNegative(Representation::None(), Representation::UInteger16());
93 6 : TestPairNegative(Representation::Integer8(), Representation::UInteger16());
94 6 : TestPairNegative(Representation::UInteger8(), Representation::UInteger16());
95 6 : TestPairNegative(Representation::Integer16(), Representation::UInteger16());
96 6 : TestPairNegative(Representation::UInteger16(), Representation::UInteger16());
97 6 : TestPairPositive(Representation::Smi(), Representation::UInteger16());
98 6 : TestPairPositive(Representation::Integer32(), Representation::UInteger16());
99 6 : TestPairNegative(Representation::HeapObject(), Representation::UInteger16());
100 6 : TestPairPositive(Representation::Double(), Representation::UInteger16());
101 6 : TestPairPositive(Representation::Tagged(), Representation::UInteger16());
102 :
103 6 : TestPairNegative(Representation::None(), Representation::Smi());
104 6 : TestPairNegative(Representation::Integer8(), Representation::Smi());
105 6 : TestPairNegative(Representation::UInteger8(), Representation::Smi());
106 6 : TestPairNegative(Representation::Integer16(), Representation::Smi());
107 6 : TestPairNegative(Representation::UInteger16(), Representation::Smi());
108 6 : TestPairNegative(Representation::Smi(), Representation::Smi());
109 6 : TestPairPositive(Representation::Integer32(), Representation::Smi());
110 6 : TestPairNegative(Representation::HeapObject(), Representation::Smi());
111 6 : TestPairPositive(Representation::Double(), Representation::Smi());
112 6 : TestPairPositive(Representation::Tagged(), Representation::Smi());
113 :
114 6 : TestPairNegative(Representation::None(), Representation::Integer32());
115 6 : TestPairNegative(Representation::Integer8(), Representation::Integer32());
116 6 : TestPairNegative(Representation::UInteger8(), Representation::Integer32());
117 6 : TestPairNegative(Representation::Integer16(), Representation::Integer32());
118 6 : TestPairNegative(Representation::UInteger16(), Representation::Integer32());
119 6 : TestPairNegative(Representation::Smi(), Representation::Integer32());
120 6 : TestPairNegative(Representation::Integer32(), Representation::Integer32());
121 6 : TestPairNegative(Representation::HeapObject(), Representation::Integer32());
122 6 : TestPairPositive(Representation::Double(), Representation::Integer32());
123 6 : TestPairPositive(Representation::Tagged(), Representation::Integer32());
124 :
125 6 : TestPairNegative(Representation::None(), Representation::External());
126 6 : TestPairNegative(Representation::External(), Representation::External());
127 6 : TestPairPositive(Representation::External(), Representation::None());
128 6 : }
129 :
130 : } // namespace internal
131 71154 : } // namespace v8
|