v8/test/cctest/compiler/test-run-jsobjects.cc
Camillo Bruni 22afaacd47 [keys] Handle RangeError in GetKeysWithPrototypeInfoCache
Drive-by-fix: Add V8_WARN_UNUSED_RESULT to MaybeHandle::ToHandle

Bug: chromium:1057653
Change-Id: I2834806ca498a2fa43a64f5391606cdbfb4af4fa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2084814
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66582}
2020-03-04 13:38:10 +00:00

58 lines
1.9 KiB
C++

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/execution/isolate.h"
#include "src/heap/factory.h"
#include "src/objects/objects-inl.h"
#include "test/cctest/compiler/function-tester.h"
namespace v8 {
namespace internal {
namespace compiler {
TEST(ArgumentsMapped) {
FunctionTester T("(function(a) { return arguments; })");
Handle<Object> arguments =
T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandleChecked();
CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
CHECK(JSObject::cast(*arguments).HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
Handle<Object> length =
Object::GetProperty(T.isolate, arguments, l).ToHandleChecked();
CHECK_EQ(4, length->Number());
}
TEST(ArgumentsUnmapped) {
FunctionTester T("(function(a) { 'use strict'; return arguments; })");
Handle<Object> arguments =
T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandleChecked();
CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
CHECK(!JSObject::cast(*arguments).HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
Handle<Object> length =
Object::GetProperty(T.isolate, arguments, l).ToHandleChecked();
CHECK_EQ(4, length->Number());
}
TEST(ArgumentsRest) {
FunctionTester T("(function(a, ...args) { return args; })");
Handle<Object> arguments =
T.Call(T.Val(19), T.Val(23), T.Val(42), T.Val(65)).ToHandleChecked();
CHECK(arguments->IsJSObject() && arguments->IsJSArray());
CHECK(!JSObject::cast(*arguments).HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
Handle<Object> length =
Object::GetProperty(T.isolate, arguments, l).ToHandleChecked();
CHECK_EQ(3, length->Number());
}
} // namespace compiler
} // namespace internal
} // namespace v8