blob: 1e88bdd5146a0a68378693b4a6ff2262bceba5e3 [file] [log] [blame]
// Copyright (c) 2017, 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_2/service_io.dart';
import 'package:test/test.dart';
import 'test_helper.dart';
var thing1;
var thing2;
testeeMain() {
thing1 = 3;
thing2 = 4;
var tests = <IsolateTest>[
(Isolate isolate) async {
Library lib = await isolate.rootLibrary.load();
Field thing1Field =
await lib.variables.singleWhere((v) => == "thing1").load();
var thing1 = thing1Field.staticValue;
Field thing2Field =
await lib.variables.singleWhere((v) => == "thing2").load();
var thing2 = thing2Field.staticValue;
Instance result = await lib.evaluate("x + y",
scope: <String, ServiceObject>{"x": thing1, "y": thing2});
expect(result.valueAsString, equals('7'));
DartError errorResult = await lib
.evaluate("x + y", scope: <String, ServiceObject>{"x": lib, "y": lib});
contains("Cannot evaluate against a VM-internal object"));
errorResult = await lib.evaluate("x + y",
scope: <String, ServiceObject>{"not&an&identifier": thing1});
expect(errorResult.toString(), contains("invalid 'scope' parameter"));
main(args) => runIsolateTests(args, tests, testeeBefore: testeeMain);