OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Issue 24043. | 4 // Issue 24043. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class EvilMatch implements Match { | 8 class EvilMatch implements Match { |
9 int get start => 100000000; | 9 int get start => 100000000; |
10 int get end => 3; | 10 int get end => 3; |
11 } | 11 } |
12 | 12 |
13 class EvilIterator implements Iterator { | 13 class EvilIterator implements Iterator { |
14 bool moveNext() => true; | 14 bool moveNext() => true; |
15 EvilMatch get current => new EvilMatch(); | 15 EvilMatch get current => new EvilMatch(); |
16 } | 16 } |
17 | 17 |
18 class EvilIterable extends Iterable { | 18 class EvilIterable extends Iterable { |
19 Iterator get iterator => new EvilIterator(); | 19 Iterator get iterator => new EvilIterator(); |
20 } | 20 } |
21 | 21 |
22 class EvilPattern { | 22 class EvilPattern implements Pattern { |
23 Iterable allMatches(String s) => new EvilIterable(); | 23 Iterable allMatches(String s) => new EvilIterable(); |
24 } | 24 } |
25 | 25 |
26 void main() { | 26 void main() { |
27 Expect.throws(() => "foo".split(new EvilPattern())[0].length, | 27 Expect.throws(() => "foo".split(new EvilPattern())[0].length, |
28 (e) => e is RangeError); | 28 (e) => e is RangeError); |
29 } | 29 } |
OLD | NEW |