LCOV - code coverage report
Current view: top level - test/unittests/interpreter - bytecode-node-unittest.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 47 47 100.0 %
Date: 2019-02-19 Functions: 18 26 69.2 %

          Line data    Source code
       1             : // Copyright 2016 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/v8.h"
       6             : 
       7             : #include "src/interpreter/bytecode-node.h"
       8             : #include "test/unittests/test-utils.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : namespace interpreter {
      13             : 
      14             : using BytecodeNodeTest = TestWithIsolateAndZone;
      15             : 
      16       15189 : TEST_F(BytecodeNodeTest, Constructor1) {
      17             :   BytecodeNode node(Bytecode::kLdaZero);
      18           1 :   CHECK_EQ(node.bytecode(), Bytecode::kLdaZero);
      19           1 :   CHECK_EQ(node.operand_count(), 0);
      20           1 :   CHECK(!node.source_info().is_valid());
      21           1 : }
      22             : 
      23       15189 : TEST_F(BytecodeNodeTest, Constructor2) {
      24             :   uint32_t operands[] = {0x11};
      25             :   BytecodeNode node(Bytecode::kJumpIfTrue, operands[0]);
      26           1 :   CHECK_EQ(node.bytecode(), Bytecode::kJumpIfTrue);
      27           1 :   CHECK_EQ(node.operand_count(), 1);
      28           1 :   CHECK_EQ(node.operand(0), operands[0]);
      29           2 :   CHECK(!node.source_info().is_valid());
      30           1 : }
      31             : 
      32       15189 : TEST_F(BytecodeNodeTest, Constructor3) {
      33             :   uint32_t operands[] = {0x11, 0x22};
      34             :   BytecodeNode node(Bytecode::kLdaGlobal, operands[0], operands[1]);
      35           1 :   CHECK_EQ(node.bytecode(), Bytecode::kLdaGlobal);
      36           1 :   CHECK_EQ(node.operand_count(), 2);
      37           1 :   CHECK_EQ(node.operand(0), operands[0]);
      38           1 :   CHECK_EQ(node.operand(1), operands[1]);
      39           2 :   CHECK(!node.source_info().is_valid());
      40           1 : }
      41             : 
      42       15189 : TEST_F(BytecodeNodeTest, Constructor4) {
      43             :   uint32_t operands[] = {0x11, 0x22, 0x33};
      44             :   BytecodeNode node(Bytecode::kLdaNamedProperty, operands[0], operands[1],
      45             :                     operands[2]);
      46           1 :   CHECK_EQ(node.operand_count(), 3);
      47           1 :   CHECK_EQ(node.bytecode(), Bytecode::kLdaNamedProperty);
      48           1 :   CHECK_EQ(node.operand(0), operands[0]);
      49           1 :   CHECK_EQ(node.operand(1), operands[1]);
      50           1 :   CHECK_EQ(node.operand(2), operands[2]);
      51           2 :   CHECK(!node.source_info().is_valid());
      52           1 : }
      53             : 
      54       15189 : TEST_F(BytecodeNodeTest, Constructor5) {
      55             :   uint32_t operands[] = {0x71, 0xA5, 0x5A, 0xFC};
      56             :   BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
      57             :                     operands[3]);
      58           1 :   CHECK_EQ(node.operand_count(), 4);
      59           1 :   CHECK_EQ(node.bytecode(), Bytecode::kForInNext);
      60           1 :   CHECK_EQ(node.operand(0), operands[0]);
      61           1 :   CHECK_EQ(node.operand(1), operands[1]);
      62           1 :   CHECK_EQ(node.operand(2), operands[2]);
      63           1 :   CHECK_EQ(node.operand(3), operands[3]);
      64           2 :   CHECK(!node.source_info().is_valid());
      65           1 : }
      66             : 
      67       15189 : TEST_F(BytecodeNodeTest, Equality) {
      68             :   uint32_t operands[] = {0x71, 0xA5, 0x5A, 0xFC};
      69             :   BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
      70             :                     operands[3]);
      71           1 :   CHECK_EQ(node, node);
      72             :   BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1],
      73             :                      operands[2], operands[3]);
      74           1 :   CHECK_EQ(node, other);
      75           1 : }
      76             : 
      77       15189 : TEST_F(BytecodeNodeTest, EqualityWithSourceInfo) {
      78             :   uint32_t operands[] = {0x71, 0xA5, 0x5A, 0xFC};
      79             :   BytecodeSourceInfo first_source_info(3, true);
      80             :   BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
      81             :                     operands[3], first_source_info);
      82           1 :   CHECK_EQ(node, node);
      83             :   BytecodeSourceInfo second_source_info(3, true);
      84             :   BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1],
      85             :                      operands[2], operands[3], second_source_info);
      86           1 :   CHECK_EQ(node, other);
      87           1 : }
      88             : 
      89       15189 : TEST_F(BytecodeNodeTest, NoEqualityWithDifferentSourceInfo) {
      90             :   uint32_t operands[] = {0x71, 0xA5, 0x5A, 0xFC};
      91             :   BytecodeSourceInfo source_info(77, true);
      92             :   BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
      93             :                     operands[3], source_info);
      94             :   BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1],
      95             :                      operands[2], operands[3]);
      96           1 :   CHECK_NE(node, other);
      97           1 : }
      98             : 
      99             : }  // namespace interpreter
     100             : }  // namespace internal
     101        9111 : }  // namespace v8

Generated by: LCOV version 1.10