| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/interpreter/source-position-table.h" | 7 #include "src/interpreter/source-position-table.h" |
| 8 #include "test/unittests/test-utils.h" | 8 #include "test/unittests/test-utils.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 SourcePositionTableBuilder builder(isolate(), zone()); | 26 SourcePositionTableBuilder builder(isolate(), zone()); |
| 27 for (int i = 0; i < arraysize(offsets); i++) { | 27 for (int i = 0; i < arraysize(offsets); i++) { |
| 28 builder.AddStatementPosition(offsets[i], offsets[i]); | 28 builder.AddStatementPosition(offsets[i], offsets[i]); |
| 29 } | 29 } |
| 30 | 30 |
| 31 // To test correctness, we rely on the assertions in ToSourcePositionTable(). | 31 // To test correctness, we rely on the assertions in ToSourcePositionTable(). |
| 32 // (Also below.) | 32 // (Also below.) |
| 33 CHECK(!builder.ToSourcePositionTable().is_null()); | 33 CHECK(!builder.ToSourcePositionTable().is_null()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 TEST_F(SourcePositionTableTest, EncodeStatementDuplicates) { |
| 37 SourcePositionTableBuilder builder(isolate(), zone()); |
| 38 for (int i = 0; i < arraysize(offsets); i++) { |
| 39 builder.AddStatementPosition(offsets[i], offsets[i]); |
| 40 builder.AddStatementPosition( |
| 41 offsets[i], offsets[i], |
| 42 (i % 2 == 0) ? SourcePositionTableBuilder::OVERWRITE_DUPLICATE |
| 43 : SourcePositionTableBuilder::DISCARD_DUPLICATE); |
| 44 builder.AddStatementPosition(offsets[i], offsets[i]); |
| 45 builder.AddStatementPosition( |
| 46 offsets[i], offsets[i], |
| 47 (i % 2 == 0) ? SourcePositionTableBuilder::OVERWRITE_DUPLICATE |
| 48 : SourcePositionTableBuilder::DISCARD_DUPLICATE); |
| 49 } |
| 50 |
| 51 // To test correctness, we rely on the assertions in ToSourcePositionTable(). |
| 52 // (Also below.) |
| 53 CHECK(!builder.ToSourcePositionTable().is_null()); |
| 54 } |
| 55 |
| 36 TEST_F(SourcePositionTableTest, EncodeExpression) { | 56 TEST_F(SourcePositionTableTest, EncodeExpression) { |
| 37 SourcePositionTableBuilder builder(isolate(), zone()); | 57 SourcePositionTableBuilder builder(isolate(), zone()); |
| 38 for (int i = 0; i < arraysize(offsets); i++) { | 58 for (int i = 0; i < arraysize(offsets); i++) { |
| 39 builder.AddExpressionPosition(offsets[i], offsets[i]); | 59 builder.AddExpressionPosition(offsets[i], offsets[i]); |
| 40 } | 60 } |
| 41 CHECK(!builder.ToSourcePositionTable().is_null()); | 61 CHECK(!builder.ToSourcePositionTable().is_null()); |
| 42 } | 62 } |
| 43 | 63 |
| 44 TEST_F(SourcePositionTableTest, EncodeAscending) { | 64 TEST_F(SourcePositionTableTest, EncodeAscending) { |
| 45 SourcePositionTableBuilder builder(isolate(), zone()); | 65 SourcePositionTableBuilder builder(isolate(), zone()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 builder.AddExpressionPosition(accumulator, accumulator); | 83 builder.AddExpressionPosition(accumulator, accumulator); |
| 64 } | 84 } |
| 65 } | 85 } |
| 66 | 86 |
| 67 CHECK(!builder.ToSourcePositionTable().is_null()); | 87 CHECK(!builder.ToSourcePositionTable().is_null()); |
| 68 } | 88 } |
| 69 | 89 |
| 70 } // namespace interpreter | 90 } // namespace interpreter |
| 71 } // namespace internal | 91 } // namespace internal |
| 72 } // namespace v8 | 92 } // namespace v8 |
| OLD | NEW |