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

Unified Diff: runtime/tests/vm/src/GenericTest.dart

Issue 10280007: Check upper bounds of type arguments when allocating objects of a generic type (Closed) Base URL: http://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 | runtime/vm/code_generator.h » ('j') | runtime/vm/code_generator.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/tests/vm/src/GenericTest.dart
===================================================================
--- runtime/tests/vm/src/GenericTest.dart (revision 7209)
+++ runtime/tests/vm/src/GenericTest.dart (working copy)
@@ -1,85 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
srdjan 2012/05/01 23:30:51 2012
regis 2012/05/02 01:34:16 This test is being deleted. There is an almost ide
-// BSD-style license that can be found in the LICENSE file.
-// VMOptions=--enable_type_checks --enable_asserts
srdjan 2012/05/01 23:30:51 You don't need asserts, do you?
regis 2012/05/02 01:34:16 No.
-//
-// Dart test program testing generic type allocations and generic type tests.
-
-class A {
- const A();
-}
srdjan 2012/05/01 23:30:51 Would it be good to have a similar test in the sha
regis 2012/05/02 01:34:16 We have one.
-
-class AA extends A {
- const AA();
-}
-
-class AX {
- const AX();
-}
-
-class B<T extends A> {
- final A a_;
- final T t_;
- const B(T t) : a_ = t, t_ = t;
- isT(x) {
- return x is T;
- }
-}
-
-class C<T> {
- B<T> b_;
- C(T t) : b_ = new B<T>(t) { }
-}
-
-class D {
- C<AA> caa_;
- D() : caa_ = new C<AA>(const AA()) { }
-}
-
-class E {
- C<AX> cax_;
- E() : cax_ = new C<AX>(const AX()) { }
-}
-
-class GenericTest {
- static test() {
- int result = 0;
- D d = new D();
- Expect.equals(true, d.caa_.b_ is B<AA>);
- Expect.equals(true, d.caa_.b_.isT(const AA()));
- C c = new C(const AA()); // c is of raw type C, T in C<T> is Dynamic.
- Expect.equals(true, c.b_ is B);
- Expect.equals(true, c.b_ is B<AA>);
- Expect.equals(true, c.b_.isT(const AA()));
- Expect.equals(true, c.b_.isT(const AX()));
- try {
- E e = new E(); // Throws a type error, if type checks are enabled.
- } catch (TypeError error) {
- result = 1;
- // TODO(regis): The error below is detected too late.
- // It should be reported on line 31, at new B<T>(), i.e. new B<AX>().
- // This will be detected when we check the subtyping constraints.
- Expect.equals("A", error.dstType);
- Expect.equals("AX", error.srcType);
- Expect.equals("a_", error.dstName); // VM specific field.
- int pos = error.url.lastIndexOf("/", error.url.length);
- if (pos == -1) {
- pos = error.url.lastIndexOf("\\", error.url.length);
- }
- String subs = error.url.substring(pos + 1, error.url.length);
- Expect.equals("GenericTest.dart", subs);
- Expect.equals(23, error.line);
- Expect.equals(23, error.column);
- }
- return result;
- }
-
- static testMain() {
- Expect.equals(1, test());
- }
-}
-
-
-main() {
- GenericTest.testMain();
-}
« no previous file with comments | « no previous file | runtime/vm/code_generator.h » ('j') | runtime/vm/code_generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698