2017-04-18 14:01:12 +00:00
|
|
|
// 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.
|
|
|
|
|
2019-05-17 12:13:44 +00:00
|
|
|
#include "src/api/api-inl.h"
|
2019-05-23 08:51:46 +00:00
|
|
|
#include "src/objects/objects-inl.h"
|
2017-04-18 14:01:12 +00:00
|
|
|
#include "test/unittests/test-helpers.h"
|
|
|
|
#include "test/unittests/test-utils.h"
|
|
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2017-11-13 12:04:57 +00:00
|
|
|
class PreParserTest : public TestWithNativeContext {
|
2017-04-18 14:01:12 +00:00
|
|
|
public:
|
2018-09-13 10:07:40 +00:00
|
|
|
PreParserTest() = default;
|
2020-11-05 08:11:05 +00:00
|
|
|
PreParserTest(const PreParserTest&) = delete;
|
|
|
|
PreParserTest& operator=(const PreParserTest&) = delete;
|
2017-04-18 14:01:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(PreParserTest, LazyFunctionLength) {
|
|
|
|
const char* script_source = "function lazy(a, b, c) { } lazy";
|
|
|
|
|
2017-11-13 12:04:57 +00:00
|
|
|
Handle<JSFunction> lazy_function = RunJS<JSFunction>(script_source);
|
2017-04-18 14:01:12 +00:00
|
|
|
|
2018-06-23 09:05:50 +00:00
|
|
|
Handle<SharedFunctionInfo> shared(lazy_function->shared(),
|
|
|
|
lazy_function->GetIsolate());
|
2019-04-11 10:43:45 +00:00
|
|
|
CHECK_EQ(3, shared->length());
|
2017-04-18 14:01:12 +00:00
|
|
|
|
2017-11-13 12:04:57 +00:00
|
|
|
Handle<Smi> length = RunJS<Smi>("lazy.length");
|
2017-04-18 14:01:12 +00:00
|
|
|
int32_t value;
|
|
|
|
CHECK(length->ToInt32(&value));
|
|
|
|
CHECK_EQ(3, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|