summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/test/string.rb
AgeCommit message (Collapse)Author
2019-10-10Integrate `mrb_str_inspect` and `mrb_str_dump`KOBAYASHI Shuji
2019-09-11Move tests related to `getbyte`, `setbyte`, byteslice` to core.Yukihiro "Matz" Matsumoto
2019-09-11Drop test dependency from `mruby-string-ext` to `mruby-enumerator`KOBAYASHI Shuji
2019-07-23Add encoding argument to `Integral#chr`KOBAYASHI Shuji
Currently, `Integral#chr` in mruby changes behavior by `MRB_UTF8_STRING` setting. before this patch: $ bin/mruby -e 'p 171.chr' #=> "\xab" (`MRB_UTF8_STRING` is disabled) $ bin/mruby -e 'p 171.chr' #=> "«" (`MRB_UTF8_STRING` is enabled) This behavior is incompatible with Ruby, and a little inconvenient because it can't be interpreted as ASCII-8BIT with `MRB_UTF8_STRING`, I think. So add encoding argument according to Ruby. after this patch: $ bin/mruby -e 'p 171.chr' #=> "\xab" $ bin/mruby -e 'p 171.chr("ASCII-8BIT")' #=> "\xab" $ bin/mruby -e 'p 171.chr("UTF-8")' #=> "«" Allow only `String` for encoding because mruby doesn't have `Encoding` class, and `"ASCII-8BIT"` (`"BINARY"`) and `"UTF-8"` (only with `MRB_UTF8_STRING`) are valid value (default is `"ASCII-8BIT"`).
2019-07-19Refine `String#chr` test and separate `Fixnum#chr` testKOBAYASHI Shuji
2019-06-28Use `__ENCODING__` in testsKOBAYASHI Shuji
It cannot be used for `String#size` test if judging whether or not `MRB_UTF8_STRING` is defined by result of `String#size`.
2019-06-25Fix `String#byteslice` with `MRB_UTF8_STRING` and some edge casesKOBAYASHI Shuji
Example: $ bin/mruby -e ' p "あa".byteslice(1) p "bar".byteslice(3) p "bar".byteslice(4..0) ' Before this patch: "a" "" RangeError (4..0 out of range) After this patch (same as Ruby): "\x81" nil nil
2019-04-27Remove duplicated `String#each_char`KOBAYASHI Shuji
2019-03-12Fix missing assertions in `mruby-string-ext` testKOBAYASHI Shuji
2018-11-19Removed `String#try_convert` method from `mruby-string-ext` gem.Yukihiro "Matz" Matsumoto
Because `try_convert` method rarely used in production. For mruby users, we have `__to_str` utility method to check string type.
2018-11-19Remove implicit conversion using `to_str` method; fix #3854Yukihiro "Matz" Matsumoto
We have added internal convenience method `__to_str` which does string type check. The issue #3854 was fixed but fundamental flaw of lack of stack depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA` for workaround.
2018-11-19Remove implicit conversion using `to_int` method.Yukihiro "Matz" Matsumoto
The ISO standard does not include implicit type conversion using `to_int`. This implicit conversion often causes vulnerability. There will be no more attacks like #4120. In addition, we have added internal convenience method `__to_int` which does type check and conversion (from floats).
2018-11-02Add tests for empty patterns for `tr` and `count`; #4156 #4157Yukihiro "Matz" Matsumoto
2018-09-21Implement `String#delete` and `#delete!`; ref #4086Yukihiro "Matz" Matsumoto
mruby restriction: In mruby, `String#delete` only takes single pattern argument.
2018-09-21Implement `String#count`; ref #4086Yukihiro "Matz" Matsumoto
mruby restriction: In mruby, `String#count` does not take multiple pattern arguments, but only one pattern.
2018-09-21Add `String#squeeze` and `#squeeze!`; ref #4086Yukihiro "Matz" Matsumoto
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.
2018-09-21Add `String#tr_s` and `String#tr_s!`; ref #4086Yukihiro "Matz" Matsumoto
2018-09-21Add `String#tr` and `#tr!` to `mruby-string-ext` gem; fix #4086Yukihiro "Matz" Matsumoto
This patch is based on `mruby/c` implementation by Hirohito Higashi. We might need to add `#tr_s`, `#squeeze` and `#delete` as well. Adding them should not be too hard using functions we implemented here.
2017-10-17Add `String#delete_{prefix,suffix}`; CRuby2.5Yukihiro "Matz" Matsumoto
2017-06-14Reimplement String#uptoksss
2017-05-21String#concat: Try to convert when not stringksss
2017-02-11Remove historical comment; ref #3450 #3448Yukihiro "Matz" Matsumoto
2017-02-11remove skip that shouldn't be necessary anymore.robert
the test should pass after https://github.com/mruby/mruby/commit/8f4a929e1a01c8d6176fb53a9ef5dff6de632959.
2017-02-10Tests for UTF-8 String#ljust and String#rjustTomasz Dabrowski
2017-02-10String#ljust and String#rjust reimplementation (fix #3445)Tomasz Dabrowski
- String#ljust and String#rjust are now C functions to improve performance - infinite loop because of an empty padding argument is now prevented (ArgumentError is raised) - extra tests for ljust/rjust added
2016-11-24Read length after args in String#setbyteCraig Lehmann
Prevents RCE Reported by https://hackerone.com/raydot
2016-08-17Fix String#ord failure which return a negative valueHiroshi Mimaki
2016-07-14String#insert should be destructiveksss
2016-01-30Add String#rjust test to mruby-string-extAkira Moroo
2015-11-24add {Array|Hash|String}.try_converttakahashim
2015-09-24UTF-8 string support in coreYukihiro "Matz" Matsumoto
define MRB_UTF8_STRING (in mrbconf.h) to enable UTF-8 support.
2015-08-05add String#setbyte and String#byteslice to mruby-string-extYukihiro "Matz" Matsumoto
2015-01-13Add String#uptoJun Hiroe
2015-01-12add String#ljust into mruby-string-exttakahashim
2014-12-17Add String#prependJun Hiroe
2014-12-13Add String#insertJun Hiroe
2014-08-11"-a-a-".succ should be "-a-b-"mattn
2014-08-11Fix String#succ. "-a-".succ should be "-b-"mattn
2014-08-11Fix String#succ. "-".succ should be "."mattn
2014-08-08remove test for succ on Unicode (non-ASCII) char; #2520Yukihiro "Matz" Matsumoto
2014-08-08Add String#succ, String#succ!, String#next, String#next!mattn
2014-06-19Modify return value of String#slice! if idx == self.sizeAkito Mochizuki
2014-06-15Implement String#slice_bangJun Hiroe
2014-06-07move String#clear to mruby-string-ext; ref #2370Yukihiro "Matz" Matsumoto
2014-06-07remove UTF-8 strings from mruby-string-ext testYukihiro "Matz" Matsumoto
2014-06-04Add String#linesmattn
2014-06-03Implement String#chrJun Hiroe
2014-04-30remove trailing spacesNobuyoshi Nakada
2014-04-20String#casecmp should be call `to_str`ksss
when non String object sent And should be raise TypeError when can not responsed to `to_str`
2014-03-31More tests for String#hex, String#oct as against ↵mattn
9434506035c3fc01de55ac0bc8b75497f8b5df5f