v8/test/unittests/parser/preparser-unittest.cc
Zhi An Ng b8761260dc [cleanup] Remove DISALLOW_COPY_AND_ASSIGN in test/{common,unittests}
Bug: v8:11074
Change-Id: I7b34b6a647bf9ad317bdb97a344739302f892957
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2519184
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70997}
2020-11-06 06:07:54 +00:00

38 lines
1.1 KiB
C++

// Copyright 2017 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/api/api-inl.h"
#include "src/objects/objects-inl.h"
#include "test/unittests/test-helpers.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
class PreParserTest : public TestWithNativeContext {
public:
PreParserTest() = default;
PreParserTest(const PreParserTest&) = delete;
PreParserTest& operator=(const PreParserTest&) = delete;
};
TEST_F(PreParserTest, LazyFunctionLength) {
const char* script_source = "function lazy(a, b, c) { } lazy";
Handle<JSFunction> lazy_function = RunJS<JSFunction>(script_source);
Handle<SharedFunctionInfo> shared(lazy_function->shared(),
lazy_function->GetIsolate());
CHECK_EQ(3, shared->length());
Handle<Smi> length = RunJS<Smi>("lazy.length");
int32_t value;
CHECK(length->ToInt32(&value));
CHECK_EQ(3, value);
}
} // namespace internal
} // namespace v8