rice 4.0.4 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/CONTRIBUTORS.md +2 -0
  4. data/Rakefile +1 -1
  5. data/include/rice/rice.hpp +2851 -1955
  6. data/include/rice/stl.hpp +1654 -287
  7. data/lib/mkmf-rice.rb +5 -2
  8. data/lib/version.rb +1 -1
  9. data/rice/Arg.hpp +6 -6
  10. data/rice/Arg.ipp +8 -9
  11. data/rice/Constructor.hpp +2 -2
  12. data/rice/Data_Object.ipp +69 -15
  13. data/rice/Data_Object_defn.hpp +1 -15
  14. data/rice/Data_Type.ipp +56 -86
  15. data/rice/Data_Type_defn.hpp +14 -17
  16. data/rice/Director.hpp +0 -1
  17. data/rice/Enum.ipp +31 -22
  18. data/rice/Exception.ipp +2 -3
  19. data/rice/Exception_defn.hpp +5 -5
  20. data/rice/HandlerRegistration.hpp +15 -0
  21. data/rice/Return.hpp +5 -4
  22. data/rice/Return.ipp +8 -3
  23. data/rice/detail/ExceptionHandler.hpp +8 -0
  24. data/rice/detail/ExceptionHandler.ipp +28 -0
  25. data/rice/detail/{Exception_Handler_defn.hpp → ExceptionHandler_defn.hpp} +17 -21
  26. data/rice/detail/HandlerRegistry.hpp +51 -0
  27. data/rice/detail/HandlerRegistry.ipp +20 -0
  28. data/rice/detail/InstanceRegistry.hpp +34 -0
  29. data/rice/detail/InstanceRegistry.ipp +50 -0
  30. data/rice/detail/MethodInfo.ipp +1 -1
  31. data/rice/detail/NativeAttribute.hpp +26 -15
  32. data/rice/detail/NativeAttribute.ipp +76 -47
  33. data/rice/detail/NativeFunction.hpp +64 -14
  34. data/rice/detail/NativeFunction.ipp +138 -86
  35. data/rice/detail/NativeIterator.hpp +49 -0
  36. data/rice/detail/NativeIterator.ipp +102 -0
  37. data/rice/detail/NativeRegistry.hpp +31 -0
  38. data/rice/detail/{method_data.ipp → NativeRegistry.ipp} +20 -16
  39. data/rice/detail/Registries.hpp +26 -0
  40. data/rice/detail/Registries.ipp +23 -0
  41. data/rice/detail/RubyFunction.hpp +6 -11
  42. data/rice/detail/RubyFunction.ipp +10 -22
  43. data/rice/detail/Type.hpp +1 -1
  44. data/rice/detail/Type.ipp +2 -2
  45. data/rice/detail/TypeRegistry.hpp +8 -11
  46. data/rice/detail/TypeRegistry.ipp +3 -28
  47. data/rice/detail/Wrapper.hpp +0 -2
  48. data/rice/detail/Wrapper.ipp +74 -24
  49. data/rice/detail/cpp_protect.hpp +93 -0
  50. data/rice/detail/default_allocation_func.ipp +1 -1
  51. data/rice/detail/from_ruby.ipp +206 -2
  52. data/rice/detail/to_ruby.ipp +39 -5
  53. data/rice/detail/to_ruby_defn.hpp +1 -1
  54. data/rice/forward_declares.ipp +6 -0
  55. data/rice/global_function.hpp +0 -4
  56. data/rice/global_function.ipp +0 -6
  57. data/rice/rice.hpp +29 -24
  58. data/rice/stl.hpp +6 -1
  59. data/sample/callbacks/extconf.rb +0 -1
  60. data/sample/enum/extconf.rb +0 -1
  61. data/sample/inheritance/extconf.rb +0 -1
  62. data/sample/map/extconf.rb +0 -1
  63. data/test/embed_ruby.cpp +6 -15
  64. data/test/ext/t1/extconf.rb +0 -1
  65. data/test/ext/t2/extconf.rb +0 -1
  66. data/test/extconf.rb +0 -1
  67. data/test/test_Array.cpp +20 -24
  68. data/test/test_Attribute.cpp +6 -6
  69. data/test/test_Class.cpp +8 -47
  70. data/test/test_Constructor.cpp +0 -2
  71. data/test/test_Data_Object.cpp +25 -11
  72. data/test/test_Data_Type.cpp +124 -28
  73. data/test/test_Director.cpp +12 -13
  74. data/test/test_Enum.cpp +65 -26
  75. data/test/test_Inheritance.cpp +9 -9
  76. data/test/test_Iterator.cpp +134 -5
  77. data/test/test_Keep_Alive.cpp +7 -7
  78. data/test/test_Keep_Alive_No_Wrapper.cpp +80 -0
  79. data/test/test_Memory_Management.cpp +1 -1
  80. data/test/test_Module.cpp +25 -62
  81. data/test/test_Object.cpp +75 -3
  82. data/test/test_Ownership.cpp +12 -13
  83. data/test/test_Self.cpp +12 -13
  84. data/test/test_Stl_Map.cpp +696 -0
  85. data/test/test_Stl_Optional.cpp +3 -3
  86. data/test/test_Stl_Pair.cpp +38 -2
  87. data/test/test_Stl_Reference_Wrapper.cpp +102 -0
  88. data/test/test_Stl_SmartPointer.cpp +49 -9
  89. data/test/test_Stl_String.cpp +5 -2
  90. data/test/test_Stl_Unordered_Map.cpp +697 -0
  91. data/test/test_Stl_Variant.cpp +346 -0
  92. data/test/test_Stl_Vector.cpp +200 -41
  93. data/test/test_Struct.cpp +3 -3
  94. data/test/test_To_From_Ruby.cpp +8 -2
  95. data/test/test_Tracking.cpp +239 -0
  96. data/test/unittest.hpp +21 -4
  97. metadata +24 -13
  98. data/rice/detail/Exception_Handler.hpp +0 -8
  99. data/rice/detail/Exception_Handler.ipp +0 -28
  100. data/rice/detail/Iterator.hpp +0 -23
  101. data/rice/detail/Iterator.ipp +0 -47
  102. data/rice/detail/function_traits.hpp +0 -124
  103. data/rice/detail/method_data.hpp +0 -29
  104. data/rice/detail/rice_traits.hpp +0 -116
  105. data/rice/ruby_try_catch.hpp +0 -86
data/test/test_Module.cpp CHANGED
@@ -8,17 +8,23 @@ using namespace Rice;
8
8
 
9
9
  TESTSUITE(Module);
10
10
 
11
- SETUP(Object)
11
+ SETUP(Module)
12
12
  {
13
13
  embed_ruby();
14
14
  }
15
15
 
16
- TESTCASE(construct_from_value)
16
+ TESTCASE(FromConstant)
17
17
  {
18
18
  Module m(rb_mEnumerable);
19
19
  ASSERT_EQUAL(rb_mEnumerable, m.value());
20
20
  }
21
21
 
22
+ TESTCASE(FromName)
23
+ {
24
+ Module m("Enumerable");
25
+ ASSERT_EQUAL(rb_mEnumerable, m.value());
26
+ }
27
+
22
28
  namespace
23
29
  {
24
30
 
@@ -41,10 +47,11 @@ void throw_silly_exception(Object self)
41
47
 
42
48
  TESTCASE(add_handler)
43
49
  {
50
+ register_handler<Quite_Silly_Exception>(handle_silly_exception);
51
+
44
52
  Module m(anonymous_module());
45
- m.add_handler<Quite_Silly_Exception>(handle_silly_exception);
46
53
  m.define_singleton_method("foo", throw_silly_exception);
47
- Object exc = m.instance_eval("begin; foo; rescue Exception; $!; end");
54
+ Object exc = m.module_eval("begin; foo; rescue Exception; $!; end");
48
55
  ASSERT_EQUAL(rb_eRuntimeError, CLASS_OF(exc));
49
56
  Exception ex(exc);
50
57
  ASSERT_EQUAL(String("SILLY"), String(ex.what()));
@@ -80,8 +87,8 @@ TESTCASE(define_method)
80
87
  Module m(anonymous_module());
81
88
  m.define_method("some_method", some_method);
82
89
 
83
- Object o = m.instance_eval("$o = Object.new");
84
- Object result = m.instance_eval(R"EOS($o.extend(self)
90
+ Object o = m.module_eval("$o = Object.new");
91
+ Object result = m.module_eval(R"EOS($o.extend(self)
85
92
  $o.some_method)EOS");
86
93
  ASSERT_EQUAL(o, result);
87
94
  }
@@ -99,7 +106,7 @@ TESTCASE(define_module_function)
99
106
  Module m(anonymous_module());
100
107
  m.define_module_function("some_function", some_function);
101
108
 
102
- Object result = m.instance_eval(R"EOS(o = Object.new
109
+ Object result = m.module_eval(R"EOS(o = Object.new
103
110
  o.extend(self)
104
111
  o.instance_eval do
105
112
  some_function
@@ -130,7 +137,7 @@ TESTCASE(define_function_int)
130
137
  {
131
138
  Module m(anonymous_module());
132
139
  m.define_function("foo", function_int);
133
- Object result = m.instance_eval("o = Object.new; o.extend(self); o.foo(42)");
140
+ Object result = m.module_eval("o = Object.new; o.extend(self); o.foo(42)");
134
141
  ASSERT_EQUAL(42, detail::From_Ruby<int>().convert(result));
135
142
  }
136
143
 
@@ -138,7 +145,7 @@ TESTCASE(define_method_int)
138
145
  {
139
146
  Module m(anonymous_module());
140
147
  m.define_method("foo", method_int);
141
- Object result = m.instance_eval("o = Object.new; o.extend(self); o.foo(42)");
148
+ Object result = m.module_eval("o = Object.new; o.extend(self); o.foo(42)");
142
149
  ASSERT_EQUAL(42, detail::From_Ruby<int>().convert(result));
143
150
  }
144
151
 
@@ -162,7 +169,7 @@ TESTCASE(define_module_function_int)
162
169
  {
163
170
  Module m(anonymous_module());
164
171
  m.define_module_function("foo", function_int);
165
- Object result = m.instance_eval("o = Object.new; o.extend(self); o.instance_eval { foo(42) }");
172
+ Object result = m.module_eval("o = Object.new; o.extend(self); o.instance_eval { foo(42) }");
166
173
  ASSERT_EQUAL(42, detail::From_Ruby<int>().convert(result));
167
174
 
168
175
  result = m.call("foo", 42);
@@ -175,7 +182,7 @@ TESTCASE(method_int_passed_no_args)
175
182
  m.define_method("foo", method_int);
176
183
  ASSERT_EXCEPTION_CHECK(
177
184
  Exception,
178
- m.instance_eval("o = Object.new; o.extend(self); o.foo"),
185
+ m.module_eval("o = Object.new; o.extend(self); o.foo"),
179
186
  ASSERT_EQUAL(
180
187
  Object(rb_eArgError),
181
188
  Object(CLASS_OF(ex.value()))
@@ -204,50 +211,6 @@ TESTCASE(include_module)
204
211
  ASSERT_EQUAL(expected_ancestors, ancestors);
205
212
  }
206
213
 
207
- TESTCASE(const_set_get_by_id)
208
- {
209
- Module m(anonymous_module());
210
- Object v = detail::to_ruby(42);
211
- Module & m2(m.const_set(rb_intern("FOO"), v));
212
- ASSERT_EQUAL(&m, &m2);
213
- ASSERT_EQUAL(v, m.const_get(rb_intern("FOO")));
214
- }
215
-
216
- TESTCASE(const_set_get_by_identifier)
217
- {
218
- Module m(anonymous_module());
219
- Object v = detail::to_ruby(42);
220
- Module & m2(m.const_set(Identifier("FOO"), v));
221
- ASSERT_EQUAL(&m, &m2);
222
- ASSERT_EQUAL(v, m.const_get(Identifier("FOO")));
223
- }
224
-
225
- TESTCASE(const_set_get_by_string)
226
- {
227
- Module m(anonymous_module());
228
- Object v = detail::to_ruby(42);
229
- Module & m2(m.const_set("FOO", v));
230
- ASSERT_EQUAL(&m, &m2);
231
- ASSERT_EQUAL(v, m.const_get("FOO"));
232
- }
233
-
234
- TESTCASE(remove_const)
235
- {
236
- Module m(anonymous_module());
237
- Object v = detail::to_ruby(42);
238
- m.const_set("FOO", v);
239
- ASSERT_EQUAL(v, m.const_get("FOO"));
240
- m.remove_const("FOO");
241
- ASSERT_EXCEPTION_CHECK(
242
- Exception,
243
- m.const_get("FOO"),
244
- ASSERT_EQUAL(
245
- Object(rb_eNameError),
246
- Object(CLASS_OF(ex.value()))
247
- )
248
- );
249
- }
250
-
251
214
  TESTCASE(mod_name_anonymous)
252
215
  {
253
216
  Module m(anonymous_module());
@@ -274,7 +237,7 @@ TESTCASE(define_method_default_arguments)
274
237
  Module m(anonymous_module());
275
238
  m.define_function("foo", &defaults_method_one, Arg("arg1"), Arg("arg2") = 3, Arg("arg3") = true);
276
239
 
277
- Object o = m.instance_eval("o = Object.new; o.extend(self); o");
240
+ Object o = m.module_eval("o = Object.new; o.extend(self); o");
278
241
  o.call("foo", 2);
279
242
 
280
243
  ASSERT_EQUAL(2, defaults_method_one_arg1);
@@ -301,7 +264,7 @@ TESTCASE(default_arguments_still_throws_argument_error)
301
264
 
302
265
  ASSERT_EXCEPTION_CHECK(
303
266
  Exception,
304
- m.instance_eval("o = Object.new; o.extend(self); o.foo()"),
267
+ m.module_eval("o = Object.new; o.extend(self); o.foo()"),
305
268
  ASSERT_EQUAL(
306
269
  Object(rb_eArgError),
307
270
  Object(CLASS_OF(ex.value()))
@@ -310,7 +273,7 @@ TESTCASE(default_arguments_still_throws_argument_error)
310
273
 
311
274
  ASSERT_EXCEPTION_CHECK(
312
275
  Exception,
313
- m.instance_eval("o = Object.new; o.extend(self); o.foo(3, 4, false, 17)"),
276
+ m.module_eval("o = Object.new; o.extend(self); o.foo(3, 4, false, 17)"),
314
277
  ASSERT_EQUAL(
315
278
  Object(rb_eArgError),
316
279
  Object(CLASS_OF(ex.value()))
@@ -330,7 +293,7 @@ TESTCASE(defining_methods_with_single_default_argument)
330
293
  // define_method
331
294
  Module m(anonymous_module());
332
295
  m.define_function("foo", &method_with_one_default_arg, (Arg("num") = 4));
333
- m.instance_eval("o = Object.new; o.extend(self); o.foo()");
296
+ m.module_eval("o = Object.new; o.extend(self); o.foo()");
334
297
  ASSERT_EQUAL(4, the_one_default_arg);
335
298
 
336
299
  the_one_default_arg = 0;
@@ -448,7 +411,7 @@ TESTCASE(define_method_works_with_const_reference_return)
448
411
 
449
412
  Module m(anonymous_module());
450
413
 
451
- Object result = m.instance_eval("Factory.new.get_return_test");
414
+ Object result = m.module_eval("Factory.new.get_return_test");
452
415
 
453
416
  ASSERT_EQUAL("ReturnTest", result.class_of().name().c_str());
454
417
  }
@@ -531,7 +494,7 @@ TESTCASE(pointers)
531
494
  Module m = define_module("TestingModule");
532
495
 
533
496
  std::string code = "with_pointers(32, true, 33.0, 34.0)";
534
- m.instance_eval(code);
497
+ m.module_eval(code);
535
498
 
536
499
  ASSERT_EQUAL(intValue, 32);
537
500
  ASSERT_EQUAL(boolValue, true);
@@ -546,7 +509,7 @@ TESTCASE(references)
546
509
  Module m = define_module("TestingModule");
547
510
 
548
511
  std::string code = "with_references(42, true, 43.0, 44.0)";
549
- m.instance_eval(code);
512
+ m.module_eval(code);
550
513
 
551
514
  ASSERT_EQUAL(intValue, 42);
552
515
  ASSERT_EQUAL(boolValue, true);
data/test/test_Object.cpp CHANGED
@@ -172,9 +172,81 @@ TESTCASE(call_return_rice_object)
172
172
  ASSERT_EQUAL(Object(detail::to_ruby(3)), three);
173
173
  }
174
174
 
175
- /*TESTCASE(test_mark)
175
+ TESTCASE(call_with_keywords)
176
+ {
177
+ Module m(anonymous_module());
178
+
179
+ m.module_eval(R"(
180
+ def self.keywords_test(value, exception:)
181
+ if exception
182
+ raise "An exception!"
183
+ end
184
+
185
+ value
186
+ end
187
+ )");
188
+
189
+ Hash keywords;
190
+ keywords[":exception"] = false;
191
+ Object result = m.call_kw("keywords_test", "charlie", keywords);
192
+ ASSERT_EQUAL("charlie", detail::From_Ruby<const char*>().convert(result.value()));
193
+
194
+ keywords[":exception"] = true;
195
+
196
+ ASSERT_EXCEPTION_CHECK(
197
+ Exception,
198
+ m.call_kw("keywords_test", "charlie", keywords),
199
+ ASSERT_EQUAL("An exception!", ex.what())
200
+ );
201
+ }
202
+
203
+ TESTCASE(const_set_get_by_id)
204
+ {
205
+ Class c(anonymous_class());
206
+ Object v1 = detail::to_ruby(42);
207
+ Object v2 = c.const_set(rb_intern("FOO"), v1);
208
+ ASSERT_EQUAL(v1, v2);
209
+ ASSERT_EQUAL(v1, c.const_get(rb_intern("FOO")));
210
+ }
211
+
212
+ TESTCASE(const_set_get_by_identifier)
213
+ {
214
+ Class c(anonymous_class());
215
+ Object v1 = detail::to_ruby(42);
216
+ Object v2 = c.const_set(Identifier("FOO"), v1);
217
+ ASSERT_EQUAL(v1, v2);
218
+ ASSERT_EQUAL(v1, c.const_get(Identifier("FOO")));
219
+ }
220
+
221
+ TESTCASE(const_set_get_by_string)
222
+ {
223
+ Class c(anonymous_class());
224
+ Object v1 = detail::to_ruby(42);
225
+ Object v2 = c.const_set("FOO", v1);
226
+ ASSERT_EQUAL(v1, v2);
227
+ ASSERT_EQUAL(v1, c.const_get("FOO"));
228
+ }
229
+
230
+ TESTCASE(remove_const)
231
+ {
232
+ Module m(anonymous_module());
233
+ Object v = detail::to_ruby(42);
234
+ m.const_set("FOO", v);
235
+ ASSERT_EQUAL(v, m.const_get("FOO"));
236
+ m.remove_const("FOO");
237
+ ASSERT_EXCEPTION_CHECK(
238
+ Exception,
239
+ m.const_get("FOO"),
240
+ ASSERT_EQUAL(
241
+ Object(rb_eNameError),
242
+ Object(CLASS_OF(ex.value()))
243
+ )
244
+ );
245
+ }
246
+
247
+ TESTCASE(test_mark)
176
248
  {
177
249
  Object o(INT2NUM(42));
178
250
  rb_gc_start();
179
- ASSERT_EQUAL(42, detail::From_Ruby<int>::convert(o.value()));
180
- }*/
251
+ ASSERT_EQUAL(42, detail::From_Ruby<int>().convert(o.value()));
252
+ }
@@ -13,11 +13,11 @@ namespace
13
13
  class MyClass
14
14
  {
15
15
  public:
16
- static inline uint32_t constructorCalls = 0;
17
- static inline uint32_t copyConstructorCalls = 0;
18
- static inline uint32_t moveConstructorCalls = 0;
19
- static inline uint32_t destructorCalls = 0;
20
- static inline uint32_t methodCalls = 0;
16
+ static inline int constructorCalls = 0;
17
+ static inline int copyConstructorCalls = 0;
18
+ static inline int moveConstructorCalls = 0;
19
+ static inline int destructorCalls = 0;
20
+ static inline int methodCalls = 0;
21
21
 
22
22
  static void reset()
23
23
  {
@@ -145,7 +145,7 @@ TESTCASE(TransferPointer)
145
145
  my_class = nil
146
146
  end)";
147
147
 
148
- m.instance_eval(code);
148
+ m.module_eval(code);
149
149
  rb_gc_start();
150
150
 
151
151
  ASSERT_EQUAL(10, MyClass::constructorCalls);
@@ -169,7 +169,7 @@ TESTCASE(KeepPointer)
169
169
  my_class.set_flag(i)
170
170
  end)";
171
171
 
172
- m.instance_eval(code);
172
+ m.module_eval(code);
173
173
  rb_gc_start();
174
174
 
175
175
  ASSERT_EQUAL(1, MyClass::constructorCalls);
@@ -193,7 +193,7 @@ TESTCASE(KeepReference)
193
193
  my_class.set_flag(i)
194
194
  end)";
195
195
 
196
- m.instance_eval(code);
196
+ m.module_eval(code);
197
197
  rb_gc_start();
198
198
 
199
199
  ASSERT_EQUAL(1, MyClass::constructorCalls);
@@ -217,7 +217,7 @@ TESTCASE(CopyReference)
217
217
  my_class.set_flag(i)
218
218
  end)";
219
219
 
220
- m.instance_eval(code);
220
+ m.module_eval(code);
221
221
  rb_gc_start();
222
222
 
223
223
  ASSERT_EQUAL(1, MyClass::constructorCalls);
@@ -227,7 +227,7 @@ TESTCASE(CopyReference)
227
227
  ASSERT_EQUAL(0, Factory::instance_->flag);
228
228
  }
229
229
 
230
- /*TESTCASE(TransferValue)
230
+ TESTCASE(TransferValue)
231
231
  {
232
232
  Factory::reset();
233
233
  MyClass::reset();
@@ -240,7 +240,7 @@ TESTCASE(CopyReference)
240
240
  my_class.set_flag(i)
241
241
  end)";
242
242
 
243
- m.instance_eval(code);
243
+ m.module_eval(code);
244
244
  rb_gc_start();
245
245
 
246
246
  ASSERT_EQUAL(10, MyClass::constructorCalls);
@@ -263,7 +263,7 @@ TESTCASE(MoveValue)
263
263
  my_class.set_flag(i)
264
264
  end)";
265
265
 
266
- m.instance_eval(code);
266
+ m.module_eval(code);
267
267
  rb_gc_start();
268
268
 
269
269
  ASSERT_EQUAL(10, MyClass::constructorCalls);
@@ -272,4 +272,3 @@ TESTCASE(MoveValue)
272
272
  ASSERT_EQUAL(30, MyClass::destructorCalls);
273
273
  ASSERT(!Factory::instance_);
274
274
  }
275
- */
data/test/test_Self.cpp CHANGED
@@ -13,11 +13,11 @@ namespace
13
13
  class SelfClass
14
14
  {
15
15
  public:
16
- static inline uint32_t constructorCalls = 0;
17
- static inline uint32_t copyConstructorCalls = 0;
18
- static inline uint32_t moveConstructorCalls = 0;
19
- static inline uint32_t destructorCalls = 0;
20
- static inline uint32_t methodCalls = 0;
16
+ static inline int constructorCalls = 0;
17
+ static inline int copyConstructorCalls = 0;
18
+ static inline int moveConstructorCalls = 0;
19
+ static inline int destructorCalls = 0;
20
+ static inline int methodCalls = 0;
21
21
 
22
22
  static void reset()
23
23
  {
@@ -94,7 +94,7 @@ TESTCASE(SelfPointer)
94
94
  SelfClass::reset();
95
95
 
96
96
  Module m = define_module("TestingModule");
97
- Object selfClass1 = m.instance_eval("SelfClass.new");
97
+ Object selfClass1 = m.module_eval("SelfClass.new");
98
98
  Object selfClass2 = selfClass1.call("self_pointer");
99
99
  ASSERT(selfClass2.is_equal(selfClass1));
100
100
 
@@ -113,7 +113,7 @@ TESTCASE(SelfReference)
113
113
  SelfClass::reset();
114
114
 
115
115
  Module m = define_module("TestingModule");
116
- Object selfClass1 = m.instance_eval("SelfClass.new");
116
+ Object selfClass1 = m.module_eval("SelfClass.new");
117
117
  Object selfClass2 = selfClass1.call("self_reference");
118
118
  ASSERT(selfClass2.is_equal(selfClass1));
119
119
 
@@ -132,7 +132,7 @@ TESTCASE(SelfValue)
132
132
  SelfClass::reset();
133
133
 
134
134
  Module m = define_module("TestingModule");
135
- Object selfClass1 = m.instance_eval("SelfClass.new");
135
+ Object selfClass1 = m.module_eval("SelfClass.new");
136
136
  Object selfClass2 = selfClass1.call("self_value");
137
137
  ASSERT(!selfClass2.is_equal(selfClass1));
138
138
 
@@ -151,7 +151,7 @@ TESTCASE(SelfPointerLambda)
151
151
  SelfClass::reset();
152
152
 
153
153
  Module m = define_module("TestingModule");
154
- Object selfClass1 = m.instance_eval("SelfClass.new");
154
+ Object selfClass1 = m.module_eval("SelfClass.new");
155
155
  Object selfClass2 = selfClass1.call("self_pointer_lambda");
156
156
  ASSERT(selfClass2.is_equal(selfClass1));
157
157
 
@@ -162,8 +162,7 @@ TESTCASE(SelfPointerLambda)
162
162
  ASSERT_EQUAL(1, SelfClass::constructorCalls);
163
163
  ASSERT_EQUAL(0, SelfClass::copyConstructorCalls);
164
164
  ASSERT_EQUAL(0, SelfClass::moveConstructorCalls);
165
- // TODO: re-enable this. It fails regularly on Ubuntu + Ruby 2.7, and nothing else.
166
- // ASSERT_EQUAL(0, SelfClass::destructorCalls);
165
+ ASSERT_EQUAL(0, SelfClass::destructorCalls);
167
166
  }
168
167
 
169
168
  TESTCASE(SelfReferenceLambda)
@@ -171,7 +170,7 @@ TESTCASE(SelfReferenceLambda)
171
170
  SelfClass::reset();
172
171
 
173
172
  Module m = define_module("TestingModule");
174
- Object selfClass1 = m.instance_eval("SelfClass.new");
173
+ Object selfClass1 = m.module_eval("SelfClass.new");
175
174
  Object selfClass2 = selfClass1.call("self_reference_lambda");
176
175
  ASSERT(selfClass2.is_equal(selfClass1));
177
176
 
@@ -190,7 +189,7 @@ TESTCASE(SelfValueLambda)
190
189
  SelfClass::reset();
191
190
 
192
191
  Module m = define_module("TestingModule");
193
- Object selfClass1 = m.instance_eval("SelfClass.new");
192
+ Object selfClass1 = m.module_eval("SelfClass.new");
194
193
  Object selfClass2 = selfClass1.call("self_value_lambda");
195
194
  ASSERT(!selfClass2.is_equal(selfClass1));
196
195