| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/interpreter/interpreter-intrinsics.h" | 7 #include "src/interpreter/interpreter-intrinsics.h" |
| 8 #include "test/cctest/interpreter/interpreter-tester.h" | 8 #include "test/cctest/interpreter/interpreter-tester.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 InvokeIntrinsicHelper sub_string_helper(isolate, handles.main_zone(), | 219 InvokeIntrinsicHelper sub_string_helper(isolate, handles.main_zone(), |
| 220 Runtime::kInlineSubString); | 220 Runtime::kInlineSubString); |
| 221 CHECK(sub_string_helper | 221 CHECK(sub_string_helper |
| 222 .Invoke(sub_string_helper.NewObject("'foobar'"), | 222 .Invoke(sub_string_helper.NewObject("'foobar'"), |
| 223 sub_string_helper.NewObject("3"), | 223 sub_string_helper.NewObject("3"), |
| 224 sub_string_helper.NewObject("6")) | 224 sub_string_helper.NewObject("6")) |
| 225 ->SameValue(*sub_string_helper.NewObject("'bar'"))); | 225 ->SameValue(*sub_string_helper.NewObject("'bar'"))); |
| 226 } | 226 } |
| 227 | 227 |
| 228 TEST(ValueOf) { | |
| 229 HandleAndZoneScope handles; | |
| 230 Isolate* isolate = handles.main_isolate(); | |
| 231 Factory* factory = isolate->factory(); | |
| 232 InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(), | |
| 233 Runtime::kInlineValueOf); | |
| 234 | |
| 235 CHECK_EQ(Smi::FromInt(1234), *helper.Invoke(helper.NewObject("1234"))); | |
| 236 CHECK_EQ(Smi::FromInt(5678), | |
| 237 *helper.Invoke(helper.NewObject("new Object(5678)"))); | |
| 238 | |
| 239 CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("true"))); | |
| 240 CHECK_EQ(*factory->false_value(), | |
| 241 *helper.Invoke(helper.NewObject("new Object(false)"))); | |
| 242 | |
| 243 CHECK(helper.Invoke(helper.NewObject("'foobar'")) | |
| 244 ->SameValue(*helper.NewObject("'foobar'"))); | |
| 245 CHECK(helper.Invoke(helper.NewObject("new Object('foobar')")) | |
| 246 ->SameValue(*helper.NewObject("'foobar'"))); | |
| 247 } | |
| 248 | |
| 249 TEST(ClassOf) { | 228 TEST(ClassOf) { |
| 250 HandleAndZoneScope handles; | 229 HandleAndZoneScope handles; |
| 251 Isolate* isolate = handles.main_isolate(); | 230 Isolate* isolate = handles.main_isolate(); |
| 252 Factory* factory = isolate->factory(); | 231 Factory* factory = isolate->factory(); |
| 253 InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(), | 232 InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(), |
| 254 Runtime::kInlineClassOf); | 233 Runtime::kInlineClassOf); |
| 255 CHECK_EQ(*helper.Invoke(helper.NewObject("123")), *factory->null_value()); | 234 CHECK_EQ(*helper.Invoke(helper.NewObject("123")), *factory->null_value()); |
| 256 CHECK_EQ(*helper.Invoke(helper.NewObject("'true'")), *factory->null_value()); | 235 CHECK_EQ(*helper.Invoke(helper.NewObject("'true'")), *factory->null_value()); |
| 257 CHECK_EQ(*helper.Invoke(helper.NewObject("'foo'")), *factory->null_value()); | 236 CHECK_EQ(*helper.Invoke(helper.NewObject("'foo'")), *factory->null_value()); |
| 258 CHECK(helper.Invoke(helper.NewObject("({a:1})")) | 237 CHECK(helper.Invoke(helper.NewObject("({a:1})")) |
| 259 ->SameValue(*helper.NewObject("'Object'"))); | 238 ->SameValue(*helper.NewObject("'Object'"))); |
| 260 CHECK(helper.Invoke(helper.NewObject("(function foo() {})")) | 239 CHECK(helper.Invoke(helper.NewObject("(function foo() {})")) |
| 261 ->SameValue(*helper.NewObject("'Function'"))); | 240 ->SameValue(*helper.NewObject("'Function'"))); |
| 262 CHECK(helper.Invoke(helper.NewObject("new Date()")) | 241 CHECK(helper.Invoke(helper.NewObject("new Date()")) |
| 263 ->SameValue(*helper.NewObject("'Date'"))); | 242 ->SameValue(*helper.NewObject("'Date'"))); |
| 264 CHECK(helper.Invoke(helper.NewObject("new Set")) | 243 CHECK(helper.Invoke(helper.NewObject("new Set")) |
| 265 ->SameValue(*helper.NewObject("'Set'"))); | 244 ->SameValue(*helper.NewObject("'Set'"))); |
| 266 CHECK(helper.Invoke(helper.NewObject("/x/")) | 245 CHECK(helper.Invoke(helper.NewObject("/x/")) |
| 267 ->SameValue(*helper.NewObject("'RegExp'"))); | 246 ->SameValue(*helper.NewObject("'RegExp'"))); |
| 268 } | 247 } |
| 269 | 248 |
| 270 } // namespace interpreter | 249 } // namespace interpreter |
| 271 } // namespace internal | 250 } // namespace internal |
| 272 } // namespace v8 | 251 } // namespace v8 |
| OLD | NEW |