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

Generated by: LCOV version 1.10