72 Commits

Author SHA1 Message Date
dearblue 4cd858f93d Update test/t/kernel.rb
- Remove unnecessoury assert
- Fix typo
2020-06-09 20:33:56 +09:00
Yusuke Endoh 6f4c585bd7 Do not destruct rest arguments for __send__
Formerly, `__send__(*args)` modified `args` with `Array#shift`.
This bug affects optcarrot.

This changeset avoids the array destruction by using
`args = args[1, len-1]`.
2020-05-24 01:25:03 +09:00
Yukihiro "Matz" Matsumoto c181d89c9d Kernel#clone and Kernel#dup no longer raise TypeError; fix #4974
In ISO, those methods should raise `TypeError`, but the spec has been
changed.  The change was discussed in [Feature#12979].
2020-04-21 13:21:12 +09:00
Yukihiro "Matz" Matsumoto 2ebc6d5b6f Merge pull request #4407 from shuujii/add-assert_raise_with_message-and-assert_raise_with_message_pattern
Add `assert_raise_with_message` and `assert_raise_with_message_pattern`
2019-07-29 01:05:26 +09:00
KOBAYASHI Shuji 97c9e6b000 Fix include, prepend and extend to frozen object 2019-06-30 15:06:39 +09:00
KOBAYASHI Shuji ad8473bd66 Add modification tests for immediate value 2019-06-27 18:47:48 +09:00
KOBAYASHI Shuji c43ff6fa40 Move Kernel#__send__ test to core from mruby-metaprog 2019-06-21 22:02:29 +09:00
KOBAYASHI Shuji 030dd6655e Fix cvar, ivar, const and method can be removed to frozen object 2019-06-16 20:43:23 +09:00
KOBAYASHI Shuji 4b83fe8b04 Remove Kernel#global_variables from core
This method is defined in `mruby-metaprog` gem.
2019-06-07 22:02:43 +09:00
KOBAYASHI Shuji 1fb635ac03 Add assert_raise_with_message and assert_raise_with_message_pattern 2019-04-26 21:48:40 +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 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
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
Yukihiro "Matz" Matsumoto f408143c28 The clone method should copy object status (e.g. frozen) too; #4030 2018-06-01 22:39:40 +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 5405b47f41 Update test for Kernel#local_variables 2017-10-28 00:29:30 +09:00
Christopher Aue 731dd78aa0 Added basic test for calling a missing method through super 2017-08-11 14:09:22 +02:00
Yukihiro "Matz" Matsumoto 466a18b0d3 Remove redundant use of Object#to_s in interpolation. 2017-06-28 23:28:24 +09:00
ksss bd72dba8c0 Kernel#local_variables: Make result array unique 2017-02-06 11:16:47 +09:00
ksss 5c1c002ac2 Fix segv when primitive value
Fix #3352
2016-12-25 16:52:10 +09:00
Takashi Kokubun 10bb7ad693 Implement Object#freeze 2016-12-11 03:44:15 +09:00
Bouke van der Bijl 9c61e1cd87 Use mrb_ptr instead of mrb_cptr in Kernel#to_s
This is to avoid segfault when WORD_BOXING is enabled

Reported by https://hackerone.com/brakhane
2016-12-01 15:23:56 -05:00
Bouke van der Bijl 73bb30c2f4 Copy over INSTANCE_TT when duping class 2016-11-24 09:52:30 -05:00
Yasuhiro Matsumoto 8a15ab0c0c add test for public_methods(false) 2016-06-18 01:21:21 +09:00
Yukihiro "Matz" Matsumoto 35d4137da1 remove part of 9cd71916 test for same reason as 5306e47 2014-06-01 02:51:04 +09:00
take_cheeze d8d07a2345 Move Kernel.local_variables to core. 2014-05-19 22:05:02 +09:00
Carson McDonald aa2e03cdf6 Add test for remove_instance_variable 2014-05-18 15:53:11 -04:00
take_cheeze 49cf477688 Fix #2259 . 2014-05-16 19:58:36 +09:00
take_cheeze d0c0beb880 Move __method__ to mruby-kernel-ext since it's not ISO method. 2014-05-09 22:44:10 +09:00
ksss f0dd4cb673 Implement Kernel#define_singleton_method 2014-03-28 18:16:28 +09:00
ksss 65ace4e027 Implement Kernel#__method__ 2014-03-27 18:25:47 +09:00
Jun Hiroe caa139f91a Refactor tests in kernel.rb 2014-02-27 23:49:58 +09:00
cubicdaiya 677cd22be1 add test for Kernel#instance_variable_defined? 2014-02-26 22:44:22 +09:00
Pavel 411168deab Fix Kernel#global_variables for $1-$9 2014-02-09 23:54:49 +07:00
Tomoyuki Sahara 83413218a5 add operator "!~". 2014-01-10 13:41:41 +09:00
Yukihiro "Matz" Matsumoto d40a62e2d2 object_id may not return Fixnum (ISO says Integer), since intptr_t may be bigger than Fixnum, so type check for Numeric; ref #1630 2014-01-04 21:12:18 +09:00
Yukihiro "Matz" Matsumoto e8dd8180ba return value from #object_id may not be Fixnum; ref #1630 2014-01-01 12:24:20 +09:00
Yukihiro "Matz" Matsumoto 047f318cf9 successful recursion check to be shallower; ref #1630 2014-01-01 12:20:48 +09:00
Carson McDonald 60cd1c341b Method missing and inspect tests 2013-12-31 14:53:44 -05:00
Carson McDonald 9cd7191622 Test coverage of extending stack and overflow 2013-12-31 14:49:24 -05:00
Carson McDonald 3911a052a6 More object_id test coverage 2013-12-31 14:47:17 -05:00
Carson McDonald 12e2488a4a Add is_a? test to cover issue 1477 2013-12-04 10:29:40 -05:00
Jun Hiroe b423171eb4 I fix order of actual and expect test value in kernel.rb. 2013-08-02 21:04:02 +09:00
Daniel Bovensiepen 4bd527cebf Improve Kernel Tests 2013-06-15 01:32:22 +08:00
Carson McDonald 61c0b8f7df Adding a few more respond_to tests 2013-05-05 09:14:41 -04:00
Carson McDonald 54e1ed20f9 Add a test for respond_to_missing? 2013-04-20 07:47:58 -04:00
Masaki Muranaka 91db290412 Add a comment. Kernel#require is defined in the mrbgem. 2013-04-06 18:24:42 +09:00
Masaki Muranaka d1b131e2b0 Add some tests. 2013-04-06 18:22:42 +09:00