Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Side by Side Diff: recipes/test/core/strings/finding_regexp_matches_test.dart

Issue 12335109: Strings recipes for the Dart Cookbook (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Made most changes requested my Kathy. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 library finding_regexp_matches;
2
3 import 'package:unittest/unittest.dart';
4
5 void main() {
6 group('finding regExp matches', () {
7 var neverEatingThat = 'Not with a fox, not in a box';
8 var regExp = new RegExp(r'[fb]ox');
9
10 test('using allMatches()', () {
11 List matches = regExp.allMatches(neverEatingThat);
12 expect(matches.map((match) => match.group(0)).toList(), equals(['fox', 'bo x']));
13 // Finding the number of occurences of a subneverEatingThat.
14 expect(matches.length, equals(2));
15 });
16
17 test('using firstMatch()', () {
18 expect(regExp.firstMatch(neverEatingThat).group(0), equals('fox'));
19 });
20
21 test('using neverEatingThatMatch', () {
22 expect(regExp.stringMatch(neverEatingThat), equals('fox'));
23 expect(regExp.stringMatch('I like bagels and lox'), isNull);
24 });
25 });
26 }
27
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698