OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 4 |
5 import 'package:test/test.dart'; | 5 import 'package:test/test.dart'; |
6 import 'package:source_span/src/utils.dart'; | 6 import 'package:source_span/src/utils.dart'; |
7 | 7 |
8 main() { | 8 main() { |
9 group('find line start', () { | 9 group('find line start', () { |
10 test('skip entries in wrong column', () { | 10 test('skip entries in wrong column', () { |
(...skipping 27 matching lines...) Expand all Loading... |
38 expect(index, 0); | 38 expect(index, 0); |
39 }); | 39 }); |
40 | 40 |
41 test('not found', () { | 41 test('not found', () { |
42 var context = '0\n2\n45\n'; | 42 var context = '0\n2\n45\n'; |
43 var index = findLineStart(context, '0', 1); | 43 var index = findLineStart(context, '0', 1); |
44 expect(index, isNull); | 44 expect(index, isNull); |
45 }); | 45 }); |
46 }); | 46 }); |
47 } | 47 } |
48 | |
49 _linearSearch(list, predicate) { | |
50 if (list.length == 0) return -1; | |
51 for (int i = 0; i < list.length; i++) { | |
52 if (predicate(list[i])) return i; | |
53 } | |
54 return list.length; | |
55 } | |
OLD | NEW |