LCOV - code coverage report
Current view: top level - test/cctest/compiler - test-run-jsobjects.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 28 28 100.0 %
Date: 2019-01-20 Functions: 5 5 100.0 %

          Line data    Source code
       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
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/heap/factory.h"
       6             : #include "src/isolate.h"
       7             : #include "src/objects-inl.h"
       8             : #include "test/cctest/compiler/function-tester.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : namespace compiler {
      13             : 
      14       28342 : TEST(ArgumentsMapped) {
      15           5 :   FunctionTester T("(function(a) { return arguments; })");
      16             : 
      17             :   Handle<Object> arguments;
      18          10 :   T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandle(&arguments);
      19          20 :   CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
      20          10 :   CHECK(JSObject::cast(*arguments)->HasSloppyArgumentsElements());
      21           5 :   Handle<String> l = T.isolate->factory()->length_string();
      22             :   Handle<Object> length =
      23          10 :       Object::GetProperty(T.isolate, arguments, l).ToHandleChecked();
      24           5 :   CHECK_EQ(4, length->Number());
      25           5 : }
      26             : 
      27             : 
      28       28342 : TEST(ArgumentsUnmapped) {
      29           5 :   FunctionTester T("(function(a) { 'use strict'; return arguments; })");
      30             : 
      31             :   Handle<Object> arguments;
      32          10 :   T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandle(&arguments);
      33          20 :   CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
      34          10 :   CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
      35           5 :   Handle<String> l = T.isolate->factory()->length_string();
      36             :   Handle<Object> length =
      37          10 :       Object::GetProperty(T.isolate, arguments, l).ToHandleChecked();
      38           5 :   CHECK_EQ(4, length->Number());
      39           5 : }
      40             : 
      41             : 
      42       28342 : TEST(ArgumentsRest) {
      43           5 :   FunctionTester T("(function(a, ...args) { return args; })");
      44             : 
      45             :   Handle<Object> arguments;
      46          10 :   T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandle(&arguments);
      47          20 :   CHECK(arguments->IsJSObject() && arguments->IsJSArray());
      48          10 :   CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
      49           5 :   Handle<String> l = T.isolate->factory()->length_string();
      50             :   Handle<Object> length =
      51          10 :       Object::GetProperty(T.isolate, arguments, l).ToHandleChecked();
      52           5 :   CHECK_EQ(3, length->Number());
      53           5 : }
      54             : 
      55             : }  // namespace compiler
      56             : }  // namespace internal
      57       85011 : }  // namespace v8

Generated by: LCOV version 1.10