Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: test/cctest/test-liveedit.cc

Issue 1737009: Rename Compare -> Comparator to resolve name conflict in v8::internal (Closed)
Patch Set: merge Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/liveedit.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 20 matching lines...) Expand all
31 31
32 #include "liveedit.h" 32 #include "liveedit.h"
33 #include "cctest.h" 33 #include "cctest.h"
34 34
35 35
36 using namespace v8::internal; 36 using namespace v8::internal;
37 37
38 // Anonymous namespace. 38 // Anonymous namespace.
39 namespace { 39 namespace {
40 40
41 class StringCompareInput : public Compare::Input { 41 class StringCompareInput : public Comparator::Input {
42 public: 42 public:
43 StringCompareInput(const char* s1, const char* s2) : s1_(s1), s2_(s2) { 43 StringCompareInput(const char* s1, const char* s2) : s1_(s1), s2_(s2) {
44 } 44 }
45 int getLength1() { 45 int getLength1() {
46 return StrLength(s1_); 46 return StrLength(s1_);
47 } 47 }
48 int getLength2() { 48 int getLength2() {
49 return StrLength(s2_); 49 return StrLength(s2_);
50 } 50 }
51 bool equals(int index1, int index2) { 51 bool equals(int index1, int index2) {
(...skipping 13 matching lines...) Expand all
65 : pos1(pos1_param), pos2(pos2_param), 65 : pos1(pos1_param), pos2(pos2_param),
66 len1(len1_param), len2(len2_param), next(NULL) {} 66 len1(len1_param), len2(len2_param), next(NULL) {}
67 int pos1; 67 int pos1;
68 int pos2; 68 int pos2;
69 int len1; 69 int len1;
70 int len2; 70 int len2;
71 DiffChunkStruct* next; 71 DiffChunkStruct* next;
72 }; 72 };
73 73
74 74
75 class ListDiffOutputWriter : public Compare::Output { 75 class ListDiffOutputWriter : public Comparator::Output {
76 public: 76 public:
77 explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer) 77 explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer)
78 : next_chunk_pointer_(next_chunk_pointer) { 78 : next_chunk_pointer_(next_chunk_pointer) {
79 (*next_chunk_pointer_) = NULL; 79 (*next_chunk_pointer_) = NULL;
80 } 80 }
81 void AddChunk(int pos1, int pos2, int len1, int len2) { 81 void AddChunk(int pos1, int pos2, int len1, int len2) {
82 current_chunk_ = new DiffChunkStruct(pos1, pos2, len1, len2); 82 current_chunk_ = new DiffChunkStruct(pos1, pos2, len1, len2);
83 (*next_chunk_pointer_) = current_chunk_; 83 (*next_chunk_pointer_) = current_chunk_;
84 next_chunk_pointer_ = &current_chunk_->next; 84 next_chunk_pointer_ = &current_chunk_->next;
85 } 85 }
86 private: 86 private:
87 DiffChunkStruct** next_chunk_pointer_; 87 DiffChunkStruct** next_chunk_pointer_;
88 DiffChunkStruct* current_chunk_; 88 DiffChunkStruct* current_chunk_;
89 }; 89 };
90 90
91 91
92 void CompareStringsOneWay(const char* s1, const char* s2, 92 void CompareStringsOneWay(const char* s1, const char* s2,
93 int expected_diff_parameter = -1) { 93 int expected_diff_parameter = -1) {
94 StringCompareInput input(s1, s2); 94 StringCompareInput input(s1, s2);
95 95
96 ZoneScope zone_scope(DELETE_ON_EXIT); 96 ZoneScope zone_scope(DELETE_ON_EXIT);
97 97
98 DiffChunkStruct* first_chunk; 98 DiffChunkStruct* first_chunk;
99 ListDiffOutputWriter writer(&first_chunk); 99 ListDiffOutputWriter writer(&first_chunk);
100 100
101 Compare::CalculateDifference(&input, &writer); 101 Comparator::CalculateDifference(&input, &writer);
102 102
103 int len1 = StrLength(s1); 103 int len1 = StrLength(s1);
104 int len2 = StrLength(s2); 104 int len2 = StrLength(s2);
105 105
106 int pos1 = 0; 106 int pos1 = 0;
107 int pos2 = 0; 107 int pos2 = 0;
108 108
109 int diff_parameter = 0; 109 int diff_parameter = 0;
110 110
111 for (DiffChunkStruct* chunk = first_chunk; 111 for (DiffChunkStruct* chunk = first_chunk;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 CompareStrings("cat", "cut", 2); 165 CompareStrings("cat", "cut", 2);
166 CompareStrings("ct", "cut", 1); 166 CompareStrings("ct", "cut", 1);
167 CompareStrings("cat", "ct", 1); 167 CompareStrings("cat", "ct", 1);
168 CompareStrings("cat", "cat", 0); 168 CompareStrings("cat", "cat", 0);
169 CompareStrings("", "", 0); 169 CompareStrings("", "", 0);
170 CompareStrings("cat", "", 3); 170 CompareStrings("cat", "", 3);
171 CompareStrings("a cat", "a capybara", 7); 171 CompareStrings("a cat", "a capybara", 7);
172 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", 172 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa",
173 "bbbbabababbbabababbbabababababbabbababa"); 173 "bbbbabababbbabababbbabababababbabbababa");
174 } 174 }
OLDNEW
« no previous file with comments | « src/liveedit.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698