OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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/object_graph.dart'; | 6 import 'package:observatory/object_graph.dart'; |
7 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 (ObjectVertex obj) => obj.successors.length == 2).first; | 64 (ObjectVertex obj) => obj.successors.length == 2).first; |
65 | 65 |
66 // TODO(koda): Check actual byte sizes. | 66 // TODO(koda): Check actual byte sizes. |
67 | 67 |
68 expect(aVertex.retainedSize, equals(aVertex.shallowSize)); | 68 expect(aVertex.retainedSize, equals(aVertex.shallowSize)); |
69 expect(bVertex.retainedSize, equals(bVertex.shallowSize)); | 69 expect(bVertex.retainedSize, equals(bVertex.shallowSize)); |
70 expect(rVertex.retainedSize, equals(aVertex.shallowSize + | 70 expect(rVertex.retainedSize, equals(aVertex.shallowSize + |
71 bVertex.shallowSize + | 71 bVertex.shallowSize + |
72 rVertex.shallowSize)); | 72 rVertex.shallowSize)); |
73 | 73 |
74 const int fixedSizeListCid = 62; | 74 Library corelib = |
| 75 isolate.libraries.singleWhere((lib) => lib.uri == 'dart:core'); |
| 76 await corelib.load(); |
| 77 Class _List = |
| 78 corelib.classes.singleWhere((cls) => cls.vmName.startsWith('_List')); |
| 79 int kArrayCid = _List.vmCid; |
| 80 // startsWith to ignore the private mangling |
75 List<ObjectVertex> lists = new List.from(graph.vertices.where( | 81 List<ObjectVertex> lists = new List.from(graph.vertices.where( |
76 (ObjectVertex obj) => obj.vmCid == fixedSizeListCid)); | 82 (ObjectVertex obj) => obj.vmCid == kArrayCid)); |
77 expect(lists.length >= 2, isTrue); | 83 expect(lists.length >= 2, isTrue); |
78 // Order by decreasing retained size. | 84 // Order by decreasing retained size. |
79 lists.sort((u, v) => v.retainedSize - u.retainedSize); | 85 lists.sort((u, v) => v.retainedSize - u.retainedSize); |
80 ObjectVertex first = lists[0]; | 86 ObjectVertex first = lists[0]; |
81 ObjectVertex second = lists[1]; | 87 ObjectVertex second = lists[1]; |
82 // Check that the short list retains more than the long list inside. | 88 // Check that the short list retains more than the long list inside. |
83 expect(first.successors.length, | 89 expect(first.successors.length, |
84 equals(2 + second.successors.length)); | 90 equals(2 + second.successors.length)); |
85 // ... and specifically, that it retains exactly itself + the long one. | 91 // ... and specifically, that it retains exactly itself + the long one. |
86 expect(first.retainedSize, | 92 expect(first.retainedSize, |
87 equals(first.shallowSize + second.shallowSize)); | 93 equals(first.shallowSize + second.shallowSize)); |
88 }, | 94 }, |
89 | 95 |
90 ]; | 96 ]; |
91 | 97 |
92 main(args) => runIsolateTests(args, tests, testeeBefore: script); | 98 main(args) => runIsolateTests(args, tests, testeeBefore: script); |
OLD | NEW |