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 bool noSuchMethod(Invocation im) {} // To appease dartanalyzer. |
11 } | 12 } |
12 | 13 |
13 class EvilIterator implements Iterator { | 14 class EvilIterator implements Iterator { |
14 bool moveNext() => true; | 15 bool moveNext() => true; |
15 EvilMatch get current => new EvilMatch(); | 16 EvilMatch get current => new EvilMatch(); |
16 } | 17 } |
17 | 18 |
18 class EvilIterable extends Iterable { | 19 class EvilIterable extends Iterable { |
19 Iterator get iterator => new EvilIterator(); | 20 Iterator get iterator => new EvilIterator(); |
20 } | 21 } |
21 | 22 |
22 class EvilPattern implements Pattern { | 23 class EvilPattern implements Pattern { |
23 Iterable allMatches(String s) => new EvilIterable(); | 24 Iterable allMatches(String s, [int start=0]) => new EvilIterable(); |
| 25 bool noSuchMethod(Invocation im) {} // To appease dartanalyzer. |
24 } | 26 } |
25 | 27 |
26 void main() { | 28 void main() { |
27 Expect.throws(() => "foo".split(new EvilPattern())[0].length, | 29 Expect.throws(() => "foo".split(new EvilPattern())[0].length, |
28 (e) => e is RangeError); | 30 (e) => e is RangeError); |
29 } | 31 } |
OLD | NEW |