Line data Source code
1 : // Copyright 2017 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/ast/ast-value-factory.h"
6 : #include "src/heap/heap-inl.h"
7 : #include "src/isolate-inl.h"
8 : #include "src/zone/zone.h"
9 : #include "test/unittests/test-utils.h"
10 : #include "testing/gtest/include/gtest/gtest.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 :
15 2 : class AstValueTest : public TestWithIsolateAndZone {
16 : protected:
17 1 : AstValueTest()
18 : : ast_value_factory_(zone(), i_isolate()->ast_string_constants(),
19 2 : i_isolate()->heap()->HashSeed()) {}
20 :
21 : AstValueFactory ast_value_factory_;
22 : };
23 :
24 13160 : TEST_F(AstValueTest, BigIntBooleanValue) {
25 2 : EXPECT_FALSE(ast_value_factory_.NewBigInt("0")->BooleanValue());
26 2 : EXPECT_FALSE(ast_value_factory_.NewBigInt("0b0")->BooleanValue());
27 2 : EXPECT_FALSE(ast_value_factory_.NewBigInt("0o0")->BooleanValue());
28 2 : EXPECT_FALSE(ast_value_factory_.NewBigInt("0x0")->BooleanValue());
29 2 : EXPECT_FALSE(ast_value_factory_.NewBigInt("0b000")->BooleanValue());
30 2 : EXPECT_FALSE(ast_value_factory_.NewBigInt("0o00000")->BooleanValue());
31 2 : EXPECT_FALSE(ast_value_factory_.NewBigInt("0x000000000")->BooleanValue());
32 :
33 2 : EXPECT_TRUE(ast_value_factory_.NewBigInt("3")->BooleanValue());
34 2 : EXPECT_TRUE(ast_value_factory_.NewBigInt("0b1")->BooleanValue());
35 2 : EXPECT_TRUE(ast_value_factory_.NewBigInt("0o6")->BooleanValue());
36 2 : EXPECT_TRUE(ast_value_factory_.NewBigInt("0xa")->BooleanValue());
37 2 : EXPECT_TRUE(ast_value_factory_.NewBigInt("0b0000001")->BooleanValue());
38 2 : EXPECT_TRUE(ast_value_factory_.NewBigInt("0o00005000")->BooleanValue());
39 2 : EXPECT_TRUE(ast_value_factory_.NewBigInt("0x0000d00c0")->BooleanValue());
40 1 : }
41 :
42 : } // namespace internal
43 7893 : } // namespace v8
|