v8/test/unittests/parser/preparser-unittest.cc
Marja Hölttä 42b2eb0e0e [parser] Move newly added cctest/test-parsing/LazyFunctionLength to unittests.
BUG=v8:5516

Change-Id: Ie2e41ffa82c63788e285641232a5d555155b0d13
Reviewed-on: https://chromium-review.googlesource.com/480239
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Daniel Vogelheim <vogelheim@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44689}
2017-04-18 14:27:32 +00:00

42 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.h"
#include "src/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 TestWithContext {
public:
PreParserTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(PreParserTest);
};
TEST_F(PreParserTest, LazyFunctionLength) {
const char* script_source = "function lazy(a, b, c) { } lazy";
Handle<Object> lazy_object = test::RunJS(isolate(), script_source);
Handle<SharedFunctionInfo> shared(
Handle<JSFunction>::cast(lazy_object)->shared(), i_isolate());
CHECK_EQ(shared->length(), SharedFunctionInfo::kInvalidLength);
const char* get_length_source = "lazy.length";
Handle<Object> length = test::RunJS(isolate(), get_length_source);
CHECK(length->IsSmi());
int32_t value;
CHECK(length->ToInt32(&value));
CHECK_EQ(3, value);
}
} // namespace internal
} // namespace v8