Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "package:expect/expect.dart"; | |
| 6 | |
| 7 class B { | |
| 8 final z; | |
| 9 B(this.z); | |
| 10 | |
| 11 foo() => this.z; | |
| 12 } | |
| 13 | |
| 14 class A<T> extends B { | |
| 15 var captured, captured2; | |
| 16 var typedList; | |
| 17 | |
| 18 // p must be inside a box (in dart2js). | |
| 19 A(p) : captured = (() => p), super(p++) { | |
| 20 // Make non-inlinable. | |
| 21 try {} catch(e) {} | |
| 22 | |
| 23 captured2 = () => p++; | |
| 24 | |
| 25 // In the current implementation of dart2js makes the generic type an | |
| 26 // argument to the body. | |
| 27 typedList = <T>[]; | |
| 28 } | |
| 29 | |
| 30 foo() => captured(); | |
| 31 bar() => captured2(); | |
| 32 } | |
| 33 | |
| 34 @NoInline() | |
| 35 @AssumeDynamic() | |
| 36 confuse(x) => x; | |
| 37 | |
| 38 main() { | |
| 39 var a = confuse(new A<int>(1)); | |
| 40 var a2 = confuse(new A(2)); | |
| 41 var b = confuse(new B(3)); | |
| 42 Expect.equals(2, a.foo()); | |
| 43 Expect.equals(3, a2.foo()); | |
| 44 Expect.equals(3, b.foo()); | |
|
Johnni Winther
2015/03/02 10:41:52
What is testing?
Shouldn't we (instead) test tha
floitsch
2015/03/02 14:56:52
Added tests against "z".
| |
| 45 Expect.isTrue(a is A<int>); | |
| 46 Expect.isFalse(a is A<String>); | |
| 47 Expect.isTrue(a2 is A<int>); | |
| 48 Expect.isTrue(a2 is A<String>); | |
| 49 Expect.equals(2, a.bar()); | |
| 50 Expect.equals(3, a2.bar()); | |
| 51 Expect.equals(3, a.foo()); | |
| 52 Expect.equals(4, a2.foo()); | |
| 53 Expect.equals(0, a.typedList.length); | |
| 54 Expect.equals(0, a2.typedList.length); | |
| 55 a.typedList.add(499); | |
| 56 Expect.equals(1, a.typedList.length); | |
| 57 Expect.equals(0, a2.typedList.length); | |
| 58 Expect.isTrue(a.typedList is List<int>); | |
| 59 Expect.isTrue(a2.typedList is List<int>); | |
| 60 Expect.isFalse(a.typedList is List<String>); | |
| 61 Expect.isTrue(a2.typedList is List<String>); | |
| 62 } | |
| OLD | NEW |