-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Beeger
committed
Mar 28, 2012
1 parent
2a1a9ef
commit 146181e
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
StartWithMatcher startWith(var expected) => new StartWithMatcher(expected); | ||
ContainSubstringMatcher containSubstring(var expected) => new ContainSubstringMatcher(expected); | ||
|
||
class StartWithMatcher implements Matcher { | ||
final expected; | ||
const StartWithMatcher(this.expected); | ||
|
||
matches(var actual) { | ||
return (actual.startsWith(expected)); | ||
} | ||
|
||
String describeExpectation(var actual) { | ||
return 'actual "$actual" to start with the expected "$expected"'; | ||
} | ||
} | ||
|
||
class ContainSubstringMatcher implements Matcher { | ||
final expected; | ||
const ContainSubstringMatcher(this.expected); | ||
|
||
matches(var actual) { | ||
return (actual.contains(expected)); | ||
} | ||
|
||
String describeExpectation(var actual) { | ||
return 'actual "$actual" to contain the expected "$expected"'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
stringMatchersTests() { | ||
describe('startWith matcher', () { | ||
it('should succeed if the actual string starts with the expected string', () => expect('hallo').to(startWith('ha'))); | ||
it('should fail if the actual string does not start with the expected string', () => expect('hallo').to(not(startWith('test')))); | ||
}); | ||
describe('containSubstring matcher', () { | ||
it('should succeed if the actual string starts with the expected string', () => expect('hallo').to(containSubstring('ha'))); | ||
it('should succeed if the actual string contains the expected string', () => expect('hallo').to(containSubstring('al'))); | ||
it('should fail if the actual string does not contain the expected string', () => expect('hallo').to(not(containSubstring('test')))); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters