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 175 : void TestPairPositive(Representation more_general,
36 : Representation less_general) {
37 175 : CHECK(more_general.is_more_general_than(less_general));
38 175 : }
39 :
40 :
41 190 : void TestPairNegative(Representation more_general,
42 : Representation less_general) {
43 190 : CHECK(!more_general.is_more_general_than(less_general));
44 190 : }
45 :
46 :
47 28342 : TEST(RepresentationMoreGeneralThan) {
48 5 : TestPairNegative(Representation::None(), Representation::None());
49 5 : TestPairPositive(Representation::Integer8(), Representation::None());
50 5 : TestPairPositive(Representation::UInteger8(), Representation::None());
51 5 : TestPairPositive(Representation::Integer16(), Representation::None());
52 5 : TestPairPositive(Representation::UInteger16(), Representation::None());
53 5 : TestPairPositive(Representation::Smi(), Representation::None());
54 5 : TestPairPositive(Representation::Integer32(), Representation::None());
55 5 : TestPairPositive(Representation::HeapObject(), Representation::None());
56 5 : TestPairPositive(Representation::Double(), Representation::None());
57 5 : TestPairPositive(Representation::Tagged(), Representation::None());
58 :
59 5 : TestPairNegative(Representation::None(), Representation::Integer8());
60 5 : TestPairNegative(Representation::Integer8(), Representation::Integer8());
61 5 : TestPairNegative(Representation::UInteger8(), Representation::Integer8());
62 5 : TestPairPositive(Representation::Integer16(), Representation::Integer8());
63 5 : TestPairPositive(Representation::UInteger16(), Representation::Integer8());
64 5 : TestPairPositive(Representation::Smi(), Representation::Integer8());
65 5 : TestPairPositive(Representation::Integer32(), Representation::Integer8());
66 5 : TestPairNegative(Representation::HeapObject(), Representation::Integer8());
67 5 : TestPairPositive(Representation::Double(), Representation::Integer8());
68 5 : TestPairPositive(Representation::Tagged(), Representation::Integer8());
69 :
70 5 : TestPairNegative(Representation::None(), Representation::UInteger8());
71 5 : TestPairNegative(Representation::Integer8(), Representation::UInteger8());
72 5 : TestPairNegative(Representation::UInteger8(), Representation::UInteger8());
73 5 : TestPairPositive(Representation::Integer16(), Representation::UInteger8());
74 5 : TestPairPositive(Representation::UInteger16(), Representation::UInteger8());
75 5 : TestPairPositive(Representation::Smi(), Representation::UInteger8());
76 5 : TestPairPositive(Representation::Integer32(), Representation::UInteger8());
77 5 : TestPairNegative(Representation::HeapObject(), Representation::UInteger8());
78 5 : TestPairPositive(Representation::Double(), Representation::UInteger8());
79 5 : TestPairPositive(Representation::Tagged(), Representation::UInteger8());
80 :
81 5 : TestPairNegative(Representation::None(), Representation::Integer16());
82 5 : TestPairNegative(Representation::Integer8(), Representation::Integer16());
83 5 : TestPairNegative(Representation::UInteger8(), Representation::Integer16());
84 5 : TestPairNegative(Representation::Integer16(), Representation::Integer16());
85 5 : TestPairNegative(Representation::UInteger16(), Representation::Integer16());
86 5 : TestPairPositive(Representation::Smi(), Representation::Integer16());
87 5 : TestPairPositive(Representation::Integer32(), Representation::Integer16());
88 5 : TestPairNegative(Representation::HeapObject(), Representation::Integer16());
89 5 : TestPairPositive(Representation::Double(), Representation::Integer16());
90 5 : TestPairPositive(Representation::Tagged(), Representation::Integer16());
91 :
92 5 : TestPairNegative(Representation::None(), Representation::UInteger16());
93 5 : TestPairNegative(Representation::Integer8(), Representation::UInteger16());
94 5 : TestPairNegative(Representation::UInteger8(), Representation::UInteger16());
95 5 : TestPairNegative(Representation::Integer16(), Representation::UInteger16());
96 5 : TestPairNegative(Representation::UInteger16(), Representation::UInteger16());
97 5 : TestPairPositive(Representation::Smi(), Representation::UInteger16());
98 5 : TestPairPositive(Representation::Integer32(), Representation::UInteger16());
99 5 : TestPairNegative(Representation::HeapObject(), Representation::UInteger16());
100 5 : TestPairPositive(Representation::Double(), Representation::UInteger16());
101 5 : TestPairPositive(Representation::Tagged(), Representation::UInteger16());
102 :
103 5 : TestPairNegative(Representation::None(), Representation::Smi());
104 5 : TestPairNegative(Representation::Integer8(), Representation::Smi());
105 5 : TestPairNegative(Representation::UInteger8(), Representation::Smi());
106 5 : TestPairNegative(Representation::Integer16(), Representation::Smi());
107 5 : TestPairNegative(Representation::UInteger16(), Representation::Smi());
108 5 : TestPairNegative(Representation::Smi(), Representation::Smi());
109 5 : TestPairPositive(Representation::Integer32(), Representation::Smi());
110 5 : TestPairNegative(Representation::HeapObject(), Representation::Smi());
111 5 : TestPairPositive(Representation::Double(), Representation::Smi());
112 5 : TestPairPositive(Representation::Tagged(), Representation::Smi());
113 :
114 5 : TestPairNegative(Representation::None(), Representation::Integer32());
115 5 : TestPairNegative(Representation::Integer8(), Representation::Integer32());
116 5 : TestPairNegative(Representation::UInteger8(), Representation::Integer32());
117 5 : TestPairNegative(Representation::Integer16(), Representation::Integer32());
118 5 : TestPairNegative(Representation::UInteger16(), Representation::Integer32());
119 5 : TestPairNegative(Representation::Smi(), Representation::Integer32());
120 5 : TestPairNegative(Representation::Integer32(), Representation::Integer32());
121 5 : TestPairNegative(Representation::HeapObject(), Representation::Integer32());
122 5 : TestPairPositive(Representation::Double(), Representation::Integer32());
123 5 : TestPairPositive(Representation::Tagged(), Representation::Integer32());
124 :
125 5 : TestPairNegative(Representation::None(), Representation::External());
126 5 : TestPairNegative(Representation::External(), Representation::External());
127 5 : TestPairPositive(Representation::External(), Representation::None());
128 5 : }
129 :
130 : } // namespace internal
131 85011 : } // namespace v8
|