Files
sdk/runtime/observatory/tests/service/eval_internal_class_test.dart
T
Alexander Aprelev 4c9689c1d2 [vm] Support pluggable expression compiler for evaluate service api call.
This is follow-up to https://dart-review.googlesource.com/c/sdk/+/57520, which added expression compiler support for EvaluateInFrame

Bug: dartbug.com/31981
Change-Id: I19e6b654698d5b032a276c9cb3634324f4f1ad37
Reviewed-on: https://dart-review.googlesource.com/58660
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-06-18 15:50:02 +00:00

54 lines
1.6 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:unittest/unittest.dart';
import 'test_helper.dart';
var tests = <IsolateTest>[
(Isolate isolate) async {
Library root = await isolate.rootLibrary.load();
Class classLibrary = await root.clazz.load();
print(classLibrary);
{
bool caughtExceptions = false;
try {
dynamic result = await classLibrary.evaluate('3 + 4');
print(result);
} on ServerRpcException catch (e) {
expect(e.toString(), contains('can be evaluated only'));
caughtExceptions = true;
}
expect(caughtExceptions, isTrue);
}
Class classClass = await classLibrary.clazz.load();
print(classClass);
{
bool caughtExceptions = false;
try {
dynamic result = await classClass.evaluate('3 + 4');
print(result);
} on ServerRpcException catch (e) {
expect(e.toString(), contains('can be evaluated only'));
caughtExceptions = true;
}
expect(caughtExceptions, isTrue);
}
Instance someArray = await root.evaluate("new List(2)");
print(someArray);
expect(someArray is Instance, isTrue);
Class classArray = await someArray.clazz.load();
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);