diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-04-20 07:30:12 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-04-20 07:30:12 +0900 |
| commit | ff765c814d5f91397c4423079ba626e032222c70 (patch) | |
| tree | 3fd03cd793082d0fb37c681d042f9bee1456ad59 /test/t | |
| parent | 2f9ebc6f32571cc462d155eeaf32cdfb263eeba6 (diff) | |
| parent | 4a8b88f7757f71d7d88b89764b533dd5ba59fd44 (diff) | |
| download | mruby-ff765c814d5f91397c4423079ba626e032222c70.tar.gz mruby-ff765c814d5f91397c4423079ba626e032222c70.zip | |
Merge pull request #4390 from shuujii/add-type-check-in-String-aset
Add type check (conversion) in `String#[]=`
Diffstat (limited to 'test/t')
| -rw-r--r-- | test/t/string.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/t/string.rb b/test/t/string.rb index cf3702cbe..404cf03e1 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -161,6 +161,9 @@ assert('String#[]=') do assert_equal 'aXc', e end + assert_raise(TypeError) { 'a'[0] = 1 } + assert_raise(TypeError) { 'a'[:a] = '1' } + # length of args is 2 a1 = 'abc' assert_raise(IndexError) do @@ -197,6 +200,10 @@ assert('String#[]=') do assert_raise(IndexError) do b3['XX'] = 'Y' end + + assert_raise(TypeError) { 'a'[:a, 0] = '1' } + assert_raise(TypeError) { 'a'[0, :a] = '1' } + assert_raise(TypeError) { 'a'[0, 1] = 1 } end assert('String#capitalize', '15.2.10.5.7') do |
