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/execution.h" | 7 #include "src/execution.h" |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2290 std::make_pair("function f(a, b, c, d) {" | 2290 std::make_pair("function f(a, b, c, d) {" |
2291 "'use strict'; return arguments[2]; }", | 2291 "'use strict'; return arguments[2]; }", |
2292 2), | 2292 2), |
2293 // Check arguments are mapped in sloppy mode and unmapped in strict. | 2293 // Check arguments are mapped in sloppy mode and unmapped in strict. |
2294 std::make_pair("function f(a, b, c, d) {" | 2294 std::make_pair("function f(a, b, c, d) {" |
2295 " c = b; return arguments[2]; }", | 2295 " c = b; return arguments[2]; }", |
2296 1), | 2296 1), |
2297 std::make_pair("function f(a, b, c, d) {" | 2297 std::make_pair("function f(a, b, c, d) {" |
2298 " 'use strict'; c = b; return arguments[2]; }", | 2298 " 'use strict'; c = b; return arguments[2]; }", |
2299 2), | 2299 2), |
| 2300 // check rest parameters |
| 2301 std::make_pair("function f(...restArray) { return restArray[0]; }", 0), |
| 2302 std::make_pair("function f(a, ...restArray) { return restArray[0]; }", 1), |
| 2303 std::make_pair("function f(a, ...restArray) { return arguments[0]; }", 0), |
| 2304 std::make_pair("function f(a, ...restArray) { return arguments[1]; }", 1), |
| 2305 std::make_pair("function f(a, ...restArray) { return restArray[1]; }", 2), |
| 2306 std::make_pair("function f(a, ...arguments) { return arguments[0]; }", 1), |
| 2307 std::make_pair("function f(a, b, ...restArray) { return restArray[0]; }", |
| 2308 2), |
2300 }; | 2309 }; |
2301 | 2310 |
2302 // Test passing no arguments. | 2311 // Test passing no arguments. |
2303 for (size_t i = 0; i < arraysize(create_args); i++) { | 2312 for (size_t i = 0; i < arraysize(create_args); i++) { |
2304 InterpreterTester tester(handles.main_isolate(), create_args[i].first); | 2313 InterpreterTester tester(handles.main_isolate(), create_args[i].first); |
2305 auto callable = tester.GetCallable<>(); | 2314 auto callable = tester.GetCallable<>(); |
2306 Handle<Object> return_val = callable().ToHandleChecked(); | 2315 Handle<Object> return_val = callable().ToHandleChecked(); |
2307 CHECK(return_val.is_identical_to(factory->undefined_value())); | 2316 CHECK(return_val.is_identical_to(factory->undefined_value())); |
2308 } | 2317 } |
2309 | 2318 |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3830 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3839 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3831 CHECK(return_value->SameValue(*do_expr[i].second)); | 3840 CHECK(return_value->SameValue(*do_expr[i].second)); |
3832 } | 3841 } |
3833 | 3842 |
3834 FLAG_harmony_do_expressions = old_flag; | 3843 FLAG_harmony_do_expressions = old_flag; |
3835 } | 3844 } |
3836 | 3845 |
3837 } // namespace interpreter | 3846 } // namespace interpreter |
3838 } // namespace internal | 3847 } // namespace internal |
3839 } // namespace v8 | 3848 } // namespace v8 |
OLD | NEW |