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

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

Issue 10823293: Support resolution of indexed operators. (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') | no next file » | 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 8de20aa63d6c0ea4ad0a8bd9479f5e0af020b3c6..3c3234dc12a12f3dc58cd8b9bca4084feec93ca1 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -7,6 +7,7 @@
#import("../../../lib/compiler/implementation/leg.dart");
#import("../../../lib/compiler/implementation/elements/elements.dart");
#import("../../../lib/compiler/implementation/tree/tree.dart");
+#import("../../../lib/compiler/implementation/scanner/scannerlib.dart");
#import("../../../lib/compiler/implementation/util/util.dart");
#import("compiler_helper.dart");
#import("mock_compiler.dart");
@@ -73,6 +74,7 @@ main() {
testSuperCalls();
testTypeVariables();
testToString();
+ testIndexedOperator();
}
testTypeVariables() {
@@ -726,12 +728,16 @@ List<String> asSortedStrings(Link link) {
return result;
}
-testToString() {
+compileScript(String source) {
Uri uri = new Uri.fromComponents(scheme: 'source');
- MockCompiler compiler = compilerFor(
- @"class C { toString() => 'C'; } main() { '${new C()}'; }",
- uri);
+ MockCompiler compiler = compilerFor(source, uri);
compiler.runCompiler(uri);
+ return compiler;
+}
+
+testToString() {
+ final script = @"class C { toString() => 'C'; } main() { '${new C()}'; }";
+ final compiler = compileScript(script);
Element toStringMethod = findElement(compiler, 'C')
.lookupLocalMember(buildSourceString('toString'));
@@ -740,3 +746,28 @@ testToString() {
Expect.isNotNull(
compiler.enqueuer.resolution.getCachedElements(toStringMethod));
}
+
+testIndexedOperator() {
+ final script = @"""
+ class C {
+ operator[](ix) => ix;
+ operator[]=(ix, v) {}
+ }
+ main() { var c = new C(); c[0]++ ; }""";
+ final compiler = compileScript(script);
+
+ operatorName(op) => Elements.constructOperatorName(
+ const SourceString('operator'), new SourceString(op));
+
+ Element indexedOperator = findElement(compiler, 'C')
+ .lookupLocalMember(operatorName('[]'));
+ Expect.isNotNull(indexedOperator);
+ Expect.isNotNull(
+ compiler.enqueuer.resolution.getCachedElements(indexedOperator));
+
+ Element indexedSetOperator = findElement(compiler, 'C')
+ .lookupLocalMember(operatorName('[]='));
+ Expect.isNotNull(indexedOperator);
+ Expect.isNotNull(
+ compiler.enqueuer.resolution.getCachedElements(indexedSetOperator));
+}
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698