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