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: 2017-10-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/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       23724 : TEST(ArgumentsMapped) {
      15           6 :   FunctionTester T("(function(a) { return arguments; })");
      16             : 
      17             :   Handle<Object> arguments;
      18          12 :   T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandle(&arguments);
      19          12 :   CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
      20           6 :   CHECK(JSObject::cast(*arguments)->HasSloppyArgumentsElements());
      21           6 :   Handle<String> l = T.isolate->factory()->length_string();
      22          12 :   Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
      23           6 :   CHECK_EQ(4, length->Number());
      24           6 : }
      25             : 
      26             : 
      27       23724 : TEST(ArgumentsUnmapped) {
      28           6 :   FunctionTester T("(function(a) { 'use strict'; return arguments; })");
      29             : 
      30             :   Handle<Object> arguments;
      31          12 :   T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandle(&arguments);
      32          12 :   CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
      33           6 :   CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
      34           6 :   Handle<String> l = T.isolate->factory()->length_string();
      35          12 :   Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
      36           6 :   CHECK_EQ(4, length->Number());
      37           6 : }
      38             : 
      39             : 
      40       23724 : TEST(ArgumentsRest) {
      41           6 :   FunctionTester T("(function(a, ...args) { return args; })");
      42             : 
      43             :   Handle<Object> arguments;
      44          12 :   T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandle(&arguments);
      45          12 :   CHECK(arguments->IsJSObject() && arguments->IsJSArray());
      46           6 :   CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
      47           6 :   Handle<String> l = T.isolate->factory()->length_string();
      48          12 :   Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
      49           6 :   CHECK_EQ(3, length->Number());
      50           6 : }
      51             : 
      52             : }  // namespace compiler
      53             : }  // namespace internal
      54       71154 : }  // namespace v8

Generated by: LCOV version 1.10