-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] fix some bugs in
nvm_is_natural_num
, add unit tests.
- Loading branch information
Showing
2 changed files
with
28 additions
and
12 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,17 @@ | ||
#!/bin/sh | ||
|
||
die () { echo $@ ; exit 1; } | ||
|
||
. ../../../nvm.sh | ||
|
||
! nvm_is_natural_num || die 'no args is not false' | ||
! nvm_is_natural_num '' || die 'empty string is not false' | ||
! nvm_is_natural_num a || die 'a is not false' | ||
! nvm_is_natural_num -1 || 'negative number is not false' | ||
! nvm_is_natural_num --1 || 'double negative number is not false' | ||
! nvm_is_natural_num 1.2 || 'decimal number is not false' | ||
! nvm_is_natural_num 0 || die 'zero is not false' | ||
|
||
nvm_is_natural_num 1 || die '1 is not true' | ||
nvm_is_natural_num 2 || die '2 is not true' | ||
nvm_is_natural_num 1234 || die '1234 is not true' |