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

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

Issue 9431029: Implement interface types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 8 years, 9 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') | lib/compiler/implementation/compiler.dart » ('J')
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) {
ahe 2012/04/12 15:05:23 I think it is confusing when a helper function sta
+ 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()) {
ahe 2012/04/12 15:05:23 Expect.isTrue(index < expectedElements.length);
+ 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;'));
ahe 2012/04/12 15:05:23 What is the purpose of this?
+ 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') | lib/compiler/implementation/compiler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698