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

Side by Side Diff: runtime/observatory/tests/service/weak_properties_test.dart

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (Closed)
Patch Set: Created 3 years, 9 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
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=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 library vm_references_test; 6 library vm_references_test;
7 7
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 import 'package:observatory/service_io.dart'; 9 import 'package:observatory/service_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 import 'test_helper.dart'; 11 import 'test_helper.dart';
12 12
13 class Foo {} 13 class Foo { }
14 14 class Bar { }
15 class Bar {}
16 15
17 var expando; 16 var expando;
18 var key; 17 var key;
19 var value; 18 var value;
20 var weak_property; 19 var weak_property;
21 20
22 void script() { 21 void script() {
23 expando = new Expando('some debug name'); 22 expando = new Expando('some debug name');
24 key = new Foo(); 23 key = new Foo();
25 value = new Bar(); 24 value = new Bar();
26 expando[key] = value; 25 expando[key] = value;
27 26
28 InstanceMirror expandoMirror = reflect(expando); 27 InstanceMirror expandoMirror = reflect(expando);
29 LibraryMirror libcore = expandoMirror.type.owner; 28 LibraryMirror libcore = expandoMirror.type.owner;
30 29
31 var entries = expandoMirror 30 var entries = expandoMirror.getField(MirrorSystem.getSymbol('_data', libcore)) .reflectee;
32 .getField(MirrorSystem.getSymbol('_data', libcore))
33 .reflectee;
34 weak_property = entries.singleWhere((e) => e != null); 31 weak_property = entries.singleWhere((e) => e != null);
35 print(weak_property); 32 print(weak_property);
36 } 33 }
37 34
38 var tests = [ 35 var tests = [
36
39 (Isolate isolate) async { 37 (Isolate isolate) async {
40 var lib = await isolate.rootLibrary.load(); 38 var lib = await isolate.rootLibrary.load();
41 Field keyField = lib.variables.singleWhere((v) => v.name == 'key'); 39 Field keyField = lib.variables.singleWhere((v) => v.name == 'key');
42 await keyField.load(); 40 await keyField.load();
43 Instance key = keyField.staticValue; 41 Instance key = keyField.staticValue;
44 Field valueField = lib.variables.singleWhere((v) => v.name == 'value'); 42 Field valueField = lib.variables.singleWhere((v) => v.name == 'value');
45 await valueField.load(); 43 await valueField.load();
46 Instance value = valueField.staticValue; 44 Instance value = valueField.staticValue;
47 Field propField = 45 Field propField = lib.variables.singleWhere((v) => v.name == 'weak_property' );
48 lib.variables.singleWhere((v) => v.name == 'weak_property');
49 await propField.load(); 46 await propField.load();
50 Instance prop = propField.staticValue; 47 Instance prop = propField.staticValue;
51 48
52 expect(key.isWeakProperty, isFalse); 49 expect(key.isWeakProperty, isFalse);
53 expect(value.isWeakProperty, isFalse); 50 expect(value.isWeakProperty, isFalse);
54 expect(prop.isWeakProperty, isTrue); 51 expect(prop.isWeakProperty, isTrue);
55 expect(prop.key, isNull); 52 expect(prop.key, isNull);
56 expect(prop.value, isNull); 53 expect(prop.value, isNull);
57 Instance loadedProp = await prop.load(); 54 Instance loadedProp = await prop.load();
58 // Object ids are not cannonicalized, so we rely on the key and value 55 // Object ids are not cannonicalized, so we rely on the key and value
59 // being the sole instances of their classes to test we got the objects 56 // being the sole instances of their classes to test we got the objects
60 // we expect. 57 // we expect.
61 expect(loadedProp.key, isNotNull); 58 expect(loadedProp.key, isNotNull);
62 expect(loadedProp.key.clazz, equals(key.clazz)); 59 expect(loadedProp.key.clazz, equals(key.clazz));
63 expect(loadedProp.value, isNotNull); 60 expect(loadedProp.value, isNotNull);
64 expect(loadedProp.value.clazz, equals(value.clazz)); 61 expect(loadedProp.value.clazz, equals(value.clazz));
65 }, 62 },
63
66 ]; 64 ];
67 65
68 main(args) => runIsolateTests(args, tests, testeeBefore: script); 66 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/vm_timeline_flags_test.dart ('k') | runtime/observatory/tests/ui/inspector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698