Commit Graph

659 Commits

Author SHA1 Message Date
KOBAYASHI Shuji cdb458ed4e Commented out String#scan because it is not implemented yet 2019-04-21 20:34:39 +09:00
KOBAYASHI Shuji 4a8b88f775 Add type check (conversion) in String#[]=
Before this patch:

  'a'[0] = 1        #=> 1
  'a'[:a] = '1'     #=> ArgumentError
  'a'[:a, 0] = '1'  #=> ArgumentError
  'a'[0, :a] = '1'  #=> ArgumentError
  'a'[0, 1] = 1     #=> 1

After this patch / Ruby:

  'a'[0] = 1        #=> TypeError
  'a'[:a] = '1'     #=> TypeError
  'a'[:a, 0] = '1'  #=> TypeError
  'a'[0, :a] = '1'  #=> TypeError
  'a'[0, 1] = 1     #=> TypeError
2019-04-19 20:14:23 +09:00
KOBAYASHI Shuji 7b0ebed033 Use mrb_immediate_p() in mrb_obj_freeze() and mrb_obj_frozen() 2019-04-10 19:19:53 +09:00
KOBAYASHI Shuji f65b35dc9f Fix test for Array#slice 2019-04-07 21:31:12 +09:00
KOBAYASHI Shuji 623e15936a Module#alias_method should return self in ISO standard 2019-04-05 19:03:46 +09:00
KOBAYASHI Shuji b489ddcbd1 Remove implementation of Symbol#===
For reducing program size.
2019-03-25 21:39:11 +09:00
Yukihiro "Matz" Matsumoto f7e05c7d22 Update float test values to avoid precision errors. 2019-03-25 16:54:34 +09:00
Yukihiro "Matz" Matsumoto ce67561511 Avoid infinite binary floating numbers in float. 2019-03-25 16:21:50 +09:00
KOBAYASHI Shuji 04fc265858 Simplify assert_step in test/t/numeric.rb 2019-03-22 18:37:37 +09:00
KOBAYASHI Shuji a41b02ab91 Fix Float#eql? 2019-03-21 21:36:54 +09:00
KOBAYASHI Shuji fbad7a1595 Use FrozenError instead of RuntimeError in frozen object modification test 2019-03-19 20:48:32 +09:00
KOBAYASHI Shuji b588e5a5b7 Fix class/instance variable name validation
- `@@?` etc are invalid class variable name.
- `@1` etc are invalid instance variable name.
2019-03-17 16:58:31 +09:00
Yukihiro "Matz" Matsumoto a1e1201148 Merge pull request #4328 from shuujii/fix-constant-name-validation
Fix constant name validation
2019-03-15 21:19:48 +09:00
Yukihiro "Matz" Matsumoto 298807fa4e Avoid using infinite binary floating point numbers in tests. 2019-03-15 15:25:43 +09:00
KOBAYASHI Shuji 16b1b2978e Fix constant name validation
`X!` etc are invalid constant name.
2019-03-14 23:09:05 +09:00
KOBAYASHI Shuji 729ab86d49 Fix missing assertion in test/t/class.rb 2019-03-02 18:55:02 +09:00
Yukihiro "Matz" Matsumoto e5649eba70 Remove useless regression tests; ref #4306 2019-03-02 14:01:52 +09:00
Yukihiro "Matz" Matsumoto 997cc8238d Remove useless regression tests; fix #4306 2019-03-02 14:00:25 +09:00
Yukihiro "Matz" Matsumoto f1fb2bf29e Remove ?A style string literals from string tests; #4303
We have a plan to obsolete this style in the future.
2019-02-28 12:55:44 +09:00
dearblue f9a568adcb Add test for string literal concatenation 2019-02-27 22:58:13 +09:00
KOBAYASHI Shuji 8a7298e069 Use more appropriate assertion methods 2019-02-19 20:02:50 +09:00
KOBAYASHI Shuji d68eb3d043 Fix wrong assertion method in some tests 2019-02-18 21:24:20 +09:00
KOBAYASHI Shuji abbc501433 class/module expression with empty body should return nil
Before:

  p(class A end)          #=> A
  p(class << self; end)   #=> #<Class:#<Object:0x7fdc3880e420>>
  p(module B end)         #=> B

After/Ruby:

  p(class A end)          #=> nil
  p(class << self; end)   #=> nil
  p(module B end)         #=> nil
2019-01-28 21:29:55 +09:00
KOBAYASHI Shuji 6d5a62cf5f Fix tests for String#reverse with MRB_UTF8_STRING 2019-01-22 19:37:14 +09:00
KOBAYASHI Shuji cfe3654fd1 Fix assertion name for Numeric#** test 2019-01-17 21:16:02 +09:00
KOBAYASHI Shuji de5da4b7f6 Fix coercing for first step counter in Numeric#step
Before:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7, 4.0]

After / Ruby:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7.0, 4.0]
2019-01-15 21:41:54 +09:00
KOBAYASHI Shuji 9f081183d2 Improve compatibility to CRuby for Float#to_s
Bfore:

  Float::INFINITY.to_s  #=> "inf"
  50.0.to_s             #=> "50"
  1e20.to_s             #=> "1e+20"

After / CRuby:

  Float::INFINITY.to_s  #=> "Infinity"
  50.0.to_s             #=> "50.0"
  1e20.to_s             #=> "1.0e+20"
2019-01-13 19:59:22 +09:00
KOBAYASHI Shuji 8b951710fe Use __send__ instead of send; ref #4207 2019-01-12 22:21:34 +09:00
KOBAYASHI Shuji 6f395a58d2 Add assert_same and assert_not_same 2019-01-05 20:41:09 +09:00
Yukihiro "Matz" Matsumoto cca19532c5 Remove Kernel#class_defined? which is not available in CRuby; #3829 2019-01-03 11:34:35 +09:00
KOBAYASHI Shuji 648b57620a range: Embed edges in RRange on boxing environment.
[Breaking changes]

Developers must use following APIs for accessing attributes of RRange
because RRange structure depends on boxing setting.

- mrb_range_beg
- mrb_range_end
- mrb_range_excl_p
2019-01-01 15:35:56 +09:00
KOBAYASHI Shuji 4da687a6c3 Use __send__ instead of send in a Range test.
This assertion is accidentaly passed because `send` was removed from mruby
core so `NoMethodError` is raised and `NoMethodError` is subclass of
`NameError`.
2019-01-01 09:38:58 +09:00
Yukihiro "Matz" Matsumoto ff08856fe3 Remove implicit conversion using to_str method; fix #3854
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-19 12:05:46 +09:00
Yukihiro "Matz" Matsumoto d47003aea4 Fixed a bug in argument number check with kwargs; fix #4159 2018-11-05 07:44:25 +09:00
Tomoyuki Sahara 91444c4747 replace quicksort with mergesort. 2018-10-18 13:07:47 +09:00
Yukihiro "Matz" Matsumoto 82e00ce60f Hash#delete should return the deleted value; fix #4133 2018-10-12 08:25:54 +09:00
Yukihiro "Matz" Matsumoto 3a9caad8eb Move Symbol#to_proc to the core from mruby-symbol-ext gem.
Even though `Symbol#to_proc` is not included in ISO standard, the
`some_method(&:method_name)` is used very widely and convenient.
So we moved it to the core.
2018-09-20 13:47:29 +09:00
dearblue 366848996a Clear terminated space 2018-09-07 22:32:34 +09:00
Yukihiro "Matz" Matsumoto b80e0ef742 Move Kernel#send to mruby-metaprog gem.
But `BasicObject#__send__` is still available from the core.
2018-09-01 11:20:30 +09:00
Yukihiro "Matz" Matsumoto e471d37ca5 Separate meta-programming features to mruby-metaprog gem.
We assume meta-programming is less used in embedded environments.
We have moved following methods:

 * Kernel module
   global_variables, local_variables, singleton_class,
   instance_variables, instance_variables_defined?, instance_variable_get,
   instance_variable_set, methods, private_methods, public_methods,
   protected_methods, singleton_methods, define_singleton_methods

 * Module class
   class_variables, class_variables_defined?, class_variable_get,
   class_variable_set, remove_class_variable, included_modules,
   instance_methods, remove_method, method_removed, constants

 * Module class methods
   constants, nesting

Note:
Following meta-programming methods are kept in the core:

 * Module class
   alias_method, undef_method, ancestors, const_defined?, const_get,
   const_set, remove_const, method_defined?, define_method

 * Toplevel object
   define_method

`mruby-metaprog` gem is linked by default (specified in default.gembox).
When it is removed, it will save 40KB (stripped:8KB) on x86-64
environment last time I measured.
2018-08-30 22:30:36 +09:00
Kazuhiro Sera 2b2ff844a1 Fix misspelling words in comments 2018-08-25 09:19:17 +09:00
Yukihiro "Matz" Matsumoto 889f0f5f36 Add test case corresponding to 53e2723. 2018-07-31 17:27:59 +09:00
Yukihiro "Matz" Matsumoto 8c9e712784 Keyword argument implemented. 2018-07-30 22:58:01 +09:00
Yukihiro "Matz" Matsumoto f408143c28 The clone method should copy object status (e.g. frozen) too; #4030 2018-06-01 22:39:40 +09:00
Takeshi Watanabe e66c990234 Fix array replace leak error in mruby-uri. 2018-04-25 13:27:00 +09:00
Takeshi Watanabe 77a3863a3d Return nil if type differ in String#<=>. 2018-03-24 16:18:44 +09:00
Yukihiro "Matz" Matsumoto 1d55260423 String#inspect to use hexadecimal, not octal to print unprintable. 2018-02-12 22:56:24 +09:00
Yukihiro "Matz" Matsumoto 2a5545cc25 Update Kernel#method_missing tests for new NoMethodError message.
Also removed tests that depends on implementation details of the default
`method_missing` behavior.
2017-12-23 15:18:13 +09:00
Yukihiro "Matz" Matsumoto e14387440e Skip test/t/float.rb tests; ref #3827 2017-12-13 08:45:46 +09:00
Yukihiro "Matz" Matsumoto 597149ae23 Change newline style of test/t/lang.rb (from DOS) 2017-11-22 16:10:28 +09:00