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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 using namespace v8::internal; | 9 using namespace v8::internal; |
10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 T.CheckCall(T.undefined()); | 67 T.CheckCall(T.undefined()); |
68 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); | 68 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); |
69 } | 69 } |
70 | 70 |
71 #undef COUNTER_NAME | 71 #undef COUNTER_NAME |
72 | 72 |
73 | 73 |
74 TEST(IsArray) { | 74 TEST(IsArray) { |
75 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); | 75 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); |
76 | 76 |
| 77 T.CheckFalse(T.NewObject("new Date()")); |
77 T.CheckFalse(T.NewObject("(function() {})")); | 78 T.CheckFalse(T.NewObject("(function() {})")); |
78 T.CheckTrue(T.NewObject("([1])")); | 79 T.CheckTrue(T.NewObject("([1])")); |
79 T.CheckFalse(T.NewObject("({})")); | 80 T.CheckFalse(T.NewObject("({})")); |
80 T.CheckFalse(T.NewObject("(/x/)")); | 81 T.CheckFalse(T.NewObject("(/x/)")); |
81 T.CheckFalse(T.undefined()); | 82 T.CheckFalse(T.undefined()); |
82 T.CheckFalse(T.null()); | 83 T.CheckFalse(T.null()); |
83 T.CheckFalse(T.Val("x")); | 84 T.CheckFalse(T.Val("x")); |
84 T.CheckFalse(T.Val(1)); | 85 T.CheckFalse(T.Val(1)); |
85 } | 86 } |
86 | 87 |
87 | 88 |
| 89 TEST(IsDate) { |
| 90 FunctionTester T("(function(a) { return %_IsDate(a); })", flags); |
| 91 |
| 92 T.CheckTrue(T.NewObject("new Date()")); |
| 93 T.CheckFalse(T.NewObject("(function() {})")); |
| 94 T.CheckFalse(T.NewObject("([1])")); |
| 95 T.CheckFalse(T.NewObject("({})")); |
| 96 T.CheckFalse(T.NewObject("(/x/)")); |
| 97 T.CheckFalse(T.undefined()); |
| 98 T.CheckFalse(T.null()); |
| 99 T.CheckFalse(T.Val("x")); |
| 100 T.CheckFalse(T.Val(1)); |
| 101 } |
| 102 |
| 103 |
88 TEST(IsFunction) { | 104 TEST(IsFunction) { |
89 FunctionTester T("(function(a) { return %_IsFunction(a); })", flags); | 105 FunctionTester T("(function(a) { return %_IsFunction(a); })", flags); |
90 | 106 |
| 107 T.CheckFalse(T.NewObject("new Date()")); |
91 T.CheckTrue(T.NewObject("(function() {})")); | 108 T.CheckTrue(T.NewObject("(function() {})")); |
92 T.CheckFalse(T.NewObject("([1])")); | 109 T.CheckFalse(T.NewObject("([1])")); |
93 T.CheckFalse(T.NewObject("({})")); | 110 T.CheckFalse(T.NewObject("({})")); |
94 T.CheckFalse(T.NewObject("(/x/)")); | 111 T.CheckFalse(T.NewObject("(/x/)")); |
95 T.CheckFalse(T.undefined()); | 112 T.CheckFalse(T.undefined()); |
96 T.CheckFalse(T.null()); | 113 T.CheckFalse(T.null()); |
97 T.CheckFalse(T.Val("x")); | 114 T.CheckFalse(T.Val("x")); |
98 T.CheckFalse(T.Val(1)); | 115 T.CheckFalse(T.Val(1)); |
99 } | 116 } |
100 | 117 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 T.CheckFalse(T.undefined()); | 150 T.CheckFalse(T.undefined()); |
134 T.CheckTrue(T.null()); | 151 T.CheckTrue(T.null()); |
135 T.CheckFalse(T.Val("x")); | 152 T.CheckFalse(T.Val("x")); |
136 T.CheckFalse(T.Val(1)); | 153 T.CheckFalse(T.Val(1)); |
137 } | 154 } |
138 | 155 |
139 | 156 |
140 TEST(IsRegExp) { | 157 TEST(IsRegExp) { |
141 FunctionTester T("(function(a) { return %_IsRegExp(a); })", flags); | 158 FunctionTester T("(function(a) { return %_IsRegExp(a); })", flags); |
142 | 159 |
| 160 T.CheckFalse(T.NewObject("new Date()")); |
143 T.CheckFalse(T.NewObject("(function() {})")); | 161 T.CheckFalse(T.NewObject("(function() {})")); |
144 T.CheckFalse(T.NewObject("([1])")); | 162 T.CheckFalse(T.NewObject("([1])")); |
145 T.CheckFalse(T.NewObject("({})")); | 163 T.CheckFalse(T.NewObject("({})")); |
146 T.CheckTrue(T.NewObject("(/x/)")); | 164 T.CheckTrue(T.NewObject("(/x/)")); |
147 T.CheckFalse(T.undefined()); | 165 T.CheckFalse(T.undefined()); |
148 T.CheckFalse(T.null()); | 166 T.CheckFalse(T.null()); |
149 T.CheckFalse(T.Val("x")); | 167 T.CheckFalse(T.Val("x")); |
150 T.CheckFalse(T.Val(1)); | 168 T.CheckFalse(T.Val(1)); |
151 } | 169 } |
152 | 170 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 345 |
328 | 346 |
329 TEST(ValueOf) { | 347 TEST(ValueOf) { |
330 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); | 348 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); |
331 | 349 |
332 T.CheckCall(T.Val("a"), T.Val("a")); | 350 T.CheckCall(T.Val("a"), T.Val("a")); |
333 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); | 351 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
334 T.CheckCall(T.Val(123), T.Val(123)); | 352 T.CheckCall(T.Val(123), T.Val(123)); |
335 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); | 353 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
336 } | 354 } |
OLD | NEW |