OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/cctest/compiler/function-tester.h" | 5 #include "test/cctest/compiler/function-tester.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 T.CheckCall(T.Val("Array"), T.NewObject("([1])")); | 27 T.CheckCall(T.Val("Array"), T.NewObject("([1])")); |
28 T.CheckCall(T.Val("Object"), T.NewObject("({})")); | 28 T.CheckCall(T.Val("Object"), T.NewObject("({})")); |
29 T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)")); | 29 T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)")); |
30 T.CheckCall(T.null(), T.undefined()); | 30 T.CheckCall(T.null(), T.undefined()); |
31 T.CheckCall(T.null(), T.null()); | 31 T.CheckCall(T.null(), T.null()); |
32 T.CheckCall(T.null(), T.Val("x")); | 32 T.CheckCall(T.null(), T.Val("x")); |
33 T.CheckCall(T.null(), T.Val(1)); | 33 T.CheckCall(T.null(), T.Val(1)); |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 TEST(HeapObjectGetMap) { | |
38 FunctionTester T("(function(a) { return %_HeapObjectGetMap(a); })", flags); | |
39 | |
40 Factory* factory = T.main_isolate()->factory(); | |
41 T.CheckCall(factory->null_map(), T.null()); | |
42 T.CheckCall(factory->undefined_map(), T.undefined()); | |
43 T.CheckCall(factory->heap_number_map(), T.Val(3.1415)); | |
44 T.CheckCall(factory->symbol_map(), factory->NewSymbol()); | |
45 } | |
46 | |
47 | |
48 #define COUNTER_NAME "hurz" | 37 #define COUNTER_NAME "hurz" |
49 | 38 |
50 static int* LookupCounter(const char* name) { | 39 static int* LookupCounter(const char* name) { |
51 static int counter = 1234; | 40 static int counter = 1234; |
52 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; | 41 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; |
53 } | 42 } |
54 | 43 |
55 | 44 |
56 TEST(IncrementStatsCounter) { | 45 TEST(IncrementStatsCounter) { |
57 FLAG_native_code_counters = true; | 46 FLAG_native_code_counters = true; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 T.CheckFalse(T.NewObject("(/x/)")); | 141 T.CheckFalse(T.NewObject("(/x/)")); |
153 T.CheckFalse(T.undefined()); | 142 T.CheckFalse(T.undefined()); |
154 T.CheckTrue(T.Val(1)); | 143 T.CheckTrue(T.Val(1)); |
155 T.CheckFalse(T.Val(1.1)); | 144 T.CheckFalse(T.Val(1.1)); |
156 T.CheckFalse(T.Val(-0.0)); | 145 T.CheckFalse(T.Val(-0.0)); |
157 T.CheckTrue(T.Val(-2)); | 146 T.CheckTrue(T.Val(-2)); |
158 T.CheckFalse(T.Val(-2.3)); | 147 T.CheckFalse(T.Val(-2.3)); |
159 } | 148 } |
160 | 149 |
161 | 150 |
162 TEST(MapGetInstanceType) { | |
163 FunctionTester T( | |
164 "(function(a) { return %_MapGetInstanceType(%_HeapObjectGetMap(a)); })", | |
165 flags); | |
166 | |
167 Factory* factory = T.main_isolate()->factory(); | |
168 T.CheckCall(T.Val(ODDBALL_TYPE), T.null()); | |
169 T.CheckCall(T.Val(ODDBALL_TYPE), T.undefined()); | |
170 T.CheckCall(T.Val(HEAP_NUMBER_TYPE), T.Val(3.1415)); | |
171 T.CheckCall(T.Val(SYMBOL_TYPE), factory->NewSymbol()); | |
172 } | |
173 | |
174 | |
175 TEST(ObjectEquals) { | 151 TEST(ObjectEquals) { |
176 FunctionTester T("(function(a,b) { return %_ObjectEquals(a,b); })", flags); | 152 FunctionTester T("(function(a,b) { return %_ObjectEquals(a,b); })", flags); |
177 CompileRun("var o = {}"); | 153 CompileRun("var o = {}"); |
178 | 154 |
179 T.CheckTrue(T.NewObject("(o)"), T.NewObject("(o)")); | 155 T.CheckTrue(T.NewObject("(o)"), T.NewObject("(o)")); |
180 T.CheckTrue(T.Val("internal"), T.Val("internal")); | 156 T.CheckTrue(T.Val("internal"), T.Val("internal")); |
181 T.CheckTrue(T.true_value(), T.true_value()); | 157 T.CheckTrue(T.true_value(), T.true_value()); |
182 T.CheckFalse(T.true_value(), T.false_value()); | 158 T.CheckFalse(T.true_value(), T.false_value()); |
183 T.CheckFalse(T.NewObject("({})"), T.NewObject("({})")); | 159 T.CheckFalse(T.NewObject("({})"), T.NewObject("({})")); |
184 T.CheckFalse(T.Val("a"), T.Val("b")); | 160 T.CheckFalse(T.Val("a"), T.Val("b")); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 292 |
317 T.CheckCall(T.Val("a"), T.Val("a")); | 293 T.CheckCall(T.Val("a"), T.Val("a")); |
318 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); | 294 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
319 T.CheckCall(T.Val(123), T.Val(123)); | 295 T.CheckCall(T.Val(123), T.Val(123)); |
320 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); | 296 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
321 } | 297 } |
322 | 298 |
323 } // namespace compiler | 299 } // namespace compiler |
324 } // namespace internal | 300 } // namespace internal |
325 } // namespace v8 | 301 } // namespace v8 |
OLD | NEW |