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

Unified Diff: frog/tests/leg/src/ResolverTest.dart

Issue 10095014: Implement interface types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/tests/leg/src/ResolverTest.dart
diff --git a/frog/tests/leg/src/ResolverTest.dart b/frog/tests/leg/src/ResolverTest.dart
index 0c79114588fb97c6dec3749d8d0deb16d095fe6d..231efd0c12a52a4bd7c26125d7f476f11ee72408 100644
--- a/frog/tests/leg/src/ResolverTest.dart
+++ b/frog/tests/leg/src/ResolverTest.dart
@@ -68,6 +68,50 @@ main() {
testInitializers();
testThis();
testSuperCalls();
+ testTypeVariables();
+}
+
+testTypeVariables() {
+ testTypeResolving(visitor, text, name, expectedElements) {
+ VariableDefinitions definition = parseStatement(text);
+ visitor.visit(definition.type);
+ InterfaceType type = visitor.mapping.getType(definition.type);
+ Expect.equals(definition.type.typeArguments.length(),
+ length(type.arguments));
+ int index = 0;
+ Link<Type> arguments = type.arguments;
+ while (!arguments.isEmpty()) {
+ Expect.equals(expectedElements[index], arguments.head.element);
+ index++;
+ arguments = arguments.tail;
+ }
+ }
+
+ MockCompiler compiler = new MockCompiler();
+ ResolverVisitor visitor = compiler.resolverVisitor();
+ compiler.parseScript('class Foo<T, U> {}');
+ visitor.visit(parseStatement('Foo foo;'));
+ ClassElement foo = compiler.mainApp.find(buildSourceString('Foo'));
+ testTypeResolving(visitor, 'Foo<int, String> x;', 'Foo',
+ [compiler.intClass, compiler.stringClass]);
+ testTypeResolving(visitor, 'Foo<Foo, Foo> x;', 'Foo',
+ [foo, foo]);
+
+ compiler = new MockCompiler();
+ compiler.parseScript('class Foo<T, U> {}');
+ compiler.resolveStatement('Foo<notype, int> x;');
+ Expect.equals(1, compiler.warnings.length);
+ Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE,
+ compiler.warnings[0].message.kind);
+ Expect.equals(0, compiler.errors.length);
+
+ compiler = new MockCompiler();
+ compiler.parseScript('class Foo<T, U> {}');
+ compiler.resolveStatement('var x = new Foo<notype, int>();');
+ Expect.equals(0, compiler.warnings.length);
+ Expect.equals(1, compiler.errors.length);
+ Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE,
+ compiler.errors[0].message.kind);
}
testSuperCalls() {
« no previous file with comments | « no previous file | lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698