// 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 {} class M1 implements Iface {} class M2 implements Iface {} class M3 implements Iface {} typedef dynamic F1(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 m1 = new M1(); Expect.isTrue(m1 is Iface); Expect.isTrue(m1 is Iface); Expect.isTrue(m1 is Iface); Expect.isTrue(m1 is Iface); M2 m2 = new M2(); Expect.isTrue(m2 is Iface); Expect.isTrue(m2 is Iface); Expect.isTrue(m2 is Iface); Expect.isTrue(m2 is Iface); M3 m3 = new M3(); Expect.isTrue(m3 is Iface); Expect.isTrue(m3 is Iface); Expect.isTrue(m3 is Iface); Expect.isTrue(m3 is! Iface); F1 f1 = (String s, int i) => s[i]; Expect.isTrue(f1 is F1); 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); } }