[observatory] Fix _guardLength serialization to output a string, rather than an int.

Change-Id: I12e3505649ebe9bb72f479dc7e2fc2dd19226ed7
Reviewed-on: https://dart-review.googlesource.com/68802
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Alexander Aprelev 2018-08-07 22:58:36 +00:00
parent 1f4449658d
commit 6bdf3b7ed6
2 changed files with 23 additions and 1 deletions

View file

@ -14,6 +14,7 @@ import 'test_helper.dart';
class _DummyClass {
static var dummyVar = 11;
final List<String> dummyList = new List<String>(20);
void dummyFunction() {}
}
@ -884,6 +885,27 @@ var tests = <IsolateTest>[
expect(result['_guardLength'], isNotNull);
},
// field
(Isolate isolate) async {
// Call eval to get a class id.
var evalResult = await eval(isolate, 'new _DummyClass()');
var id = "${evalResult['class']['id']}/fields/dummyList";
var params = {
'objectId': id,
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Field'));
expect(result['id'], equals(id));
expect(result['name'], equals('dummyList'));
expect(result['const'], equals(false));
expect(result['static'], equals(false));
expect(result['final'], equals(true));
expect(result['location']['type'], equals('SourceLocation'));
expect(result['_guardNullable'], isNotNull);
expect(result['_guardClass'], isNotNull);
expect(result['_guardLength'], equals('20'));
},
// invalid field.
(Isolate isolate) async {
// Call eval to get a class id.

View file

@ -394,7 +394,7 @@ void Field::PrintJSONImpl(JSONStream* stream, bool ref) const {
} else if (guarded_list_length() == kNoFixedLength) {
jsobj.AddProperty("_guardLength", "variable");
} else {
jsobj.AddProperty("_guardLength", guarded_list_length());
jsobj.AddPropertyF("_guardLength", "%" Pd, guarded_list_length());
}
const class Script& script = Script::Handle(Script());
if (!script.IsNull()) {