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 // TODO(rmcilroy): Remove this define after this flag is turned on globally | 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 2881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2892 i::Factory* factory = isolate->factory(); | 2892 i::Factory* factory = isolate->factory(); |
2893 | 2893 |
2894 InterpreterTester tester(handles.main_isolate(), | 2894 InterpreterTester tester(handles.main_isolate(), |
2895 "var f;\n f = function f() { return f.name; }"); | 2895 "var f;\n f = function f() { return f.name; }"); |
2896 auto callable = tester.GetCallable<>(); | 2896 auto callable = tester.GetCallable<>(); |
2897 | 2897 |
2898 Handle<i::Object> return_value = callable().ToHandleChecked(); | 2898 Handle<i::Object> return_value = callable().ToHandleChecked(); |
2899 CHECK(return_value->SameValue(*factory->NewStringFromStaticChars("f"))); | 2899 CHECK(return_value->SameValue(*factory->NewStringFromStaticChars("f"))); |
2900 } | 2900 } |
2901 | 2901 |
| 2902 |
| 2903 TEST(InterpreterNewTarget) { |
| 2904 HandleAndZoneScope handles; |
| 2905 i::Isolate* isolate = handles.main_isolate(); |
| 2906 i::Factory* factory = isolate->factory(); |
| 2907 |
| 2908 // TODO(rmcilroy): Add tests that we get the original constructor for |
| 2909 // superclass constructors once we have class support. |
| 2910 InterpreterTester tester(handles.main_isolate(), |
| 2911 "function f() { this.a = new.target; }"); |
| 2912 auto callable = tester.GetCallable<>(); |
| 2913 callable().ToHandleChecked(); |
| 2914 |
| 2915 Handle<Object> new_target_name = v8::Utils::OpenHandle( |
| 2916 *CompileRun("(function() { return (new f()).a.name; })();")); |
| 2917 CHECK(new_target_name->SameValue(*factory->NewStringFromStaticChars("f"))); |
| 2918 } |
| 2919 |
2902 } // namespace interpreter | 2920 } // namespace interpreter |
2903 } // namespace internal | 2921 } // namespace internal |
2904 } // namespace v8 | 2922 } // namespace v8 |
OLD | NEW |