bbb24d3364
In observatory there are two different ways to do expression evaluation.
One calls `evaluateInFrame` and catches the ServerRpcException thrown
when there's a compilation error. Another calls `evaluate` and does not
catch the ServerRpcException thrown when there's a compilation error.
This means, for instance, if evaluting an expression on an instance
and makes a typo there's suddenly a big box with scrambled javascript
on the top-right of the screen.
This CL:
* Handles the ServerRpcException thrown when there's a compilation error
for `evaluate` as well.
* Makes both `evaluate` and `evaluateInFrame` unpack the `details` sent
by the VM instead of printing out the textual representation of a map.
This means that you get an error message like
```
org-dartlang-debug:synthetic_debug_expression:1:1: Error: Getter not found: 'test'.
test
^^^^
```
instead of
```
{details: org-dartlang-debug:synthetic_debug_expression:1:1: Error: Getter not found: 'test'.
test
^^^^}
```
TEST=Existing test suites.
Change-Id: I2dc3f19f024e918e8d0e9b0f4166a4ef2c6cbd9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186292
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
45 lines
1.5 KiB
Dart
45 lines
1.5 KiB
Dart
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:observatory/service_io.dart';
|
|
import 'package:test/test.dart';
|
|
import 'test_helper.dart';
|
|
|
|
var tests = <IsolateTest>[
|
|
(Isolate isolate) async {
|
|
Library root = await isolate.rootLibrary.load() as Library;
|
|
|
|
Class classLibrary = await root.clazz!.load() as Class;
|
|
print(classLibrary);
|
|
{
|
|
final DartError errorResult =
|
|
await classLibrary.evaluate('3 + 4') as DartError;
|
|
print(errorResult);
|
|
expect(errorResult.toString(), contains('can be evaluated only'));
|
|
}
|
|
|
|
Class classClass = await classLibrary.clazz!.load() as Class;
|
|
print(classClass);
|
|
{
|
|
final DartError errorResult =
|
|
await classClass.evaluate('3 + 4') as DartError;
|
|
print(errorResult);
|
|
expect(errorResult.toString(), contains('can be evaluated only'));
|
|
}
|
|
|
|
Instance someArray =
|
|
await root.evaluate("new List<dynamic>.filled(2, null)") as Instance;
|
|
print(someArray);
|
|
expect(someArray is Instance, isTrue);
|
|
Class classArray = await someArray.clazz!.load() as Class;
|
|
print(classArray);
|
|
dynamic result = await classArray.evaluate('3 + 4');
|
|
print(result);
|
|
expect(result is Instance, isTrue);
|
|
expect(result.valueAsString, equals('7'));
|
|
},
|
|
];
|
|
|
|
main(args) => runIsolateTests(args, tests);
|