summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/test/string.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-09-20 18:05:26 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-09-21 00:03:07 +0900
commit346f154ece3bd68b63dfee4b4c4d9a20c0eee063 (patch)
tree2e1e9bc61fdf07b443026d443112baa427ecea3a /mrbgems/mruby-string-ext/test/string.rb
parent58f7f2361a39ae288c4233ca434e1dbd37f127d0 (diff)
downloadmruby-346f154ece3bd68b63dfee4b4c4d9a20c0eee063.tar.gz
mruby-346f154ece3bd68b63dfee4b4c4d9a20c0eee063.zip
Implement `String#delete` and `#delete!`; ref #4086
mruby restriction: In mruby, `String#delete` only takes single pattern argument.
Diffstat (limited to 'mrbgems/mruby-string-ext/test/string.rb')
-rw-r--r--mrbgems/mruby-string-ext/test/string.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb
index 3e9ab5b1b..36a253989 100644
--- a/mrbgems/mruby-string-ext/test/string.rb
+++ b/mrbgems/mruby-string-ext/test/string.rb
@@ -194,6 +194,20 @@ assert('String#squeeze!') do
assert_equal " now is the", s
end
+assert('String#delete') do
+ assert_equal "he", "hello".delete("lo")
+ assert_equal "hll", "hello".delete("aeiou")
+ assert_equal "ll", "hello".delete("^l")
+ assert_equal "ho", "hello".delete("ej-m")
+end
+
+assert('String#delete!') do
+ s = "hello"
+ assert_equal "he", s.delete!("lo")
+ assert_equal "he", s
+ assert_nil s.delete!("lz")
+end
+
assert('String#start_with?') do
assert_true "hello".start_with?("heaven", "hell")
assert_true !"hello".start_with?("heaven", "paradise")