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-source-info.h"
8 : #include "test/unittests/test-utils.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 : namespace interpreter {
13 :
14 15188 : TEST(BytecodeSourceInfo, Operations) {
15 : BytecodeSourceInfo x(0, true);
16 1 : CHECK_EQ(x.source_position(), 0);
17 1 : CHECK_EQ(x.is_statement(), true);
18 1 : CHECK_EQ(x.is_valid(), true);
19 : x.set_invalid();
20 1 : CHECK_EQ(x.is_statement(), false);
21 1 : CHECK_EQ(x.is_valid(), false);
22 :
23 : x.MakeStatementPosition(1);
24 : BytecodeSourceInfo y(1, true);
25 1 : CHECK(x == y);
26 1 : CHECK(!(x != y));
27 :
28 : x.set_invalid();
29 1 : CHECK(!(x == y));
30 1 : CHECK(x != y);
31 :
32 : y.MakeStatementPosition(1);
33 1 : CHECK_EQ(y.source_position(), 1);
34 1 : CHECK_EQ(y.is_statement(), true);
35 :
36 : y.MakeStatementPosition(2);
37 1 : CHECK_EQ(y.source_position(), 2);
38 1 : CHECK_EQ(y.is_statement(), true);
39 :
40 : y.set_invalid();
41 : y.MakeExpressionPosition(3);
42 1 : CHECK_EQ(y.source_position(), 3);
43 1 : CHECK_EQ(y.is_statement(), false);
44 :
45 : y.MakeStatementPosition(3);
46 1 : CHECK_EQ(y.source_position(), 3);
47 1 : CHECK_EQ(y.is_statement(), true);
48 1 : }
49 :
50 : } // namespace interpreter
51 : } // namespace internal
52 9111 : } // namespace v8
|