diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-02-10 21:20:26 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-02-10 21:20:26 +0900 |
| commit | 0dc26f52a0a5da95c3c44c43fda1edb51226ac2e (patch) | |
| tree | d8d5fbeeecb1af277c3060074619ec9d7c4229fd /mrbgems/mruby-string-ext/test | |
| parent | d0ecf862d9d2e7aed461bc9360686449f56c5d25 (diff) | |
| parent | 981105b3e6758455646e9834b1c2695bf774a401 (diff) | |
| download | mruby-0dc26f52a0a5da95c3c44c43fda1edb51226ac2e.tar.gz mruby-0dc26f52a0a5da95c3c44c43fda1edb51226ac2e.zip | |
Merge pull request #3447 from dabroz/fix-ljust
String#ljust and String#rjust reimplementation (fix #3445)
Diffstat (limited to 'mrbgems/mruby-string-ext/test')
| -rw-r--r-- | mrbgems/mruby-string-ext/test/string.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb index 228a236af..2b2c02b8b 100644 --- a/mrbgems/mruby-string-ext/test/string.rb +++ b/mrbgems/mruby-string-ext/test/string.rb @@ -444,6 +444,26 @@ assert('String#rjust') do assert_equal "hello", "hello".rjust(-3) end +assert('String#ljust should not change string') do + a = "hello" + a.ljust(20) + assert_equal "hello", a +end + +assert('String#rjust should not change string') do + a = "hello" + a.rjust(20) + assert_equal "hello", a +end + +assert('String#ljust should raise on zero width padding') do + assert_raise(ArgumentError) { "foo".ljust(10, '') } +end + +assert('String#rjust should raise on zero width padding') do + assert_raise(ArgumentError) { "foo".rjust(10, '') } +end + assert('String#upto') do a = "aa" start = "aa" |
