80 Commits

Author SHA1 Message Date
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 7675fcb5d3 Fix Module#dup to frozen module
Before this patch:

  $ bin/mruby -e 'p Module.new.freeze.dup.frozen?'  #=> true

After this patch (same as Ruby):

  $ bin/mruby -e 'p Module.new.freeze.dup.frozen?'  #=> false
2019-07-20 22:41:57 +09:00
KOBAYASHI Shuji 97c9e6b000 Fix include, prepend and extend to frozen object 2019-06-30 15:06:39 +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 dc1905e1bd Fix missing assertions in test/t/module.rb 2019-06-05 19:13:36 +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 cc7f9190ba Fix name assignment to frozen anonymous class/module
Fix the following issues:

  A = Class.new.freeze              #=> FrozenError
  Module.new::B = Class.new.freeze  #=> FrozenError
  String::B = Module.new.freeze     #=> FrozenError
2019-04-23 20:45:38 +09:00
Yukihiro "Matz" Matsumoto 7cf1bc39a7 Merge pull request #4356 from shuujii/add-assert_match-and-assert_not_match
Add `assert_match` and `assert_not_match`
2019-04-22 22:29:15 +09:00
KOBAYASHI Shuji 716a99b069 Add assert_match and assert_not_match 2019-04-14 19:06:28 +09:00
KOBAYASHI Shuji 623e15936a Module#alias_method should return self in ISO standard 2019-04-05 19:03:46 +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 8a7298e069 Use more appropriate assertion methods 2019-02-19 20:02:50 +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
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 b03f1f78e3 Fix misspelling words in comments 2018-08-11 00:28:32 +09:00
Christopher Aue 4b0b8f7e1a Refactored #assert_raise and #assert_nothing_raised 2017-08-29 23:25:53 +02:00
Yukihiro "Matz" Matsumoto 9e10afe1d0 Implements `Module::nesting' (15.2.2.3.2); ref #600, #3200 2017-08-01 15:37:21 +09:00
Yukihiro "Matz" Matsumoto b290e98f3b Merge pull request #3757 from christopheraue/module_const_get_class_path
Extended Module#const_get to support class paths
2017-07-29 07:05:37 +09:00
Christopher Aue f937af5745 Extended Module#const_get to support class paths 2017-07-28 23:19:49 +02:00
Christopher Aue b499ad6749 Fixed return value of Module#include and #prepend 2017-07-28 17:38:40 +02:00
Christopher Aue 468cc34c93 Fixed Module#to_s and #name for #const_set modules 2017-07-18 22:55:37 +02:00
Kouichi Nakanishi 507e00e86f Modify to get constant of parent module in singleton class; fix #3568 2017-03-31 13:43:20 +09:00
ksss efe4f30b39 Module#define_method supports proc argument 2016-10-12 22:19:54 +09:00
Blaž Hrastnik 78462c9181 Clean up tests 2015-07-13 23:46:41 +02:00
Blaž Hrastnik 8c4da7accd assert() cannot be nested 2015-07-13 23:38:37 +02:00
Blaž Hrastnik 8c13e2b7c6 Set origin when doing kind_of? comparisons 2015-07-13 23:35:30 +02:00
Blaž Hrastnik b0fb9ccfd8 Enable test_prepend_module_ancestors because it seems to pass. 2015-07-13 23:25:01 +02:00
Corey Powell 11cb41770d Space out test_prepend_super_in_alias assert
Also tried to fix it, however the problem lies with how aliased methods
are done and their internal structure.

mruby simply aliases methods by grabbing the RProc and giving it a new name,
super then determines the original method to call by using the name

so a method called m, aliased as m2, will call the m2 super method instead of m
2015-07-13 10:45:57 -05:00
Blaž Hrastnik 11dad71578 Enable visibility prepend tests again 2015-07-13 14:04:43 +02:00
Corey Powell 47264bf289 Ported all MRI prepend tests
And of course, some of them fail miserably
2015-07-13 14:04:42 +02:00
Corey Powell 319553f0ef Removed some debug prints from the test 2015-07-13 14:04:42 +02:00
Corey Powell 99aff17075 Ported a bit more of the MRI Module#prepend tests over
Currently kind_of fails miserably, still looking for the reason
2015-07-13 14:04:42 +02:00
Blaž Hrastnik d046814d8b Rename classes because of conflicts 2015-07-13 14:04:42 +02:00
Blaž Hrastnik f962890a92 Implement Module#prepend. 2015-07-13 14:04:42 +02:00
cremno 59ea323976 check if outer is a class or module
For modules this check didn't exist yet. Also call #inspect.
2015-05-29 14:58:53 +02:00
Yukihiro "Matz" Matsumoto 69ba4f0ed5 instance_methods etc should not include undef'ed method names; based on a patch from @cremno; fix #2613 2014-10-20 11:11:26 +09:00
Tatsuhiko Kubo 2b283393c6 Remove empty lines. 2014-08-20 12:07:36 +09:00
dreamedge 0b8a0f4bb4 add Module#module_function 2014-07-18 09:50:54 +09:00
take_cheeze ec5b055694 Move direct superclass checking to test/t/superclass.rb. 2014-06-15 15:02:21 +09:00
ksss 0bd8e48773 Module#initialize set created object
for block argument
2014-05-21 23:09:19 +09:00
ksss ffbf90bdc8 Implement Module#initialize (15.2.2.4.31) 2014-05-19 19:28:42 +09:00
ksss 464bbbddc7 instance method name use "#" instead of "." for assert 2014-05-18 10:54:23 +09:00
Nobuyoshi Nakada ab67c57f65 remove trailing spaces 2014-04-30 09:50:14 +09:00
h2so5 25045345c9 clone Class/Module rightly 2014-01-25 07:47:15 +09:00
Carson McDonald 5ab9979ba4 Change :vattr= to :cattr= in respond_to? test 2013-12-24 12:12:50 -05:00
Yukihiro "Matz" Matsumoto fa4ae7dd4d modify test case to check #1606 2013-12-09 11:44:02 +09:00
Carson McDonald 3385a33e9e Add two tests for issue #1467 2013-08-13 11:39:30 -04:00
Jun Hiroe dddb5faff0 I fix order of actual and expect test value in module.rb. 2013-08-02 22:04:23 +09:00
Ryan Scott ab787ab968 Cleaned up some of the Module#attr tests 2013-07-21 18:43:00 +10:00