dart-sdk/tests/language/dynamic_test.dart
kustermann@google.com 94ebff2225 Bugfix in test.dart, adding of specialized test outcomes for analyzer
This CL will:
 - fix a bug in the legacy AnalyzerCommandOutputImpl class (in certain cases
   we did not report that the analyzer was missing a warning).
 - make the outcome of running the analyzer on a test be one of:
   * CompileTimeError
   * MissingCompileTimeError
   * StaticWarning
   * MissingStaticWarning
 - Make status file updates using the new Expectation markers
 - Remove support for '@static-clean':
     Previously running the analyer on a test could either result in
     'Pass' or in 'Fail'. The '@static-clean' annotation has been used
     as a (poor) mechanism to distinguish between errors and warnings.
     Having the 4 markers mentioned above means we can remove '@static-clean'
 - Remove 100 lines of rotted legacy code in our testing scripts.
 - Make a status file entry for every test that has analyzer errors or warnings

R=ricow@google.com

Review URL: https://codereview.chromium.org//46163002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29350 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-28 10:39:38 +00:00

68 lines
1.8 KiB
Dart

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// Dart test program testing the use of 'dynamic' in generic types.
import "package:expect/expect.dart";
abstract class Iface<K,V> {
}
class M1<K, V> implements Iface<K, V> {
}
class M2<K> implements Iface<K, dynamic> {
}
class M3 implements Iface<String, dynamic> {
}
typedef dynamic F1<T>(dynamic x, T y);
class HasFieldDynamic {
HasFieldDynamic() : dynamic = "dynamic" { }
var dynamic; // Field named dynamic is allowed.
}
class HasMethodDynamic {
dynamic() => "dynamic"; // Method named dynamic is allowed.
}
main() {
Expect.isTrue(dynamic is Type);
Expect.equals(dynamic, dynamic);
M1<dynamic, dynamic> m1 = new M1<dynamic, dynamic>();
Expect.isTrue(m1 is Iface<dynamic, num>);
Expect.isTrue(m1 is Iface<String, dynamic>);
Expect.isTrue(m1 is Iface<String, num>);
Expect.isTrue(m1 is Iface<num, String>);
M2<dynamic> m2 = new M2<dynamic>();
Expect.isTrue(m2 is Iface<dynamic, num>);
Expect.isTrue(m2 is Iface<String, dynamic>);
Expect.isTrue(m2 is Iface<String, num>);
Expect.isTrue(m2 is Iface<num, String>);
M3 m3 = new M3();
Expect.isTrue(m3 is Iface<dynamic, num>);
Expect.isTrue(m3 is Iface<String, dynamic>);
Expect.isTrue(m3 is Iface<String, num>);
Expect.isTrue(m3 is !Iface<num, String>);
F1<int> f1 = (String s, int i) => s[i];
Expect.isTrue(f1 is F1<int>);
HasFieldDynamic has_field = new HasFieldDynamic();
Expect.equals("dynamic", has_field.dynamic);
HasMethodDynamic has_method = new HasMethodDynamic();
Expect.equals("dynamic", has_method.dynamic());
{
int dynamic = 0; // Local variable named dynamic is allowed.
Expect.equals(0, dynamic);
}
}