OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // VMOptions=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
5 | 5 |
| 6 import 'package:observatory/heap_snapshot.dart'; |
6 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
7 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
8 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
9 | 10 |
10 // small example from [Lenguaer & Tarjan 1979] | 11 // small example from [Lenguaer & Tarjan 1979] |
11 class R { var x; var y; var z; } | 12 class R { var x; var y; var z; } |
12 class A { var x; } | 13 class A { var x; } |
13 class B { var x; var y; var z; } | 14 class B { var x; var y; var z; } |
14 class C { var x; var y; } | 15 class C { var x; var y; } |
15 class D { var x; } | 16 class D { var x; } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 g.x = i; g.y = j; | 50 g.x = i; g.y = j; |
50 h.x = e; h.y = k; | 51 h.x = e; h.y = k; |
51 i.x = k; | 52 i.x = k; |
52 j.x = i; | 53 j.x = i; |
53 k.x = i; k.y = r; | 54 k.x = i; k.y = r; |
54 l.x = h; | 55 l.x = h; |
55 } | 56 } |
56 | 57 |
57 var tests = [ | 58 var tests = [ |
58 (Isolate isolate) async { | 59 (Isolate isolate) async { |
59 var rootLib = await isolate.rootLibrary.load(); | 60 final rootLib = await isolate.rootLibrary.load(); |
60 var snapshot = await isolate.fetchHeapSnapshot(false).last; | 61 final raw = await isolate.fetchHeapSnapshot(false).last; |
| 62 final snapshot = new HeapSnapshot(); |
| 63 await snapshot.loadProgress(isolate, raw).last; |
61 | 64 |
62 node(String className) { | 65 node(String className) { |
63 var cls = rootLib.classes.singleWhere((cls) => cls.name == className); | 66 var cls = rootLib.classes.singleWhere((cls) => cls.name == className); |
64 return snapshot.graph.vertices.singleWhere((v) => v.vmCid == cls.vmCid); | 67 return snapshot.graph.vertices.singleWhere((v) => v.vmCid == cls.vmCid); |
65 } | 68 } |
66 | 69 |
67 expect(node('I').dominator, equals(node('R'))); | 70 expect(node('I').dominator, equals(node('R'))); |
68 expect(node('K').dominator, equals(node('R'))); | 71 expect(node('K').dominator, equals(node('R'))); |
69 expect(node('C').dominator, equals(node('R'))); | 72 expect(node('C').dominator, equals(node('R'))); |
70 expect(node('H').dominator, equals(node('R'))); | 73 expect(node('H').dominator, equals(node('R'))); |
71 expect(node('E').dominator, equals(node('R'))); | 74 expect(node('E').dominator, equals(node('R'))); |
72 expect(node('A').dominator, equals(node('R'))); | 75 expect(node('A').dominator, equals(node('R'))); |
73 expect(node('D').dominator, equals(node('R'))); | 76 expect(node('D').dominator, equals(node('R'))); |
74 expect(node('B').dominator, equals(node('R'))); | 77 expect(node('B').dominator, equals(node('R'))); |
75 | 78 |
76 expect(node('F').dominator, equals(node('C'))); | 79 expect(node('F').dominator, equals(node('C'))); |
77 expect(node('G').dominator, equals(node('C'))); | 80 expect(node('G').dominator, equals(node('C'))); |
78 expect(node('J').dominator, equals(node('G'))); | 81 expect(node('J').dominator, equals(node('G'))); |
79 expect(node('L').dominator, equals(node('D'))); | 82 expect(node('L').dominator, equals(node('D'))); |
80 | 83 |
81 expect(node('R'), isNotNull); // The field. | 84 expect(node('R'), isNotNull); // The field. |
82 }, | 85 }, |
83 ]; | 86 ]; |
84 | 87 |
85 main(args) => runIsolateTests(args, tests, testeeBefore: buildGraph); | 88 main(args) => runIsolateTests(args, tests, testeeBefore: buildGraph); |
OLD | NEW |