forked from objectionary/eo-hamcrest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
objectionary#153 - added blank-string matcher
- Loading branch information
Showing
4 changed files
with
145 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
49 changes: 49 additions & 0 deletions
49
src/main/eo/org/eolang/hamcrest/matchers/blank-string-matcher.eo
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,49 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2022 Graur Andrew | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
+alias org.eolang.txt.text | ||
+alias sprintf org.eolang.txt.sprintf | ||
+home https://github.com/objectionary/eo-hamcrest | ||
+package org.eolang.hamcrest.matchers | ||
+rt jvm org.eolang:eo-hamcrest:0.0.0 | ||
+version 0.0.0 | ||
|
||
# Tests if the examined string contains zero or more whitespace characters and nothing else. | ||
[] > blank-string-matcher | ||
|
||
[a] > match | ||
text a > str! | ||
or. > @ | ||
eq. | ||
str | ||
"" | ||
eq. | ||
str | ||
" " | ||
|
||
[act] > describe-mismatch | ||
sprintf > @ | ||
"was <%s>" | ||
act | ||
|
||
[] > description-of | ||
"blank string" > @ |
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,42 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2020-2022 Graur Andrew | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
+alias org.eolang.hamcrest.assert-that | ||
+home https://github.com/objectionary/eo-hamcrest | ||
+junit | ||
+package org.eolang.hamcrest | ||
+version 0.0.0 | ||
|
||
[] > simple-blank-string | ||
assert-that > @ | ||
"" | ||
$.blank-string | ||
"simple-blank-string" | ||
|
||
[] > simple-blank-string-with-space | ||
assert-that > @ | ||
" " | ||
$.is | ||
$.blank-string | ||
"simple-blank-string-with-space" | ||
|
||
|
49 changes: 49 additions & 0 deletions
49
src/test/eo/org/eolang/hamcrest/failed-output/blank-string-failed-output.eo
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,49 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2020-2022 Graur Andrew | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
+alias org.eolang.hamcrest.assert-that | ||
+home https://github.com/objectionary/eo-hamcrest | ||
+junit | ||
+package org.eolang.hamcrest.failed-output | ||
+version 0.0.0 | ||
|
||
[] > simple-blank-string-failed | ||
[] > suggestion | ||
assert-that > @ | ||
"Привет, 世界" | ||
$.blank-string | ||
"simple-blank-string" | ||
assert-that > @ | ||
suggestion | ||
$.equal-to "simple-blank-string\nExpected: blank string\n but: was <Привет, 世界>" | ||
|
||
[] > is-blank-string-failed | ||
[] > suggestion | ||
assert-that > @ | ||
"Привет, 世界" | ||
$.is | ||
$.blank-string | ||
"simple-blank-string" | ||
assert-that > @ | ||
suggestion | ||
$.equal-to "simple-blank-string\nExpected: is blank string\n but: was <Привет, 世界>" | ||
|