OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // VMOptions= | 4 // VMOptions= |
5 // VMOptions=--interpret_irregexp | 5 // VMOptions=--interpret_irregexp |
6 | 6 |
7 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
10 | 10 |
11 var regex0; | 11 var regex0; |
12 var regex; | 12 var regex; |
13 | 13 |
14 void script() { | 14 void script() { |
15 // Check the internal NUL doesn't trip up the name scrubbing in the vm. | 15 // Check the internal NUL doesn't trip up the name scrubbing in the vm. |
16 regex0 = new RegExp("with internal \u{0} NUL"); | 16 regex0 = new RegExp("with internal \u{0} NUL"); |
17 regex = new RegExp(r"(\w+)"); | 17 regex = new RegExp(r"(\w+)"); |
18 String str = "Parse my string"; | 18 String str = "Parse my string"; |
19 Iterable<Match> matches = regex.allMatches(str); // Run to generate bytecode. | 19 Iterable<Match> matches = regex.allMatches(str); // Run to generate bytecode. |
20 expect(matches.length, equals(3)); | 20 expect(matches.length, equals(3)); |
21 } | 21 } |
22 | 22 |
23 var tests = [ | 23 var tests = [ |
| 24 (Isolate isolate) async { |
| 25 Library lib = isolate.rootLibrary; |
| 26 await lib.load(); |
24 | 27 |
25 (Isolate isolate) async { | 28 Field field0 = lib.variables.singleWhere((v) => v.name == 'regex0'); |
26 Library lib = isolate.rootLibrary; | 29 await field0.load(); // No crash due to embedded NUL. |
27 await lib.load(); | |
28 | 30 |
29 Field field0 = lib.variables.singleWhere((v) => v.name == 'regex0'); | 31 Field field = lib.variables.singleWhere((v) => v.name == 'regex'); |
30 await field0.load(); // No crash due to embedded NUL. | 32 await field.load(); |
| 33 Instance regex = field.staticValue; |
| 34 expect(regex.isInstance, isTrue); |
| 35 expect(regex.isRegExp, isTrue); |
| 36 await regex.load(); |
31 | 37 |
32 Field field = lib.variables.singleWhere((v) => v.name == 'regex'); | 38 if (regex.oneByteFunction == null) { |
33 await field.load(); | 39 // Running with interpreted regexp. |
34 Instance regex = field.staticValue; | 40 var b1 = await regex.oneByteBytecode.load(); |
35 expect(regex.isInstance, isTrue); | 41 expect(b1.isTypedData, isTrue); |
36 expect(regex.isRegExp, isTrue); | 42 var b2 = await regex.twoByteBytecode.load(); |
37 await regex.load(); | 43 expect(b2.isTypedData, isFalse); // No two-byte string subject was used. |
38 | 44 } else { |
39 if (regex.oneByteFunction == null) { | 45 // Running with compiled regexp. |
40 // Running with interpreted regexp. | 46 var f1 = await regex.oneByteFunction.load(); |
41 var b1 = await regex.oneByteBytecode.load(); | 47 expect(f1 is ServiceFunction, isTrue); |
42 expect(b1.isTypedData, isTrue); | 48 var f2 = await regex.twoByteFunction.load(); |
43 var b2 = await regex.twoByteBytecode.load(); | 49 expect(f2 is ServiceFunction, isTrue); |
44 expect(b2.isTypedData, isFalse); // No two-byte string subject was used. | 50 var f3 = await regex.externalOneByteFunction.load(); |
45 } else { | 51 expect(f3 is ServiceFunction, isTrue); |
46 // Running with compiled regexp. | 52 var f4 = await regex.externalTwoByteFunction.load(); |
47 var f1 = await regex.oneByteFunction.load(); | 53 expect(f4 is ServiceFunction, isTrue); |
48 expect(f1 is ServiceFunction, isTrue); | 54 } |
49 var f2 = await regex.twoByteFunction.load(); | |
50 expect(f2 is ServiceFunction, isTrue); | |
51 var f3 = await regex.externalOneByteFunction.load(); | |
52 expect(f3 is ServiceFunction, isTrue); | |
53 var f4 = await regex.externalTwoByteFunction.load(); | |
54 expect(f4 is ServiceFunction, isTrue); | |
55 } | 55 } |
56 } | |
57 | |
58 ]; | 56 ]; |
59 | 57 |
60 main(args) => runIsolateTests(args, tests, testeeBefore: script); | 58 main(args) => runIsolateTests(args, tests, testeeBefore: script); |
OLD | NEW |