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

Side by Side Diff: runtime/observatory/test/graph_test.dart

Issue 1043513002: Enable strict flags for all service tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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=--compile-all --error_on_bad_type --error_on_bad_override --checked
4 5
5 import 'dart:async'; 6 import 'dart:async';
6 import 'package:observatory/object_graph.dart'; 7 import 'package:observatory/object_graph.dart';
7 import 'package:observatory/service_io.dart'; 8 import 'package:observatory/service_io.dart';
8 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
9 import 'test_helper.dart'; 10 import 'test_helper.dart';
10 11
11 class Foo { 12 class Foo {
12 Object left; 13 Object left;
13 Object right; 14 Object right;
14 } 15 }
15 Foo r; 16 Foo r;
16 17
17 List lst; 18 List lst;
18 19
19 void script() { 20 void script() {
20 // Create 3 instances of Foo, with out-degrees 21 // Create 3 instances of Foo, with out-degrees
21 // 0 (for b), 1 (for a), and 2 (for staticFoo). 22 // 0 (for b), 1 (for a), and 2 (for staticFoo).
22 r = new Foo(); 23 r = new Foo();
23 var a = new Foo(); 24 var a = new Foo();
24 var b = new Foo(); 25 var b = new Foo();
25 r.left = a; 26 r.left = a;
26 r.right = b; 27 r.right = b;
27 a.left = b; 28 a.left = b;
28 29
29 lst = new List(2); 30 lst = new List(2);
30 lst[0] = lst; // Self-loop. 31 lst[0] = lst; // Self-loop.
31 // Larger than any other fixed-size list in a fresh heap. 32 // Larger than any other fixed-size list in a fresh heap.
32 lst[1] = new List(123456); 33 lst[1] = new List(123456);
33 } 34 }
34 35
35 int fooId; 36 int fooId;
36 37
37 var tests = [ 38 var tests = [
38 39
39 (Isolate isolate) { 40 (Isolate isolate) {
40 Completer completer = new Completer(); 41 Completer completer = new Completer();
41 isolate.vm.events.stream.listen((ServiceEvent event) { 42 isolate.vm.events.stream.listen((ServiceEvent event) {
42 if (event.eventType == ServiceEvent.kGraph) { 43 if (event.eventType == ServiceEvent.kGraph) {
43 ReadStream reader = new ReadStream(event.data); 44 ReadStream reader = new ReadStream(event.data);
44 ObjectGraph graph = new ObjectGraph(reader); 45 ObjectGraph graph = new ObjectGraph(reader);
45 expect(fooId, isNotNull); 46 expect(fooId, isNotNull);
46 Iterable<ObjectVertex> foos = graph.vertices.where( 47 Iterable<ObjectVertex> foos = graph.vertices.where(
47 (ObjectVertex obj) => obj.classId == fooId); 48 (ObjectVertex obj) => obj.classId == fooId);
48 expect(foos.length, equals(3)); 49 expect(foos.length, equals(3));
49 expect(foos.where( 50 expect(foos.where(
50 (ObjectVertex obj) => obj.succ.length == 0).length, equals(1)); 51 (ObjectVertex obj) => obj.succ.length == 0).length, equals(1));
51 expect(foos.where( 52 expect(foos.where(
52 (ObjectVertex obj) => obj.succ.length == 1).length, equals(1)); 53 (ObjectVertex obj) => obj.succ.length == 1).length, equals(1));
53 expect(foos.where( 54 expect(foos.where(
54 (ObjectVertex obj) => obj.succ.length == 2).length, equals(1)); 55 (ObjectVertex obj) => obj.succ.length == 2).length, equals(1));
55 56
56 ObjectVertex bVertex = foos.where( 57 ObjectVertex bVertex = foos.where(
57 (ObjectVertex obj) => obj.succ.length == 0).first; 58 (ObjectVertex obj) => obj.succ.length == 0).first;
58 ObjectVertex aVertex = foos.where( 59 ObjectVertex aVertex = foos.where(
59 (ObjectVertex obj) => obj.succ.length == 1).first; 60 (ObjectVertex obj) => obj.succ.length == 1).first;
60 ObjectVertex rVertex = foos.where( 61 ObjectVertex rVertex = foos.where(
61 (ObjectVertex obj) => obj.succ.length == 2).first; 62 (ObjectVertex obj) => obj.succ.length == 2).first;
62 63
63 // TODO(koda): Check actual byte sizes. 64 // TODO(koda): Check actual byte sizes.
64 65
65 expect(aVertex.retainedSize, equals(aVertex.shallowSize)); 66 expect(aVertex.retainedSize, equals(aVertex.shallowSize));
66 expect(bVertex.retainedSize, equals(bVertex.shallowSize)); 67 expect(bVertex.retainedSize, equals(bVertex.shallowSize));
67 expect(rVertex.retainedSize, equals(aVertex.shallowSize + 68 expect(rVertex.retainedSize, equals(aVertex.shallowSize +
68 bVertex.shallowSize + 69 bVertex.shallowSize +
69 rVertex.shallowSize)); 70 rVertex.shallowSize));
70 71
71 const int fixedSizeListCid = 62; 72 const int fixedSizeListCid = 62;
72 List<ObjectVertex> lists = new List.from(graph.vertices.where( 73 List<ObjectVertex> lists = new List.from(graph.vertices.where(
73 (ObjectVertex obj) => obj.classId == fixedSizeListCid)); 74 (ObjectVertex obj) => obj.classId == fixedSizeListCid));
74 expect(lists.length >= 2, isTrue); 75 expect(lists.length >= 2, isTrue);
75 // Order by decreasing retained size. 76 // Order by decreasing retained size.
76 lists.sort((u, v) => v.retainedSize - u.retainedSize); 77 lists.sort((u, v) => v.retainedSize - u.retainedSize);
77 ObjectVertex first = lists[0]; 78 ObjectVertex first = lists[0];
78 ObjectVertex second = lists[1]; 79 ObjectVertex second = lists[1];
79 // Check that the short list retains more than the long list inside. 80 // Check that the short list retains more than the long list inside.
80 expect(first.succ.length, equals(2 + second.succ.length)); 81 expect(first.succ.length, equals(2 + second.succ.length));
81 // ... and specifically, that it retains exactly itself + the long one. 82 // ... and specifically, that it retains exactly itself + the long one.
82 expect(first.retainedSize, 83 expect(first.retainedSize,
83 equals(first.shallowSize + second.shallowSize)); 84 equals(first.shallowSize + second.shallowSize));
84 completer.complete(); 85 completer.complete();
85 } 86 }
86 }); 87 });
87 return isolate.rootLib.load().then((Library lib) { 88 return isolate.rootLib.load().then((Library lib) {
88 expect(lib.classes.length, equals(1)); 89 expect(lib.classes.length, equals(1));
89 Class fooClass = lib.classes.first; 90 Class fooClass = lib.classes.first;
90 fooId = fooClass.vmCid; 91 fooId = fooClass.vmCid;
91 isolate.invokeRpcNoUpgrade('requestHeapSnapshot', {}); 92 isolate.invokeRpcNoUpgrade('requestHeapSnapshot', {});
92 return completer.future; 93 return completer.future;
93 }); 94 });
94 }, 95 },
95 96
96 ]; 97 ];
97 98
98 main(args) => runIsolateTests(args, tests, testeeBefore: script); 99 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698