// 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. // Test that instanceof works correctly with type variables. import "package:expect/expect.dart"; // Test that partially typed generic instances are correctly constructed. // Test factory case. class Foo { Foo() {} factory Foo.fac() { return new Foo(); } FooString() { return new Foo.fac(); } } // Test constructor case. class Moo { Moo() {} MooString() { return new Moo(); } } testAll() { var foo_int_num = new Foo(); Expect.isTrue(foo_int_num is Foo); Expect.isTrue(foo_int_num is! Foo); // foo_int_num.FooString() returns a Foo Expect.isTrue(foo_int_num.FooString() is! Foo); Expect.isTrue(foo_int_num.FooString() is Foo); var foo_raw = new Foo(); Expect.isTrue(foo_raw is Foo); Expect.isTrue(foo_raw is Foo); // foo_raw.FooString() returns a Foo Expect.isTrue(foo_raw.FooString() is! Foo); Expect.isTrue(foo_raw.FooString() is Foo); var moo_int_num = new Moo(); Expect.isTrue(moo_int_num is Moo); Expect.isTrue(moo_int_num is! Moo); // moo_int_num.MooString() returns a Moo Expect.isTrue(moo_int_num.MooString() is! Moo); Expect.isTrue(moo_int_num.MooString() is Moo); var moo_raw = new Moo(); Expect.isTrue(moo_raw is Moo); Expect.isTrue(moo_raw is Moo); // moo_raw.MooString() returns a Moo Expect.isTrue(moo_raw.MooString() is! Moo); Expect.isTrue(moo_raw.MooString() is Moo); } main() { // Repeat type checks so that inlined tests can be tested as well. for (int i = 0; i < 5; i++) { testAll(); } }