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

Unified Diff: tests/compiler/dart2js/resolver_test.dart

Issue 10857033: Make sure to register +/- when we're using ++/--. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/resolver_test.dart
diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart
index 3c3234dc12a12f3dc58cd8b9bca4084feec93ca1..f3caff05ae1d04cef41531649390fe928d230de5 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -75,6 +75,7 @@ main() {
testTypeVariables();
testToString();
testIndexedOperator();
+ testIncrementsAndDecrements();
}
testTypeVariables() {
@@ -735,39 +736,57 @@ compileScript(String source) {
return compiler;
}
+checkMemberResolved(compiler, className, memberName) {
+ Element memberElement = findElement(compiler, className)
+ .lookupLocalMember(memberName);
+ Expect.isNotNull(memberElement);
+ Expect.isNotNull(
+ compiler.enqueuer.resolution.getCachedElements(memberElement));
+}
+
testToString() {
final script = @"class C { toString() => 'C'; } main() { '${new C()}'; }";
final compiler = compileScript(script);
- Element toStringMethod = findElement(compiler, 'C')
- .lookupLocalMember(buildSourceString('toString'));
- Expect.isNotNull(toStringMethod);
-
- Expect.isNotNull(
- compiler.enqueuer.resolution.getCachedElements(toStringMethod));
+ checkMemberResolved(compiler, 'C', buildSourceString('toString'));
}
+operatorName(op) => Elements.constructOperatorName(
+ const SourceString('operator'), new SourceString(op));
+
testIndexedOperator() {
final script = @"""
class C {
operator[](ix) => ix;
operator[]=(ix, v) {}
}
- main() { var c = new C(); c[0]++ ; }""";
+ main() { var c = new C(); c[0]++; }""";
final compiler = compileScript(script);
- operatorName(op) => Elements.constructOperatorName(
- const SourceString('operator'), new SourceString(op));
+ checkMemberResolved(compiler, 'C', operatorName('[]'));
+ checkMemberResolved(compiler, 'C', operatorName('[]='));
+}
- Element indexedOperator = findElement(compiler, 'C')
- .lookupLocalMember(operatorName('[]'));
- Expect.isNotNull(indexedOperator);
- Expect.isNotNull(
- compiler.enqueuer.resolution.getCachedElements(indexedOperator));
+testIncrementsAndDecrements() {
+ final script = @"""
+ class A { operator+(o)=>null; }
+ class B { operator+(o)=>null; }
+ class C { operator-(o)=>null; }
+ class D { operator-(o)=>null; }
+ main() {
+ var a = new A();
+ a++;
+ var b = new B();
+ ++b;
+ var c = new C();
+ c--;
+ var d = new D();
+ --d;
+ }""";
+ final compiler = compileScript(script);
- Element indexedSetOperator = findElement(compiler, 'C')
- .lookupLocalMember(operatorName('[]='));
- Expect.isNotNull(indexedOperator);
- Expect.isNotNull(
- compiler.enqueuer.resolution.getCachedElements(indexedSetOperator));
+ checkMemberResolved(compiler, 'A', operatorName('+'));
+ checkMemberResolved(compiler, 'B', operatorName('+'));
+ checkMemberResolved(compiler, 'C', operatorName('-'));
+ checkMemberResolved(compiler, 'D', operatorName('-'));
}
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698