LCOV - code coverage report
Current view: top level - test/unittests/parser - ast-value-unittest.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 21 21 100.0 %
Date: 2019-01-20 Functions: 6 8 75.0 %

          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/ast/ast.h"
       7             : #include "src/heap/heap-inl.h"
       8             : #include "src/isolate-inl.h"
       9             : #include "src/zone/zone.h"
      10             : #include "test/unittests/test-utils.h"
      11             : #include "testing/gtest/include/gtest/gtest.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16           2 : class AstValueTest : public TestWithIsolateAndZone {
      17             :  protected:
      18           1 :   AstValueTest()
      19             :       : ast_value_factory_(zone(), i_isolate()->ast_string_constants(),
      20             :                            i_isolate()->heap()->HashSeed()),
      21           3 :         ast_node_factory_(&ast_value_factory_, zone()) {}
      22             : 
      23             :   Literal* NewBigInt(const char* str) {
      24             :     return ast_node_factory_.NewBigIntLiteral(AstBigInt(str),
      25          14 :                                               kNoSourcePosition);
      26             :   }
      27             : 
      28             :   AstValueFactory ast_value_factory_;
      29             :   AstNodeFactory ast_node_factory_;
      30             : };
      31             : 
      32       15128 : TEST_F(AstValueTest, BigIntToBooleanIsTrue) {
      33           2 :   EXPECT_FALSE(NewBigInt("0")->ToBooleanIsTrue());
      34           2 :   EXPECT_FALSE(NewBigInt("0b0")->ToBooleanIsTrue());
      35           2 :   EXPECT_FALSE(NewBigInt("0o0")->ToBooleanIsTrue());
      36           2 :   EXPECT_FALSE(NewBigInt("0x0")->ToBooleanIsTrue());
      37           2 :   EXPECT_FALSE(NewBigInt("0b000")->ToBooleanIsTrue());
      38           2 :   EXPECT_FALSE(NewBigInt("0o00000")->ToBooleanIsTrue());
      39           2 :   EXPECT_FALSE(NewBigInt("0x000000000")->ToBooleanIsTrue());
      40             : 
      41           2 :   EXPECT_TRUE(NewBigInt("3")->ToBooleanIsTrue());
      42           2 :   EXPECT_TRUE(NewBigInt("0b1")->ToBooleanIsTrue());
      43           2 :   EXPECT_TRUE(NewBigInt("0o6")->ToBooleanIsTrue());
      44           2 :   EXPECT_TRUE(NewBigInt("0xA")->ToBooleanIsTrue());
      45           2 :   EXPECT_TRUE(NewBigInt("0b0000001")->ToBooleanIsTrue());
      46           2 :   EXPECT_TRUE(NewBigInt("0o00005000")->ToBooleanIsTrue());
      47           2 :   EXPECT_TRUE(NewBigInt("0x0000D00C0")->ToBooleanIsTrue());
      48           1 : }
      49             : 
      50             : }  // namespace internal
      51        9075 : }  // namespace v8

Generated by: LCOV version 1.10