rice 4.6.1 → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/CMakeLists.txt +0 -4
  4. data/Rakefile +2 -8
  5. data/bin/rice-doc.rb +211 -0
  6. data/bin/rice-rbs.rb +92 -0
  7. data/include/rice/rice.hpp +4694 -3704
  8. data/include/rice/stl.hpp +840 -294
  9. data/lib/rice/doc/cpp_reference.rb +166 -0
  10. data/lib/rice/doc/doxygen.rb +294 -0
  11. data/lib/rice/doc/mkdocs.rb +298 -0
  12. data/lib/rice/doc/rice.rb +29 -0
  13. data/lib/rice/doc/ruby.rb +37 -0
  14. data/lib/rice/doc.rb +5 -0
  15. data/lib/{make_rice_headers.rb → rice/make_rice_headers.rb} +3 -0
  16. data/lib/rice/native.rb +18 -0
  17. data/lib/rice/native_registry.rb +21 -0
  18. data/lib/rice/parameter.rb +7 -0
  19. data/lib/rice/rbs.rb +104 -0
  20. data/lib/rice/version.rb +1 -1
  21. data/lib/rice.rb +4 -0
  22. data/lib/rubygems/cmake_builder.rb +24 -27
  23. data/rice/Arg.hpp +4 -4
  24. data/rice/Arg.ipp +4 -4
  25. data/rice/Buffer.hpp +32 -28
  26. data/rice/Buffer.ipp +306 -178
  27. data/rice/Data_Object.ipp +136 -88
  28. data/rice/Data_Type.hpp +5 -7
  29. data/rice/Data_Type.ipp +48 -29
  30. data/rice/Enum.ipp +15 -21
  31. data/rice/Function.hpp +17 -0
  32. data/rice/Function.ipp +13 -0
  33. data/rice/Pointer.hpp +15 -0
  34. data/rice/Pointer.ipp +49 -0
  35. data/rice/Return.hpp +1 -1
  36. data/rice/Return.ipp +2 -2
  37. data/rice/api.hpp +30 -0
  38. data/rice/cpp_api/Array.hpp +4 -4
  39. data/rice/cpp_api/Array.ipp +50 -5
  40. data/rice/cpp_api/Class.hpp +0 -5
  41. data/rice/cpp_api/Class.ipp +19 -0
  42. data/rice/cpp_api/Hash.ipp +20 -0
  43. data/rice/cpp_api/Module.hpp +6 -3
  44. data/rice/cpp_api/Module.ipp +49 -11
  45. data/rice/cpp_api/Object.ipp +31 -2
  46. data/rice/cpp_api/String.hpp +1 -2
  47. data/rice/cpp_api/String.ipp +21 -1
  48. data/rice/cpp_api/Struct.ipp +5 -0
  49. data/rice/cpp_api/Symbol.ipp +43 -0
  50. data/rice/cpp_api/shared_methods.hpp +12 -12
  51. data/rice/detail/MethodInfo.hpp +4 -2
  52. data/rice/detail/MethodInfo.ipp +19 -3
  53. data/rice/detail/ModuleRegistry.hpp +18 -0
  54. data/rice/detail/ModuleRegistry.ipp +25 -0
  55. data/rice/detail/Native.hpp +45 -2
  56. data/rice/detail/Native.ipp +196 -6
  57. data/rice/detail/NativeAttributeGet.hpp +9 -4
  58. data/rice/detail/NativeAttributeGet.ipp +65 -11
  59. data/rice/detail/NativeAttributeSet.hpp +4 -0
  60. data/rice/detail/NativeAttributeSet.ipp +30 -2
  61. data/rice/detail/NativeCallbackFFI.ipp +2 -2
  62. data/rice/detail/NativeCallbackSimple.ipp +1 -1
  63. data/rice/detail/NativeFunction.hpp +11 -49
  64. data/rice/detail/NativeFunction.ipp +82 -379
  65. data/rice/detail/NativeInvoker.hpp +74 -0
  66. data/rice/detail/NativeInvoker.ipp +197 -0
  67. data/rice/detail/NativeIterator.hpp +4 -0
  68. data/rice/detail/NativeIterator.ipp +19 -0
  69. data/rice/detail/NativeMethod.hpp +97 -0
  70. data/rice/detail/NativeMethod.ipp +332 -0
  71. data/rice/detail/NativeProc.hpp +51 -0
  72. data/rice/detail/NativeProc.ipp +133 -0
  73. data/rice/detail/NativeRegistry.hpp +8 -0
  74. data/rice/detail/NativeRegistry.ipp +26 -0
  75. data/rice/detail/Parameter.hpp +47 -0
  76. data/rice/detail/Parameter.ipp +105 -0
  77. data/rice/detail/Proc.ipp +14 -13
  78. data/rice/detail/Registries.hpp +1 -0
  79. data/rice/detail/RubyType.hpp +0 -2
  80. data/rice/detail/RubyType.ipp +15 -33
  81. data/rice/detail/Type.hpp +44 -8
  82. data/rice/detail/Type.ipp +151 -49
  83. data/rice/detail/TypeRegistry.hpp +3 -0
  84. data/rice/detail/TypeRegistry.ipp +17 -27
  85. data/rice/detail/Types.ipp +430 -0
  86. data/rice/detail/Wrapper.hpp +12 -0
  87. data/rice/detail/Wrapper.ipp +45 -2
  88. data/rice/detail/from_ruby.ipp +567 -1073
  89. data/rice/detail/ruby.hpp +1 -0
  90. data/rice/detail/to_ruby.ipp +4 -635
  91. data/rice/libc/file.ipp +3 -6
  92. data/rice/rice.hpp +22 -12
  93. data/rice/rice_api/Arg.hpp +7 -0
  94. data/rice/rice_api/Arg.ipp +9 -0
  95. data/rice/rice_api/ModuleRegistry.hpp +7 -0
  96. data/rice/rice_api/ModuleRegistry.ipp +10 -0
  97. data/rice/rice_api/Native.hpp +7 -0
  98. data/rice/rice_api/Native.ipp +52 -0
  99. data/rice/rice_api/NativeRegistry.hpp +7 -0
  100. data/rice/rice_api/NativeRegistry.ipp +21 -0
  101. data/rice/rice_api/Parameter.hpp +7 -0
  102. data/rice/rice_api/Parameter.ipp +11 -0
  103. data/rice/rice_api/Registries.hpp +6 -0
  104. data/rice/rice_api/Registries.ipp +12 -0
  105. data/rice/rice_api/TypeRegistry.hpp +7 -0
  106. data/rice/rice_api/TypeRegistry.ipp +10 -0
  107. data/rice/stl/complex.ipp +35 -0
  108. data/rice/stl/exception.ipp +20 -7
  109. data/rice/stl/filesystem.hpp +6 -0
  110. data/rice/stl/filesystem.ipp +34 -0
  111. data/rice/stl/map.ipp +13 -21
  112. data/rice/stl/monostate.ipp +37 -1
  113. data/rice/stl/multimap.ipp +17 -24
  114. data/rice/stl/optional.ipp +47 -2
  115. data/rice/stl/pair.ipp +23 -58
  116. data/rice/stl/reference_wrapper.ipp +22 -1
  117. data/rice/stl/set.ipp +17 -9
  118. data/rice/stl/shared_ptr.ipp +44 -17
  119. data/rice/stl/string.ipp +175 -7
  120. data/rice/stl/string_view.ipp +23 -0
  121. data/rice/stl/tuple.ipp +38 -9
  122. data/rice/stl/unique_ptr.ipp +46 -2
  123. data/rice/stl/unordered_map.ipp +13 -21
  124. data/rice/stl/variant.ipp +47 -11
  125. data/rice/stl/vector.ipp +183 -104
  126. data/rice/stl.hpp +1 -0
  127. data/rice/traits/function_traits.hpp +2 -2
  128. data/rice/traits/method_traits.hpp +5 -16
  129. data/rice/traits/rice_traits.hpp +24 -4
  130. data/rice.gemspec +10 -22
  131. data/test/embed_ruby.cpp +0 -3
  132. data/test/test_Array.cpp +38 -38
  133. data/test/test_Attribute.cpp +187 -2
  134. data/test/test_Buffer.cpp +302 -26
  135. data/test/test_Callback.cpp +2 -3
  136. data/test/test_Class.cpp +5 -5
  137. data/test/test_Data_Object.cpp +1 -56
  138. data/test/test_Data_Type.cpp +20 -30
  139. data/test/test_Enum.cpp +4 -46
  140. data/test/test_From_Ruby.cpp +89 -82
  141. data/test/test_GVL.cpp +109 -0
  142. data/test/test_Iterator.cpp +1 -1
  143. data/test/test_Keep_Alive_No_Wrapper.cpp +5 -3
  144. data/test/test_Module.cpp +8 -9
  145. data/test/test_Object.cpp +1 -1
  146. data/test/test_Overloads.cpp +58 -10
  147. data/test/test_Stl_Map.cpp +8 -8
  148. data/test/test_Stl_Multimap.cpp +4 -4
  149. data/test/test_Stl_Pair.cpp +5 -3
  150. data/test/test_Stl_SharedPtr.cpp +24 -12
  151. data/test/test_Stl_String_View.cpp +10 -0
  152. data/test/test_Stl_Tuple.cpp +1 -1
  153. data/test/test_Stl_UniquePtr.cpp +8 -0
  154. data/test/test_Stl_Unordered_Map.cpp +9 -9
  155. data/test/test_Stl_Variant.cpp +9 -3
  156. data/test/test_Stl_Vector.cpp +118 -13
  157. data/test/test_Symbol.cpp +12 -0
  158. data/test/test_To_Ruby.cpp +35 -28
  159. data/test/test_Type.cpp +256 -53
  160. data/test/unittest.hpp +35 -0
  161. metadata +52 -34
  162. data/rice/Init.hpp +0 -8
  163. data/rice/Init.ipp +0 -8
  164. data/rice/detail/RubyFunction.hpp +0 -31
  165. data/rice/detail/RubyFunction.ipp +0 -77
  166. data/sample/callbacks/extconf.rb +0 -5
  167. data/sample/callbacks/sample_callbacks.cpp +0 -35
  168. data/sample/callbacks/test.rb +0 -28
  169. data/sample/enum/extconf.rb +0 -5
  170. data/sample/enum/sample_enum.cpp +0 -40
  171. data/sample/enum/test.rb +0 -8
  172. data/sample/inheritance/animals.cpp +0 -82
  173. data/sample/inheritance/extconf.rb +0 -5
  174. data/sample/inheritance/test.rb +0 -7
  175. data/sample/map/extconf.rb +0 -5
  176. data/sample/map/map.cpp +0 -73
  177. data/sample/map/test.rb +0 -7
  178. data/test/ext/t1/Foo.hpp +0 -10
  179. data/test/ext/t1/extconf.rb +0 -4
  180. data/test/ext/t1/t1.cpp +0 -13
  181. data/test/ext/t2/extconf.rb +0 -4
  182. data/test/ext/t2/t2.cpp +0 -11
  183. data/test/ruby/test_callbacks_sample.rb +0 -28
  184. data/test/ruby/test_multiple_extensions.rb +0 -18
  185. data/test/ruby/test_multiple_extensions_same_class.rb +0 -14
  186. data/test/ruby/test_multiple_extensions_with_inheritance.rb +0 -20
  187. /data/test/{test_Stl_Type.cpp → test_Stl_Type_Info.cpp} +0 -0
@@ -1,77 +0,0 @@
1
-
2
- #include <any>
3
- #include <tuple>
4
-
5
- namespace Rice::detail
6
- {
7
- template<typename Function_T, typename...Arg_Ts>
8
- inline RubyFunction<Function_T, Arg_Ts...>::RubyFunction(Function_T func, const Arg_Ts&... args)
9
- : func_(func), args_(std::forward_as_tuple(args...))
10
- {
11
- }
12
-
13
- template<typename Function_T, typename...Arg_Ts>
14
- inline typename RubyFunction<Function_T, Arg_Ts...>::Return_T RubyFunction<Function_T, Arg_Ts...>::operator()()
15
- {
16
- // Setup a thread local variable to capture the result of the Ruby function call.
17
- // We use thread_local because the lambda has to be captureless so it can
18
- // be converted to a function pointer callable by C.
19
- // The thread local variable avoids having to cast the result to VALUE and then
20
- // back again to Return_T. The problem with that is the translation is not lossless
21
- // in some cases - for example a double with value of -1.0 does not roundrip.
22
- //
23
- thread_local std::any result;
24
-
25
- // Callback that will invoke the Ruby function
26
- using Functor_T = RubyFunction<Function_T, Arg_Ts...>;
27
- auto callback = [](VALUE value) -> VALUE
28
- {
29
- Functor_T* functor = (Functor_T*)value;
30
-
31
- if constexpr (std::is_same_v<Return_T, void>)
32
- {
33
- std::apply(functor->func_, functor->args_);
34
- }
35
- else
36
- {
37
- result = std::apply(functor->func_, functor->args_);
38
- }
39
-
40
- return Qnil;
41
- };
42
-
43
- // Now call rb_protect which will invoke the callback lambda above
44
- int state = (int)JumpException::RUBY_TAG_NONE;
45
- rb_protect(callback, (VALUE)this, &state);
46
-
47
- // Did anything go wrong?
48
- if (state == JumpException::RUBY_TAG_NONE)
49
- {
50
- if constexpr (!std::is_same_v<Return_T, void>)
51
- {
52
- return std::any_cast<Return_T>(result);
53
- }
54
- }
55
- else
56
- {
57
- VALUE err = rb_errinfo();
58
- if (state == JumpException::RUBY_TAG_RAISE && RB_TEST(err))
59
- {
60
- rb_set_errinfo(Qnil);
61
- throw Rice::Exception(err);
62
- }
63
- else
64
- {
65
- throw Rice::JumpException((Rice::JumpException::ruby_tag_type)state);
66
- }
67
- }
68
- }
69
-
70
- // Create a functor for calling a Ruby function and define some aliases for readability.
71
- template<typename Function_T, typename ...Arg_Ts>
72
- auto protect(Function_T func, Arg_Ts...args)
73
- {
74
- auto rubyFunction = RubyFunction<Function_T, Arg_Ts...>(func, std::forward<Arg_Ts>(args)...);
75
- return rubyFunction();
76
- }
77
- }
@@ -1,5 +0,0 @@
1
- require 'bundler/setup'
2
- require 'mkmf-rice'
3
-
4
- create_makefile('sample_callbacks')
5
-
@@ -1,35 +0,0 @@
1
- #include <rice/rice.hpp>
2
-
3
- using namespace Rice;
4
-
5
- namespace
6
- {
7
-
8
- class CallbackHolder
9
- {
10
- public:
11
-
12
- void registerCallback(Rice::Object cb)
13
- {
14
- callback_ = cb;
15
- }
16
-
17
- Rice::Object fireCallback(Rice::String param)
18
- {
19
- return callback_.call("call", param);
20
- }
21
-
22
- Rice::Object callback_;
23
- };
24
-
25
- } // namespace
26
-
27
- extern "C"
28
- void Init_sample_callbacks()
29
- {
30
- define_class<CallbackHolder>("CallbackHolder")
31
- .define_constructor(Constructor<CallbackHolder>())
32
- .define_method("register_callback", &CallbackHolder::registerCallback)
33
- .define_method("fire_callback", &CallbackHolder::fireCallback);
34
- }
35
-
@@ -1,28 +0,0 @@
1
- require 'sample_callbacks'
2
-
3
- def hello(message)
4
- "Hello #{message}"
5
- end
6
-
7
- cb1 = CallbackHolder.new
8
- cb2 = CallbackHolder.new
9
- cb3 = CallbackHolder.new
10
-
11
- cb1.register_callback(lambda do |param|
12
- "Callback 1 got param #{param}"
13
- end)
14
-
15
- cb2.register_callback(lambda do |param|
16
- "Callback 2 got param #{param}"
17
- end)
18
-
19
- cb3.register_callback method(:hello)
20
-
21
- puts "Calling Callback 1"
22
- puts cb1.fire_callback("Hello")
23
-
24
- puts "Calling Callback 2"
25
- puts cb2.fire_callback("World")
26
-
27
- puts "Calling Callback 3"
28
- puts cb3.fire_callback("Ruby")
@@ -1,5 +0,0 @@
1
- require 'bundler/setup'
2
- require 'mkmf-rice'
3
-
4
- create_makefile('sample_enum')
5
-
@@ -1,40 +0,0 @@
1
- #include <rice/rice.hpp>
2
-
3
- using namespace Rice;
4
-
5
- namespace
6
- {
7
-
8
- enum Sample_Enum
9
- {
10
- SE_FOO = 1,
11
- SE_BAR = 42,
12
- SE_BAZ = 100,
13
- };
14
-
15
- char const * description(Sample_Enum e)
16
- {
17
- switch(e)
18
- {
19
- case SE_FOO: return "Fairly Ordinary Object";
20
- case SE_BAR: return "Beginner's All-purpose Ratchet";
21
- case SE_BAZ: return "Better than A Zebra";
22
- }
23
- return "???";
24
- }
25
-
26
- } // namespace
27
-
28
- extern "C"
29
- void Init_sample_enum()
30
- {
31
- Rice::Enum<Sample_Enum> sample_enum_type =
32
- define_enum<Sample_Enum>("Sample_Enum")
33
- .define_value("FOO", SE_FOO)
34
- .define_value("BAR", SE_BAR)
35
- .define_value("BAZ", SE_BAZ);
36
-
37
- sample_enum_type
38
- .define_method("description", description);
39
- }
40
-
data/sample/enum/test.rb DELETED
@@ -1,8 +0,0 @@
1
- require_relative 'sample_enum'
2
-
3
- Sample_Enum.each { |x| p x }
4
- s = Sample_Enum::FOO
5
- puts s
6
- puts s.inspect
7
- puts s < Sample_Enum::BAR
8
- s.description
@@ -1,82 +0,0 @@
1
- #include <rice/rice.hpp>
2
-
3
- using namespace Rice;
4
-
5
- class Organism
6
- {
7
- public:
8
- virtual ~Organism() = default;
9
- virtual char const * name() = 0;
10
- };
11
-
12
- class Animal
13
- : public Organism
14
- {
15
- public:
16
- virtual char const * speak() = 0;
17
- };
18
-
19
- class Bear
20
- : public Animal
21
- {
22
- public:
23
- char const * name() override
24
- {
25
- return "Bear";
26
- }
27
-
28
- char const * speak() override
29
- {
30
- return "I'm smarter than the average bear";
31
- }
32
- };
33
-
34
- class Dog
35
- : public Animal
36
- {
37
- public:
38
- char const * name() override
39
- {
40
- return "Dog";
41
- }
42
-
43
- char const * speak() override
44
- {
45
- return "Woof woof";
46
- }
47
- };
48
-
49
- class Rabbit
50
- : public Animal
51
- {
52
- public:
53
- char const * name() override
54
- {
55
- return "Rabbit";
56
- }
57
-
58
- char const * speak() override
59
- {
60
- return "What's up, doc?";
61
- }
62
- };
63
-
64
- extern "C"
65
- void Init_animals(void)
66
- {
67
- define_class<Organism>("Organism")
68
- .define_method("name", &Organism::name);
69
-
70
- define_class<Animal, Organism>("Animal")
71
- .define_method("speak", &Animal::speak);
72
-
73
- define_class<Bear, Animal>("Bear")
74
- .define_constructor(Constructor<Bear>());
75
-
76
- define_class<Dog, Animal>("Dog")
77
- .define_constructor(Constructor<Dog>());
78
-
79
- define_class<Rabbit, Animal>("Rabbit")
80
- .define_constructor(Constructor<Rabbit>());
81
- }
82
-
@@ -1,5 +0,0 @@
1
- require 'bundler/setup'
2
- require 'mkmf-rice'
3
-
4
- create_makefile('animals')
5
-
@@ -1,7 +0,0 @@
1
- require_relative 'animals'
2
-
3
- [ Bear, Dog, Rabbit].each do |klass|
4
- animal = klass.new
5
- puts "A #{animal.name} says: #{animal.speak}"
6
- end
7
-
@@ -1,5 +0,0 @@
1
- require 'bundler/setup'
2
- require 'mkmf-rice'
3
-
4
- create_makefile('map')
5
-
data/sample/map/map.cpp DELETED
@@ -1,73 +0,0 @@
1
- #include <rice/rice.hpp>
2
-
3
- #include <map>
4
-
5
- using namespace Rice;
6
-
7
- namespace
8
- {
9
-
10
- class Map
11
- {
12
- private:
13
- struct Ruby_Value_Compare
14
- {
15
- bool operator()(Object lhs, Object rhs) const
16
- {
17
- Object result = lhs.call("<", rhs);
18
- return result.test();
19
- }
20
- };
21
-
22
- typedef std::map<Object, Object, Ruby_Value_Compare> Value_Map;
23
-
24
- public:
25
- Object bracket(Object k)
26
- {
27
- Value_Map::iterator it = map_.find(k);
28
- return it == map_.end() ? Object(Qnil) : it->second;
29
- }
30
-
31
- Object bracket_equals(Object k, Object v)
32
- {
33
- map_[k] = v;
34
- return Qnil;
35
- }
36
-
37
- Value_Map::iterator begin() { return map_.begin(); }
38
- Value_Map::iterator end() { return map_.end(); }
39
-
40
- typedef Value_Map::value_type value_type;
41
- typedef Value_Map::iterator iterator;
42
-
43
- private:
44
- Value_Map map_;
45
- };
46
-
47
- } // namespace
48
-
49
- template<>
50
- struct detail::To_Ruby<Map::value_type>
51
- {
52
- static VALUE convert(Map::value_type const & pair)
53
- {
54
- return detail::protect(rb_assoc_new, pair.first.value(), pair.second.value());
55
- }
56
- };
57
-
58
- #include <iostream>
59
- extern "C"
60
- void Init_map(void)
61
- {
62
- Rice::Module rb_mStd = define_module("Std");
63
-
64
- // TODO: no delete method on the map, because I'm not sure how to
65
- // make delete work properly while iterating
66
- Data_Type<Map> rb_cMap =
67
- define_class_under<Map>(rb_mStd, "Map")
68
- .define_constructor(Constructor<Map>())
69
- .define_method("[]", &Map::bracket)
70
- .define_method("[]=", &Map::bracket_equals)
71
- .define_iterator(&Map::begin, &Map::end)
72
- .include_module(rb_mEnumerable);
73
- }
data/sample/map/test.rb DELETED
@@ -1,7 +0,0 @@
1
- require_relative 'map.so'
2
- m = Std::Map.new
3
- m[0] = 1
4
- m[1] = 2
5
- m[3] = 3
6
- m.each { |x| p x }
7
-
data/test/ext/t1/Foo.hpp DELETED
@@ -1,10 +0,0 @@
1
- #ifndef T1__FOO__HPP_
2
- #define T1__FOO__HPP_
3
-
4
- class Foo
5
- {
6
- public:
7
- int foo() { return 42; }
8
- };
9
-
10
- #endif // T1__FOO__HPP_
@@ -1,4 +0,0 @@
1
- require 'bundler/setup'
2
- require 'mkmf-rice'
3
-
4
- create_makefile('t1')
data/test/ext/t1/t1.cpp DELETED
@@ -1,13 +0,0 @@
1
- #include "Foo.hpp"
2
- #include <rice/rice.hpp>
3
-
4
- using namespace Rice;
5
-
6
- extern "C"
7
- void Init_t1()
8
- {
9
- define_class<Foo>("Foo")
10
- .define_constructor(Constructor<Foo>())
11
- .define_method("foo", &Foo::foo);
12
- }
13
-
@@ -1,4 +0,0 @@
1
- require 'bundler/setup'
2
- require 'mkmf-rice'
3
-
4
- create_makefile('t2')
data/test/ext/t2/t2.cpp DELETED
@@ -1,11 +0,0 @@
1
- #include "../t1/Foo.hpp"
2
- #include <rice/rice.hpp>
3
-
4
- using namespace Rice;
5
-
6
- extern "C"
7
- void Init_t2()
8
- {
9
- volatile Data_Type<Foo> foo;
10
- }
11
-
@@ -1,28 +0,0 @@
1
- $: << File.join(File.dirname(__FILE__), '..', 'sample')
2
-
3
- require 'rubygems'
4
- gem 'minitest'
5
- require 'minitest/autorun'
6
- require_relative '../../sample/callbacks/sample_callbacks'
7
-
8
- class CallbacksTest < Minitest::Test
9
- def test_callbacks_sample_lambda
10
- cb = CallbackHolder.new
11
- cb.register_callback(lambda do |param|
12
- "Callback got: #{param}"
13
- end)
14
-
15
- assert_equal "Callback got: Hello", cb.fire_callback("Hello")
16
- end
17
-
18
- def hello_world(param)
19
- "Method got: #{param}"
20
- end
21
-
22
- def test_callbacks_sample_method
23
- cb = CallbackHolder.new
24
- cb.register_callback method(:hello_world)
25
-
26
- assert_equal "Method got: Hello", cb.fire_callback("Hello")
27
- end
28
- end
@@ -1,18 +0,0 @@
1
- $: << File.join(__dir__, '..', '..', 'sample')
2
-
3
- require 'minitest'
4
- require 'minitest/autorun'
5
-
6
- class MultipleExtensionTest < Minitest::Test
7
- def test_multiple_extensions
8
- # Rinse
9
- require 'map/map'
10
- m = Std::Map.new
11
- m[0] = 1
12
-
13
- # And repeat
14
- require 'enum/sample_enum'
15
- m = Std::Map.new
16
- m[0] = 1
17
- end
18
- end
@@ -1,14 +0,0 @@
1
- $: << File.join(__dir__, '..', 'ext')
2
-
3
- require 'minitest'
4
- require 'minitest/autorun'
5
-
6
- class MultipleExtensionsSameClassTest < Minitest::Test
7
- def test_multiple_extensions_same_class
8
- require 't1/t1'
9
- require 't2/t2'
10
-
11
- foo = Foo.new
12
- assert_equal 42, foo.foo
13
- end
14
- end
@@ -1,20 +0,0 @@
1
- $: << File.join(__dir__, '..', '..', 'sample')
2
- # Load a library that uses inheritance
3
- require 'inheritance/animals'
4
-
5
- # Then load a different library
6
- require 'enum/sample_enum'
7
-
8
- require 'minitest'
9
- require 'minitest/autorun'
10
-
11
- class MultipleExtensionTest < Minitest::Test
12
- def test_multiple_extensions_with_inheritance
13
-
14
- # And make sure we can call methods in the base class on a derived
15
- # instance
16
- dog = Dog.new
17
- assert_equal dog.name, "Dog"
18
- assert_equal dog.speak, "Woof woof"
19
- end
20
- end
File without changes