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

Side by Side Diff: recipes/test/core/strings/substituting_strings_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 substituting_strings_test;
2
3 import 'package:unittest/unittest.dart';
4
5 void main() {
6 group('substituting strings based on regExp matches', () {
7 test('using replaceAll()', () {
8 expect('resume'.replaceAll(new RegExp(r'e'), '\u00E9'), equals('résumé'));
9 });
10
11 test('using replaceFirst()', () {
12 expect('0.0001'.replaceFirst(new RegExp(r'0+'), ''), equals('.0001'));
13 });
14
15 test('using replaceAllMapped()', () {
16 var heart = '\u2661';
17 var string = "I like Ike but I $heart Lucy";
18 var regExp = new RegExp(r'[A-Z]\w+');
19 expect(string.replaceAllMapped(
20 regExp, (match) => match.group(0).toUpperCase()),
21 equals('I like IKE but I ♡ LUCY'));
22 });
23
24 });
25 }
OLDNEW
« no previous file with comments | « recipes/test/core/strings/subscripting_a_string_test.dart ('k') | recipes/test/core/strings/using_raw_strings_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698