lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [10/10] git commit: Fix CFC type tests
Date Mon, 17 Mar 2014 17:27:57 GMT
Fix CFC type tests

Make sure to resolve types before running the equality tests. Otherwise
they pass for the wrong reason. Also set the parcel for some types to
prepare for upcoming changes to type resolution.


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

Branch: refs/heads/explicit-dependencies-wip2
Commit: 170f5f907636eeb38fc332933ebf3d157014a973
Parents: 0b2d24e
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Mon Mar 17 16:43:20 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Mar 17 18:25:30 2014 +0100

----------------------------------------------------------------------
 compiler/perl/t/105-object_type.t | 31 ++++++++++++++++++++++++++-----
 compiler/src/CFCTestType.c        | 15 +++++++++++----
 2 files changed, 37 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/170f5f90/compiler/perl/t/105-object_type.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/105-object_type.t b/compiler/perl/t/105-object_type.t
index 6bf4c65..a9ac3fc 100644
--- a/compiler/perl/t/105-object_type.t
+++ b/compiler/perl/t/105-object_type.t
@@ -69,6 +69,7 @@ like( $@, qr/specifier/i, "specifier required" );
 for ( 0, 2 ) {
     eval {
         my $type = Clownfish::CFC::Model::Type->new_object(
+            parcel      => 'Neato',
             specifier   => 'Foo',
             indirection => $_,
         );
@@ -76,12 +77,27 @@ for ( 0, 2 ) {
     like( $@, qr/indirection/i, "invalid indirection of $_" );
 }
 
-my $foo_type = Clownfish::CFC::Model::Type->new_object( specifier => 'Foo' );
-my $another_foo
-    = Clownfish::CFC::Model::Type->new_object( specifier => 'Foo' );
+my $foo_type = Clownfish::CFC::Model::Type->new_object(
+    parcel    => 'Neato',
+    specifier => 'Foo',
+);
+$foo_type->resolve(\@classes);
+my $another_foo = Clownfish::CFC::Model::Type->new_object(
+    parcel    => 'Neato',
+    specifier => 'Foo',
+);
+$another_foo->resolve(\@classes);
 ok( $foo_type->equals($another_foo), "equals" );
 
-my $bar_type = Clownfish::CFC::Model::Type->new_object( specifier => 'Bar' );
+my $bar_class = Clownfish::CFC::Model::Class->create(
+    parcel     => 'Neato',
+    class_name => 'Bar',
+);
+my $bar_type = Clownfish::CFC::Model::Type->new_object(
+    parcel    => 'Neato',
+    specifier => 'Bar',
+);
+$bar_type->resolve([ $bar_class ]);
 ok( !$foo_type->equals($bar_type), "different specifier spoils equals" );
 
 my $foreign_foo_class = Clownfish::CFC::Model::Class->create(
@@ -89,8 +105,8 @@ my $foreign_foo_class = Clownfish::CFC::Model::Class->create(
     class_name => 'Foreign::Foo',
 );
 my $foreign_foo = Clownfish::CFC::Model::Type->new_object(
-    specifier => 'Foo',
     parcel    => 'Foreign',
+    specifier => 'Foo',
 );
 $foreign_foo->resolve([ $foreign_foo_class ]);
 ok( !$foo_type->equals($foreign_foo), "different parcel spoils equals" );
@@ -98,9 +114,11 @@ is( $foreign_foo->get_specifier, "foreign_Foo",
     "prepend parcel prefix to specifier" );
 
 my $incremented_foo = Clownfish::CFC::Model::Type->new_object(
+    parcel      => 'Neato',
     specifier   => 'Foo',
     incremented => 1,
 );
+$incremented_foo->resolve(\@classes);
 ok( $incremented_foo->incremented, "incremented" );
 ok( !$foo_type->incremented,       "not incremented" );
 ok( !$foo_type->equals($incremented_foo),
@@ -108,9 +126,11 @@ ok( !$foo_type->equals($incremented_foo),
 );
 
 my $decremented_foo = Clownfish::CFC::Model::Type->new_object(
+    parcel      => 'Neato',
     specifier   => 'Foo',
     decremented => 1,
 );
+$decremented_foo->resolve(\@classes);
 ok( $decremented_foo->decremented, "decremented" );
 ok( !$foo_type->decremented,       "not decremented" );
 ok( !$foo_type->equals($decremented_foo),
@@ -118,6 +138,7 @@ ok( !$foo_type->equals($decremented_foo),
 );
 
 my $const_foo = Clownfish::CFC::Model::Type->new_object(
+    parcel    => 'Neato',
     specifier => 'Foo',
     const     => 1,
 );

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/170f5f90/compiler/src/CFCTestType.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestType.c b/compiler/src/CFCTestType.c
index f452767..f0ce2d6 100644
--- a/compiler/src/CFCTestType.c
+++ b/compiler/src/CFCTestType.c
@@ -333,21 +333,27 @@ S_run_object_tests(CFCTest *test) {
         = CFCClass_create(neato_parcel, NULL, "Foo", NULL, NULL, NULL, NULL,
                           NULL, false, false);
     CFCClass *class_list[2] = { foo_class, NULL };
-    CFCType *foo = CFCType_new_object(0, NULL, "Foo", 1);
+    CFCType *foo = CFCType_new_object(0, neato_parcel, "Foo", 1);
     CFCType_resolve(foo, class_list);
 
     {
-        CFCType *another_foo = CFCType_new_object(0, NULL, "Foo", 1);
+        CFCType *another_foo = CFCType_new_object(0, neato_parcel, "Foo", 1);
         CFCType_resolve(another_foo, class_list);
         OK(test, CFCType_equals(foo, another_foo), "equals");
         CFCBase_decref((CFCBase*)another_foo);
     }
 
     {
-        CFCType *bar = CFCType_new_object(0, NULL, "Bar", 1);
+        CFCClass *bar_class
+            = CFCClass_create(neato_parcel, NULL, "Bar", NULL, NULL, NULL,
+                              NULL, NULL, false, false);
+        CFCType *bar = CFCType_new_object(0, neato_parcel, "Bar", 1);
+        CFCClass *bar_class_list[2] = { bar_class, NULL };
+        CFCType_resolve(bar, bar_class_list);
         OK(test, !CFCType_equals(foo, bar),
            "different specifier spoils equals");
         CFCBase_decref((CFCBase*)bar);
+        CFCBase_decref((CFCBase*)bar_class);
     }
 
     {
@@ -371,7 +377,8 @@ S_run_object_tests(CFCTest *test) {
     {
         for (int i = 0; i < 4; ++i) {
             CFCType *modified_foo
-                = CFCType_new_object(flags[i], NULL, "Foo", 1);
+                = CFCType_new_object(flags[i], neato_parcel, "Foo", 1);
+            CFCType_resolve(modified_foo, class_list);
             OK(test, accessors[i](modified_foo), "%s", modifiers[i]);
             OK(test, !accessors[i](foo), "not %s", modifiers[i]);
             OK(test, !CFCType_equals(foo, modified_foo),


Mime
View raw message