| 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 #define COUNTER_NAME "hurz" | |
| 38 | |
| 39 static int* LookupCounter(const char* name) { | |
| 40 static int counter = 1234; | |
| 41 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; | |
| 42 } | |
| 43 | |
| 44 | |
| 45 TEST(IncrementStatsCounter) { | |
| 46 FLAG_native_code_counters = true; | |
| 47 reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce()) | |
| 48 ->SetCounterFunction(LookupCounter); | |
| 49 FunctionTester T( | |
| 50 "(function() { %_IncrementStatsCounter('" COUNTER_NAME "'); })", flags); | |
| 51 StatsCounter counter(T.main_isolate(), COUNTER_NAME); | |
| 52 if (!counter.Enabled()) return; | |
| 53 | |
| 54 int old_value = *counter.GetInternalPointer(); | |
| 55 T.CheckCall(T.undefined()); | |
| 56 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); | |
| 57 } | |
| 58 | |
| 59 #undef COUNTER_NAME | |
| 60 | |
| 61 | |
| 62 TEST(IsArray) { | 37 TEST(IsArray) { |
| 63 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); | 38 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); |
| 64 | 39 |
| 65 T.CheckFalse(T.NewObject("new Date()")); | 40 T.CheckFalse(T.NewObject("new Date()")); |
| 66 T.CheckFalse(T.NewObject("(function() {})")); | 41 T.CheckFalse(T.NewObject("(function() {})")); |
| 67 T.CheckTrue(T.NewObject("([1])")); | 42 T.CheckTrue(T.NewObject("([1])")); |
| 68 T.CheckFalse(T.NewObject("({})")); | 43 T.CheckFalse(T.NewObject("({})")); |
| 69 T.CheckFalse(T.NewObject("(/x/)")); | 44 T.CheckFalse(T.NewObject("(/x/)")); |
| 70 T.CheckFalse(T.undefined()); | 45 T.CheckFalse(T.undefined()); |
| 71 T.CheckFalse(T.null()); | 46 T.CheckFalse(T.null()); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 233 |
| 259 T.CheckCall(T.Val("a"), T.Val("a")); | 234 T.CheckCall(T.Val("a"), T.Val("a")); |
| 260 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); | 235 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
| 261 T.CheckCall(T.Val(123), T.Val(123)); | 236 T.CheckCall(T.Val(123), T.Val(123)); |
| 262 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); | 237 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
| 263 } | 238 } |
| 264 | 239 |
| 265 } // namespace compiler | 240 } // namespace compiler |
| 266 } // namespace internal | 241 } // namespace internal |
| 267 } // namespace v8 | 242 } // namespace v8 |
| OLD | NEW |