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

Side by Side Diff: dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/resolver/DeclarationMatcherTest.java

Issue 59073003: Version 0.8.10.4 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, the Dart project authors. 2 * Copyright (c) 2013, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 " }", 70 " }",
71 "}"), createSource(// 71 "}"), createSource(//
72 "class C {", 72 "class C {",
73 " int m(int p) {", 73 " int m(int p) {",
74 " int product = p * p;", 74 " int product = p * p;",
75 " return product + product;", 75 " return product + product;",
76 " }", 76 " }",
77 "}")); 77 "}"));
78 } 78 }
79 79
80 public void test_methodDeclarationMatches_false_parameter() throws Exception {
81 assertMethodMatches(false, createSource(//
82 "class C {",
83 " int m(int p) {",
84 " return p + p;",
85 " }",
86 "}"), createSource(//
87 "class C {",
88 " int m(int p, int q) {",
89 " return (p * q) + (q * p);",
90 " }",
91 "}"));
92 }
93
94 public void test_methodDeclarationMatches_true_different() throws Exception { 80 public void test_methodDeclarationMatches_true_different() throws Exception {
95 assertMethodMatches(true, createSource(// 81 assertMethodMatches(true, createSource(//
96 "class C {", 82 "class C {",
97 " int m(int p) {", 83 " int m(int p) {",
98 " return p + p;", 84 " return p + p;",
99 " }", 85 " }",
100 "}"), createSource(// 86 "}"), createSource(//
101 "class C {", 87 "class C {",
102 " int m(int p) {", 88 " int m(int p) {",
103 " return (p * p) + (p * p);", 89 " return (p * p) + (p * p);",
104 " }", 90 " }",
105 "}")); 91 "}"));
106 } 92 }
107 93
108 public void test_methodDeclarationMatches_true_same() throws Exception { 94 public void test_methodDeclarationMatches_true_same() throws Exception {
109 String content = createSource(// 95 String content = createSource(//
110 "class C {", 96 "class C {",
111 " int m(int p) {", 97 " int m(int p) {",
112 " return p + p;", 98 " return p + p;",
113 " }", 99 " }",
114 "}"); 100 "}");
115 assertMethodMatches(true, content, content); 101 assertMethodMatches(true, content, content);
116 } 102 }
117 103
104 public void xtest_methodDeclarationMatches_false_parameter() throws Exception {
105 assertMethodMatches(false, createSource(//
106 "class C {",
107 " int m(int p) {",
108 " return p + p;",
109 " }",
110 "}"), createSource(//
111 "class C {",
112 " int m(int p, int q) {",
113 " return (p * q) + (q * p);",
114 " }",
115 "}"));
116 }
117
118 private void assertCompilationUnitMatches(boolean expectMatch, String oldConte nt, 118 private void assertCompilationUnitMatches(boolean expectMatch, String oldConte nt,
119 String newContent) throws Exception { 119 String newContent) throws Exception {
120 Source source = addSource(oldContent); 120 Source source = addSource(oldContent);
121 LibraryElement library = resolve(source); 121 LibraryElement library = resolve(source);
122 CompilationUnit oldUnit = resolveCompilationUnit(source, library); 122 CompilationUnit oldUnit = resolveCompilationUnit(source, library);
123 123
124 AnalysisContext context = getAnalysisContext(); 124 AnalysisContext context = getAnalysisContext();
125 context.setContents(source, newContent); 125 context.setContents(source, newContent);
126 CompilationUnit newUnit = context.parseCompilationUnit(source); 126 CompilationUnit newUnit = context.parseCompilationUnit(source);
127 127
(...skipping 15 matching lines...) Expand all
143 143
144 DeclarationMatcher matcher = new DeclarationMatcher(); 144 DeclarationMatcher matcher = new DeclarationMatcher();
145 assertEquals(expectMatch, matcher.matches(newMethod, element)); 145 assertEquals(expectMatch, matcher.matches(newMethod, element));
146 } 146 }
147 147
148 private MethodDeclaration getMethod(CompilationUnit unit) { 148 private MethodDeclaration getMethod(CompilationUnit unit) {
149 ClassDeclaration classNode = (ClassDeclaration) unit.getDeclarations().get(0 ); 149 ClassDeclaration classNode = (ClassDeclaration) unit.getDeclarations().get(0 );
150 return (MethodDeclaration) classNode.getMembers().get(0); 150 return (MethodDeclaration) classNode.getMembers().get(0);
151 } 151 }
152 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698