| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
| 9 import 'dart:developer'; | 9 import 'dart:developer'; |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 print("otherFunction >="); | 27 print("otherFunction >="); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 void testFunction() { | 32 void testFunction() { |
| 33 MyClass.otherFunction(-100); | 33 MyClass.otherFunction(-100); |
| 34 MyClass.myFunction(10000); | 34 MyClass.myFunction(10000); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool allRangesCompiled(coverage) { |
| 38 for (int i = 0; i < coverage['ranges'].length; i++) { |
| 39 if (!coverage['ranges'][i]['compiled']) { |
| 40 return false; |
| 41 } |
| 42 } |
| 43 return true; |
| 44 } |
| 45 |
| 37 var tests = [ | 46 var tests = [ |
| 38 | 47 |
| 39 hasStoppedAtBreakpoint, | 48 hasStoppedAtBreakpoint, |
| 40 | 49 |
| 41 (Isolate isolate) async { | 50 (Isolate isolate) async { |
| 42 var stack = await isolate.getStack(); | 51 var stack = await isolate.getStack(); |
| 43 | 52 |
| 44 // Make sure we are in the right place. | 53 // Make sure we are in the right place. |
| 45 expect(stack.type, equals('Stack')); | 54 expect(stack.type, equals('Stack')); |
| 46 expect(stack['frames'].length, greaterThanOrEqualTo(2)); | 55 expect(stack['frames'].length, greaterThanOrEqualTo(2)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 'endPos': 82, | 66 'endPos': 82, |
| 58 'compiled': true, | 67 'compiled': true, |
| 59 'coverage': {'hits': [48, 66, 76], 'misses': [54]} | 68 'coverage': {'hits': [48, 66, 76], 'misses': [54]} |
| 60 }; | 69 }; |
| 61 | 70 |
| 62 // Full script | 71 // Full script |
| 63 var params = { 'reports' : ['Coverage'], | 72 var params = { 'reports' : ['Coverage'], |
| 64 'scriptId' : func.location.script.id }; | 73 'scriptId' : func.location.script.id }; |
| 65 var coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); | 74 var coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); |
| 66 expect(coverage['type'], equals('SourceReport')); | 75 expect(coverage['type'], equals('SourceReport')); |
| 67 expect(coverage['ranges'].length, 5); | 76 expect(coverage['ranges'].length, 6); |
| 68 expect(coverage['ranges'][0], equals(expectedRange)); | 77 expect(coverage['ranges'][0], equals(expectedRange)); |
| 69 expect(coverage['scripts'].length, 1); | 78 expect(coverage['scripts'].length, 1); |
| 70 expect(coverage['scripts'][0]['uri'], | 79 expect(coverage['scripts'][0]['uri'], |
| 71 endsWith('get_source_report_test.dart')); | 80 endsWith('get_source_report_test.dart')); |
| 81 expect(allRangesCompiled(coverage), isFalse); |
| 82 |
| 83 // Force compilation. |
| 84 params = { 'reports' : ['Coverage'], |
| 85 'scriptId' : func.location.script.id, |
| 86 'forceCompile' : true }; |
| 87 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); |
| 88 expect(coverage['type'], equals('SourceReport')); |
| 89 expect(coverage['ranges'].length, 6); |
| 90 expect(allRangesCompiled(coverage), isTrue); |
| 72 | 91 |
| 73 // One function | 92 // One function |
| 74 params = { 'reports' : ['Coverage'], | 93 params = { 'reports' : ['Coverage'], |
| 75 'scriptId' : func.location.script.id, | 94 'scriptId' : func.location.script.id, |
| 76 'tokenPos' : func.location.tokenPos, | 95 'tokenPos' : func.location.tokenPos, |
| 77 'endTokenPos' : func.location.endTokenPos }; | 96 'endTokenPos' : func.location.endTokenPos }; |
| 78 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); | 97 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); |
| 79 expect(coverage['type'], equals('SourceReport')); | 98 expect(coverage['type'], equals('SourceReport')); |
| 80 expect(coverage['ranges'].length, 1); | 99 expect(coverage['ranges'].length, 1); |
| 81 expect(coverage['ranges'][0], equals(expectedRange)); | 100 expect(coverage['ranges'][0], equals(expectedRange)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 expect(e.message, | 148 expect(e.message, |
| 130 "_getSourceReport: the 'endTokenPos' parameter requires the " | 149 "_getSourceReport: the 'endTokenPos' parameter requires the " |
| 131 "\'scriptId\' parameter"); | 150 "\'scriptId\' parameter"); |
| 132 } | 151 } |
| 133 expect(caughtException, isTrue); | 152 expect(caughtException, isTrue); |
| 134 }, | 153 }, |
| 135 | 154 |
| 136 ]; | 155 ]; |
| 137 | 156 |
| 138 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 157 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
| OLD | NEW |