OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 |
| 6 import 'dart:async'; |
| 7 import 'dart:developer'; |
| 8 import 'package:observatory/service_io.dart'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 import 'service_test_common.dart'; |
| 11 import 'test_helper.dart'; |
| 12 |
| 13 var thing1; |
| 14 var thing2; |
| 15 |
| 16 testeeMain() { |
| 17 thing1 = 3; |
| 18 thing2 = 4; |
| 19 } |
| 20 |
| 21 var tests = [ |
| 22 (Isolate isolate) async { |
| 23 var lib = await isolate.rootLibrary.load(); |
| 24 var thing1 = |
| 25 (await lib.variables.singleWhere((v) => v.name == "thing1").load()) |
| 26 .staticValue; |
| 27 print(thing1); |
| 28 var thing2 = |
| 29 (await lib.variables.singleWhere((v) => v.name == "thing2").load()) |
| 30 .staticValue; |
| 31 print(thing2); |
| 32 |
| 33 var result = await lib.evaluate("x + y", scope: {"x": thing1, "y": thing2}); |
| 34 expect(result.valueAsString, equals('7')); |
| 35 |
| 36 bool didThrow = false; |
| 37 try { |
| 38 result = await lib.evaluate("x + y", scope: {"x": lib, "y": lib}); |
| 39 print(result); |
| 40 } catch (e) { |
| 41 didThrow = true; |
| 42 expect(e.toString(), |
| 43 contains("Cannot evaluate against a VM-internal object")); |
| 44 } |
| 45 expect(didThrow, isTrue); |
| 46 |
| 47 didThrow = false; |
| 48 try { |
| 49 result = |
| 50 await lib.evaluate("x + y", scope: {"not&an&identifier": thing1}); |
| 51 print(result); |
| 52 } catch (e) { |
| 53 didThrow = true; |
| 54 expect(e.toString(), contains("invalid 'scope' parameter")); |
| 55 } |
| 56 expect(didThrow, isTrue); |
| 57 }, |
| 58 ]; |
| 59 |
| 60 main(args) => runIsolateTests(args, tests, testeeBefore: testeeMain); |
OLD | NEW |