OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, 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 // VMOptions=--optimization_counter_threshold=100 | |
5 | |
6 // Test field type tracking and field list-length tracking in the presence of | |
7 // multiple isolates. | |
8 | |
9 import "dart:isolate"; | |
10 import "package:expect/expect.dart"; | |
11 | |
12 class A { | |
13 A(this.a); | |
14 var a; | |
15 } | |
16 | |
17 class B extends A { | |
18 B(a, this.b) : super(a) { } | |
19 | |
20 var b; | |
21 } | |
22 | |
23 f1(SendPort send_port) { | |
24 send_port.send(new B("foo", "bar")); | |
25 } | |
26 | |
27 test_b(B obj) => obj.a + obj.b; | |
28 | |
29 test_field_type() { | |
30 var receive_port = new ReceivePort(); | |
31 Future<Isolate> isolate = Isolate.spawn(f1, receive_port.sendPort); | |
32 B b = new B(1, 2); | |
33 for (var i = 0; i < 200; i++) test_b(b); | |
Ivan Posva
2013/11/01 04:50:05
{
test_b(b);
}
Florian Schneider
2013/11/01 10:39:27
Done.
| |
34 Expect.equals(3, test_b(b)); | |
35 Future<B> item = receive_port.first; | |
36 item.then((B value) { | |
37 Expect.equals("foobar", test_b(value)); | |
38 receive_port.close(); | |
39 }); | |
40 } | |
41 | |
42 class C { | |
43 C(this.list); | |
44 final List list; | |
45 } | |
46 | |
47 f2(SendPort send_port) { | |
48 send_port.send(new C(new List(1))); | |
49 } | |
50 | |
51 test_c(C obj) => obj.list[9999]; | |
52 | |
53 test_list_length() { | |
54 var receive_port = new ReceivePort(); | |
55 Future<Isolate> isolate = Isolate.spawn(f2, receive_port.sendPort); | |
56 List list = new List(10000); | |
Ivan Posva
2013/11/01 04:50:05
Where is list being used?
| |
57 C c = new C(new List(10000)); | |
58 for (var i = 0; i < 200; i++) test_c(c); | |
Ivan Posva
2013/11/01 04:50:05
ditto:
{
test_c(c);
}
| |
59 Expect.equals(null, test_c(c)); | |
60 Future<C> item = receive_port.first; | |
61 item.then((C value) { | |
62 Expect.throws(() => test_c(value), (e) => e is RangeError); | |
63 receive_port.close(); | |
64 }); | |
65 } | |
66 | |
67 main() { | |
68 test_field_type(); | |
69 test_list_length(); | |
70 } | |
OLD | NEW |