OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 |
| 6 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; |
| 8 |
| 9 import 'test_helper.dart'; |
| 10 |
| 11 class _TestClass { |
| 12 _TestClass(); |
| 13 var x; |
| 14 var y; |
| 15 } |
| 16 |
| 17 class _TestConst { |
| 18 const _TestConst(); |
| 19 } |
| 20 |
| 21 _TopLevelClosure() {} |
| 22 |
| 23 var x; |
| 24 var fn; |
| 25 |
| 26 void warmup() { |
| 27 x = const _TestConst(); |
| 28 fn = _TopLevelClosure; |
| 29 } |
| 30 |
| 31 eval(Isolate isolate, String expression) async { |
| 32 Map params = { |
| 33 'targetId': isolate.rootLibrary.id, |
| 34 'expression': expression, |
| 35 }; |
| 36 return await isolate.invokeRpcNoUpgrade('evaluate', params); |
| 37 } |
| 38 |
| 39 var tests = [ |
| 40 // Expect a simple path through variable x instead of long path filled |
| 41 // with VM objects |
| 42 (Isolate isolate) async { |
| 43 var target1 = await eval(isolate, 'x;'); |
| 44 var params = { |
| 45 'targetId': target1['id'], |
| 46 'limit': 100, |
| 47 }; |
| 48 var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params); |
| 49 expect(result['type'], equals('RetainingPath')); |
| 50 expect(result['elements'].length, equals(2)); |
| 51 expect( |
| 52 result['elements'][0]['value']['class']['name'], equals('_TestConst')); |
| 53 expect(result['elements'][1]['value']['name'], equals('x')); |
| 54 }, |
| 55 |
| 56 // Expect a simple path through variable fn instead of long path filled |
| 57 // with VM objects |
| 58 (Isolate isolate) async { |
| 59 var target2 = await eval(isolate, 'fn;'); |
| 60 var params = { |
| 61 'targetId': target2['id'], |
| 62 'limit': 100, |
| 63 }; |
| 64 var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params); |
| 65 expect(result['type'], equals('RetainingPath')); |
| 66 expect(result['elements'].length, equals(2)); |
| 67 expect(result['elements'][0]['value']['class']['name'], equals('_Closure')); |
| 68 expect(result['elements'][1]['value']['name'], equals('fn')); |
| 69 } |
| 70 ]; |
| 71 |
| 72 main(args) async => runIsolateTests(args, tests, testeeBefore: warmup); |
OLD | NEW |