rice 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_Module.cpp CHANGED
@@ -4,6 +4,7 @@
4
4
  #include "rice/Array.hpp"
5
5
  #include "rice/Arg.hpp"
6
6
  #include "rice/global_function.hpp"
7
+ #include "rice/Constructor.hpp"
7
8
 
8
9
  using namespace Rice;
9
10
 
@@ -256,13 +257,13 @@ TESTCASE(mod_name_anonymous)
256
257
  /**
257
258
  * Tests for default arguments
258
259
  */
259
- namespace
260
+ namespace
260
261
  {
261
262
  int defaults_method_one_arg1;
262
263
  int defaults_method_one_arg2;
263
264
  bool defaults_method_one_arg3 = false;
264
265
 
265
- void defaults_method_one(int arg1, int arg2 = 3, bool arg3 = true)
266
+ void defaults_method_one(int arg1, int arg2 = 3, bool arg3 = true)
266
267
  {
267
268
  defaults_method_one_arg1 = arg1;
268
269
  defaults_method_one_arg2 = arg2;
@@ -410,15 +411,10 @@ namespace {
410
411
  }
411
412
  }
412
413
 
413
- template<>
414
- std::string* from_ruby<std::string*>(Rice::Object x) {
415
- return new std::string(from_ruby<char const*>(x));
416
- }
417
-
418
- TESTCASE(define_method_works_with_reference_arguments)
414
+ TESTCASE(define_method_works_with_reference_arguments)
419
415
  {
420
416
  Module m(anonymous_module());
421
- m.define_module_function("foo", &with_defaults_and_references,
417
+ m.define_module_function("foo", &with_defaults_and_references,
422
418
  (Arg("x"), Arg("doIt") = false));
423
419
 
424
420
  m.call("foo", "test");
@@ -427,6 +423,38 @@ TESTCASE(define_method_works_with_reference_arguments)
427
423
  ASSERT(!with_defaults_and_references_doIt);
428
424
  }
429
425
 
426
+ namespace {
427
+ class ReturnTest { };
428
+
429
+ class Factory {
430
+ public:
431
+ Factory() { returnTest_ = new ReturnTest(); }
432
+
433
+ const ReturnTest& getReturnTest() const {
434
+ return *returnTest_;
435
+ }
436
+
437
+ private:
438
+ const ReturnTest* returnTest_;
439
+ };
440
+ }
441
+
442
+ TESTCASE(define_method_works_with_const_reference_return)
443
+ {
444
+ define_class<ReturnTest>("ReturnTest")
445
+ .define_constructor(Constructor<ReturnTest>());
446
+
447
+ define_class<Factory>("Factory")
448
+ .define_constructor(Constructor<Factory>())
449
+ .define_method("get_return_test", &Factory::getReturnTest);
450
+
451
+ Module m(anonymous_module());
452
+
453
+ Object result = m.instance_eval("Factory.new.get_return_test");
454
+
455
+ ASSERT_EQUAL("ReturnTest", result.class_of().name().c_str());
456
+ }
457
+
430
458
  /*
431
459
  namespace {
432
460
  float with_reference_defaults_x;
@@ -439,10 +467,10 @@ namespace {
439
467
  }
440
468
  }
441
469
 
442
- TESTCASE(define_method_works_with_reference_const_default_values)
470
+ TESTCASE(define_method_works_with_reference_const_default_values)
443
471
  {
444
472
  Module m(anonymous_module());
445
- m.define_module_function("bar", &with_reference_defaults,
473
+ m.define_module_function("bar", &with_reference_defaults,
446
474
  (Arg("x"), Arg("str") = std::string("testing")));
447
475
 
448
476
  m.call("bar", 3);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rice
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Brannan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-14 00:00:00 -05:00
13
+ date: 2010-01-10 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency