summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-09-20 17:14:15 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-09-21 00:03:07 +0900
commit68523b4ec4a271134aae34d744582a974558c962 (patch)
treef7fab1be8642000f9bae944ed7ea6d5e804c80ac /mrbgems/mruby-string-ext/test
parentc0ae8a96a1fb658b21428bee174602e9373eef3b (diff)
downloadmruby-68523b4ec4a271134aae34d744582a974558c962.tar.gz
mruby-68523b4ec4a271134aae34d744582a974558c962.zip
Add `String#squeeze` and `#squeeze!`; ref #4086
mruby restriction: `String#squeeze` can take more than 1 pattern arguments in CRuby, in that case, the intersection of patterns will be used to match. But in mruby, it doesn't take multiple patterns.
Diffstat (limited to 'mrbgems/mruby-string-ext/test')
-rw-r--r--mrbgems/mruby-string-ext/test/string.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb
index d50a2b3b4..fd6f83e71 100644
--- a/mrbgems/mruby-string-ext/test/string.rb
+++ b/mrbgems/mruby-string-ext/test/string.rb
@@ -173,6 +173,18 @@ assert('String#tr_s!') do
assert_nil s.tr_s!('l', 'r')
end
+assert('String#squeeze') do
+ assert_equal "yelow mon", "yellow moon".squeeze
+ assert_equal " now is the", " now is the".squeeze(" ")
+ assert_equal "puters shot balls", "putters shoot balls".squeeze("m-z")
+end
+
+assert('String#squeeze!') do
+ s = " now is the"
+ assert_equal " now is the", s.squeeze!(" ")
+ assert_equal " now is the", s
+end
+
assert('String#start_with?') do
assert_true "hello".start_with?("heaven", "hell")
assert_true !"hello".start_with?("heaven", "paradise")