lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/3] git commit: refs/heads/master - Check for inert classes in inheritance chain
Date Sat, 06 Jul 2013 14:32:43 GMT
Updated Branches:
  refs/heads/master f74524e6c -> 6f661d5d2


Check for inert classes in inheritance chain


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/d339697f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/d339697f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/d339697f

Branch: refs/heads/master
Commit: d339697f552620607b114ce61747975193444e20
Parents: f74524e
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Tue Jul 2 18:34:18 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Jul 6 13:01:19 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/perl/t/401-class.t | 27 ++++++++++++++++++++++++++-
 clownfish/compiler/src/CFCClass.c     | 12 +++++++++++-
 2 files changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/d339697f/clownfish/compiler/perl/t/401-class.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/401-class.t b/clownfish/compiler/perl/t/401-class.t
index 5e37cc3..b45f024 100644
--- a/clownfish/compiler/perl/t/401-class.t
+++ b/clownfish/compiler/perl/t/401-class.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 54;
+use Test::More tests => 56;
 use Clownfish::CFC::Model::Class;
 use Clownfish::CFC::Parser;
 
@@ -250,3 +250,28 @@ $class_content = qq|
     }|;
 $class = $parser->parse($class_content);
 ok( $class->final, "final class_declaration" );
+
+Clownfish::CFC::Model::Class->_clear_registry();
+
+{
+    eval {
+        my $class = Clownfish::CFC::Model::Class->create(%foo_create_args);
+        my $inert = Clownfish::CFC::Model::Class->create(%inert_args);
+        $class->add_child($inert);
+    };
+    like( $@, qr/inert class/i, "inert class can't inherit" );
+
+    Clownfish::CFC::Model::Class->_clear_registry();
+}
+
+{
+    eval {
+        my $class = Clownfish::CFC::Model::Class->create(%foo_create_args);
+        my $inert = Clownfish::CFC::Model::Class->create(%inert_args);
+        $inert->add_child($class);
+    };
+    like( $@, qr/inert class/i, "can't inherit from inert class" );
+
+    Clownfish::CFC::Model::Class->_clear_registry();
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/d339697f/clownfish/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCClass.c b/clownfish/compiler/src/CFCClass.c
index 2476071..7e6767b 100644
--- a/clownfish/compiler/src/CFCClass.c
+++ b/clownfish/compiler/src/CFCClass.c
@@ -347,7 +347,17 @@ CFCClass_clear_registry(void) {
 void
 CFCClass_add_child(CFCClass *self, CFCClass *child) {
     CFCUTIL_NULL_CHECK(child);
-    if (self->tree_grown) { CFCUtil_die("Can't call add_child after grow_tree"); }
+    if (self->tree_grown) {
+        CFCUtil_die("Can't call add_child after grow_tree");
+    }
+    if (self->is_inert) {
+        CFCUtil_die("Can't inherit from inert class %s",
+                    CFCClass_get_class_name(self));
+    }
+    if (child->is_inert) {
+        CFCUtil_die("Inert class %s can't inherit",
+                    CFCClass_get_class_name(child));
+    }
     self->num_kids++;
     size_t size = (self->num_kids + 1) * sizeof(CFCClass*);
     self->children = (CFCClass**)REALLOCATE(self->children, size);


Mime
View raw message