| OLD | NEW | 
|---|
| 1 // Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file | 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 | 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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked | 
| 5 | 5 | 
| 6 library call_site_data_test; | 6 library call_site_data_test; | 
| 7 | 7 | 
| 8 import 'package:observatory/service_io.dart'; | 8 import 'package:observatory/service_io.dart'; | 
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; | 
| 10 import 'test_helper.dart'; | 10 import 'test_helper.dart'; | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 82   return callSite['cacheEntries'].map((entry) { | 82   return callSite['cacheEntries'].map((entry) { | 
| 83     return "${entry['receiverContainer']['name']}:${entry['count']}"; | 83     return "${entry['receiverContainer']['name']}:${entry['count']}"; | 
| 84   }).toSet(); | 84   }).toSet(); | 
| 85 } | 85 } | 
| 86 | 86 | 
| 87 | 87 | 
| 88 testMonomorphic(Isolate isolate) async { | 88 testMonomorphic(Isolate isolate) async { | 
| 89   Library lib = await isolate.rootLib.load(); | 89   Library lib = await isolate.rootLib.load(); | 
| 90   ServiceFunction func = | 90   ServiceFunction func = | 
| 91      lib.functions.singleWhere((f) => f.name == 'monomorphic'); | 91      lib.functions.singleWhere((f) => f.name == 'monomorphic'); | 
| 92   Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData', | 92   Map response = await isolate.invokeRpcNoUpgrade('_getCallSiteData', | 
| 93                                                   { 'targetId': func.id }); | 93                                                   { 'targetId': func.id }); | 
| 94   expect(response['type'], equals('CodeCoverage')); | 94   expect(response['type'], equals('CodeCoverage')); | 
| 95   Map callSite = response['coverage'].single['callSites'].single; | 95   Map callSite = response['coverage'].single['callSites'].single; | 
| 96   expect(callSite['name'], equals('foo')); | 96   expect(callSite['name'], equals('foo')); | 
| 97   expect(stringifyCacheEntries(callSite), | 97   expect(stringifyCacheEntries(callSite), | 
| 98          equals(['A:10'].toSet())); | 98          equals(['A:10'].toSet())); | 
| 99 } | 99 } | 
| 100 | 100 | 
| 101 testPolymorphic(Isolate isolate) async { | 101 testPolymorphic(Isolate isolate) async { | 
| 102   Library lib = await isolate.rootLib.load(); | 102   Library lib = await isolate.rootLib.load(); | 
| 103   ServiceFunction func = | 103   ServiceFunction func = | 
| 104      lib.functions.singleWhere((f) => f.name == 'polymorphic'); | 104      lib.functions.singleWhere((f) => f.name == 'polymorphic'); | 
| 105   Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData', | 105   Map response = await isolate.invokeRpcNoUpgrade('_getCallSiteData', | 
| 106                                                   { 'targetId': func.id }); | 106                                                   { 'targetId': func.id }); | 
| 107   expect(response['type'], equals('CodeCoverage')); | 107   expect(response['type'], equals('CodeCoverage')); | 
| 108   Map callSite = response['coverage'].single['callSites'].single; | 108   Map callSite = response['coverage'].single['callSites'].single; | 
| 109   expect(callSite['name'], equals('foo')); | 109   expect(callSite['name'], equals('foo')); | 
| 110   expect(stringifyCacheEntries(callSite), | 110   expect(stringifyCacheEntries(callSite), | 
| 111          equals(['A:10', 'B:20', 'C:30'].toSet())); | 111          equals(['A:10', 'B:20', 'C:30'].toSet())); | 
| 112 } | 112 } | 
| 113 | 113 | 
| 114 testMegamorphic(Isolate isolate) async { | 114 testMegamorphic(Isolate isolate) async { | 
| 115   Library lib = await isolate.rootLib.load(); | 115   Library lib = await isolate.rootLib.load(); | 
| 116   ServiceFunction func = | 116   ServiceFunction func = | 
| 117      lib.functions.singleWhere((f) => f.name == 'megamorphic'); | 117      lib.functions.singleWhere((f) => f.name == 'megamorphic'); | 
| 118   Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData', | 118   Map response = await isolate.invokeRpcNoUpgrade('_getCallSiteData', | 
| 119                                                   { 'targetId': func.id }); | 119                                                   { 'targetId': func.id }); | 
| 120   expect(response['type'], equals('CodeCoverage')); | 120   expect(response['type'], equals('CodeCoverage')); | 
| 121   Map callSite = response['coverage'].single['callSites'].single; | 121   Map callSite = response['coverage'].single['callSites'].single; | 
| 122   expect(callSite['name'], equals('foo')); | 122   expect(callSite['name'], equals('foo')); | 
| 123   expect(stringifyCacheEntries(callSite), | 123   expect(stringifyCacheEntries(callSite), | 
| 124          equals(['A:10', 'B:20', 'C:30', 'D:40', | 124          equals(['A:10', 'B:20', 'C:30', 'D:40', | 
| 125                  'E:50', 'F:60', 'G:70', 'H:80'].toSet())); | 125                  'E:50', 'F:60', 'G:70', 'H:80'].toSet())); | 
| 126 } | 126 } | 
| 127 | 127 | 
| 128 testStaticCall(Isolate isolate) async { | 128 testStaticCall(Isolate isolate) async { | 
| 129   Library lib = await isolate.rootLib.load(); | 129   Library lib = await isolate.rootLib.load(); | 
| 130   ServiceFunction func = | 130   ServiceFunction func = | 
| 131      lib.functions.singleWhere((f) => f.name == 'staticCall'); | 131      lib.functions.singleWhere((f) => f.name == 'staticCall'); | 
| 132   Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData', | 132   Map response = await isolate.invokeRpcNoUpgrade('_getCallSiteData', | 
| 133                                                   { 'targetId': func.id }); | 133                                                   { 'targetId': func.id }); | 
| 134   expect(response['type'], equals('CodeCoverage')); | 134   expect(response['type'], equals('CodeCoverage')); | 
| 135   Map callSite = response['coverage'].single['callSites'].single; | 135   Map callSite = response['coverage'].single['callSites'].single; | 
| 136   expect(callSite['name'], equals('staticMethod')); | 136   expect(callSite['name'], equals('staticMethod')); | 
| 137   expect(stringifyCacheEntries(callSite), | 137   expect(stringifyCacheEntries(callSite), | 
| 138          equals(['Static:10'].toSet())); | 138          equals(['Static:10'].toSet())); | 
| 139 } | 139 } | 
| 140 | 140 | 
| 141 testConstructorCall(Isolate isolate) async { | 141 testConstructorCall(Isolate isolate) async { | 
| 142   Library lib = await isolate.rootLib.load(); | 142   Library lib = await isolate.rootLib.load(); | 
| 143   ServiceFunction func = | 143   ServiceFunction func = | 
| 144      lib.functions.singleWhere((f) => f.name == 'constructorCall'); | 144      lib.functions.singleWhere((f) => f.name == 'constructorCall'); | 
| 145   Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData', | 145   Map response = await isolate.invokeRpcNoUpgrade('_getCallSiteData', | 
| 146                                                   { 'targetId': func.id }); | 146                                                   { 'targetId': func.id }); | 
| 147   expect(response['type'], equals('CodeCoverage')); | 147   expect(response['type'], equals('CodeCoverage')); | 
| 148   Map callSite = response['coverage'].single['callSites'].single; | 148   Map callSite = response['coverage'].single['callSites'].single; | 
| 149   expect(callSite['name'], equals('Static.')); | 149   expect(callSite['name'], equals('Static.')); | 
| 150   expect(stringifyCacheEntries(callSite), | 150   expect(stringifyCacheEntries(callSite), | 
| 151          equals(['Static:10'].toSet())); | 151          equals(['Static:10'].toSet())); | 
| 152 } | 152 } | 
| 153 | 153 | 
| 154 testTopLevelCall(Isolate isolate) async { | 154 testTopLevelCall(Isolate isolate) async { | 
| 155   Library lib = await isolate.rootLib.load(); | 155   Library lib = await isolate.rootLib.load(); | 
| 156   ServiceFunction func = | 156   ServiceFunction func = | 
| 157      lib.functions.singleWhere((f) => f.name == 'topLevelCall'); | 157      lib.functions.singleWhere((f) => f.name == 'topLevelCall'); | 
| 158   Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData', | 158   Map response = await isolate.invokeRpcNoUpgrade('_getCallSiteData', | 
| 159                                                   { 'targetId': func.id }); | 159                                                   { 'targetId': func.id }); | 
| 160   expect(response['type'], equals('CodeCoverage')); | 160   expect(response['type'], equals('CodeCoverage')); | 
| 161   Map callSite = response['coverage'].single['callSites'].single; | 161   Map callSite = response['coverage'].single['callSites'].single; | 
| 162   expect(callSite['name'], equals('topLevelMethod')); | 162   expect(callSite['name'], equals('topLevelMethod')); | 
| 163   expect(stringifyCacheEntries(callSite), | 163   expect(stringifyCacheEntries(callSite), | 
| 164          equals(['call_site_data_test:10'].toSet())); | 164          equals(['call_site_data_test:10'].toSet())); | 
| 165 } | 165 } | 
| 166 | 166 | 
| 167 testSuperCall(Isolate isolate) async { | 167 testSuperCall(Isolate isolate) async { | 
| 168   Library lib = await isolate.rootLib.load(); | 168   Library lib = await isolate.rootLib.load(); | 
| 169   Class cls = await lib.classes.singleWhere((f) => f.name == 'Sub').load(); | 169   Class cls = await lib.classes.singleWhere((f) => f.name == 'Sub').load(); | 
| 170   ServiceFunction func = cls.functions.singleWhere((f) => f.name == 'bar'); | 170   ServiceFunction func = cls.functions.singleWhere((f) => f.name == 'bar'); | 
| 171   Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData', | 171   Map response = await isolate.invokeRpcNoUpgrade('_getCallSiteData', | 
| 172                                                   { 'targetId': func.id }); | 172                                                   { 'targetId': func.id }); | 
| 173   expect(response['type'], equals('CodeCoverage')); | 173   expect(response['type'], equals('CodeCoverage')); | 
| 174   Map callSite = response['coverage'].single['callSites'].single; | 174   Map callSite = response['coverage'].single['callSites'].single; | 
| 175   expect(callSite['name'], equals('bar')); | 175   expect(callSite['name'], equals('bar')); | 
| 176   expect(stringifyCacheEntries(callSite), | 176   expect(stringifyCacheEntries(callSite), | 
| 177          equals(['Super:15'].toSet())); | 177          equals(['Super:15'].toSet())); | 
| 178 } | 178 } | 
| 179 | 179 | 
| 180 var tests = [ | 180 var tests = [ | 
| 181     testMonomorphic, | 181     testMonomorphic, | 
| 182     testPolymorphic, | 182     testPolymorphic, | 
| 183     testMegamorphic, | 183     testMegamorphic, | 
| 184     testStaticCall, | 184     testStaticCall, | 
| 185     testConstructorCall, | 185     testConstructorCall, | 
| 186     testTopLevelCall, | 186     testTopLevelCall, | 
| 187     testSuperCall ]; | 187     testSuperCall ]; | 
| 188 | 188 | 
| 189 main(args) => runIsolateTests(args, tests, testeeBefore: script); | 189 main(args) => runIsolateTests(args, tests, testeeBefore: script); | 
| OLD | NEW | 
|---|