lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/6] git commit: Don't use default parcel in tests
Date Tue, 18 Mar 2014 16:37:58 GMT
Repository: lucy-clownfish
Updated Branches:
  refs/heads/single-parcel-per-file [created] 168f3baa2


Don't use default parcel in tests


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

Branch: refs/heads/single-parcel-per-file
Commit: c0a8d8d61e30d0e1867aba16fcdada423500dca4
Parents: ecf4907
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Tue Mar 18 14:16:14 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Tue Mar 18 16:04:18 2014 +0100

----------------------------------------------------------------------
 compiler/perl/t/051-symbol.t         |  3 +++
 compiler/perl/t/105-object_type.t    | 10 +++++++---
 compiler/perl/t/108-composite_type.t | 11 +++++++++--
 compiler/perl/t/300-variable.t       | 16 ++++++++++++----
 compiler/perl/t/401-class.t          |  2 ++
 compiler/src/CFCTestClass.c          |  6 +++---
 compiler/src/CFCTestSymbol.c         |  3 ++-
 compiler/src/CFCTestType.c           | 14 ++++++++++----
 compiler/src/CFCTestVariable.c       |  4 ++--
 9 files changed, 50 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/perl/t/051-symbol.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/051-symbol.t b/compiler/perl/t/051-symbol.t
index 9356696..70d9f0e 100644
--- a/compiler/perl/t/051-symbol.t
+++ b/compiler/perl/t/051-symbol.t
@@ -19,6 +19,8 @@ use warnings;
 use Test::More tests => 40;
 use Clownfish::CFC;
 
+my $parcel = Clownfish::CFC::Model::Parcel->new( name => 'Parcel' );
+
 for (qw( foo 1Foo Foo_Bar 1FOOBAR )) {
     eval { my $thing = new_symbol( class_name => $_ ) };
     like( $@, qr/class_name/, "Reject invalid class name $_" );
@@ -76,6 +78,7 @@ is( $eep->full_sym,  "eep_Ork_ah_ah", "full_sym" );
 
 sub new_symbol {
     return Clownfish::CFC::Model::Symbol->new(
+        parcel    => $parcel,
         micro_sym => 'sym',
         exposure  => 'parcel',
         @_

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/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 9bdce59..04d7722 100644
--- a/compiler/perl/t/105-object_type.t
+++ b/compiler/perl/t/105-object_type.t
@@ -63,7 +63,9 @@ for my $specifier (@specifiers) {
         "nullable $specifier*" );
 }
 
-eval { my $type = Clownfish::CFC::Model::Type->new_object };
+eval {
+    my $type = Clownfish::CFC::Model::Type->new_object( parcel => 'Neato' );
+};
 like( $@, qr/specifier/i, "specifier required" );
 
 for ( 0, 2 ) {
@@ -146,8 +148,10 @@ $const_foo->resolve;
 ok( !$foo_type->equals($const_foo), "different const spoils equals" );
 like( $const_foo->to_c, qr/const/, "const included in C representation" );
 
-my $string_type
-    = Clownfish::CFC::Model::Type->new_object( specifier => 'String', );
+my $string_type = Clownfish::CFC::Model::Type->new_object(
+    parcel    => 'Neato',
+    specifier => 'String',
+);
 ok( !$foo_type->is_string_type,   "Not is_string_type" );
 ok( $string_type->is_string_type, "is_string_type" );
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/perl/t/108-composite_type.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/108-composite_type.t b/compiler/perl/t/108-composite_type.t
index 8a8369d..2bcdc81 100644
--- a/compiler/perl/t/108-composite_type.t
+++ b/compiler/perl/t/108-composite_type.t
@@ -21,6 +21,7 @@ use Clownfish::CFC::Model::Type;
 use Clownfish::CFC::Parser;
 
 my $parser = Clownfish::CFC::Parser->new;
+my $parcel = $parser->parse("parcel Neato;");
 
 my @composite_type_strings = (
     qw(
@@ -49,7 +50,10 @@ for my $input (@composite_type_strings) {
 eval { my $type = Clownfish::CFC::Model::Type->new_composite };
 like( $@, qr/child/i, "child required" );
 
-my $foo_type = Clownfish::CFC::Model::Type->new_object( specifier => 'Foo' );
+my $foo_type = Clownfish::CFC::Model::Type->new_object(
+    parcel    => $parcel,
+    specifier => 'Foo',
+);
 my $composite_type = Clownfish::CFC::Model::Type->new_composite(
     child       => $foo_type,
     indirection => 1,
@@ -64,7 +68,10 @@ my $other = Clownfish::CFC::Model::Type->new_composite(
 ok( $composite_type->equals($other), "equals" );
 ok( $composite_type->is_composite,   "is_composite" );
 
-my $bar_type = Clownfish::CFC::Model::Type->new_object( specifier => 'Bar' );
+my $bar_type = Clownfish::CFC::Model::Type->new_object(
+    parcel    => $parcel,
+    specifier => 'Bar',
+);
 my $bar_composite = Clownfish::CFC::Model::Type->new_composite(
     child       => $bar_type,
     indirection => 1,

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/perl/t/300-variable.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/300-variable.t b/compiler/perl/t/300-variable.t
index bc49d17..a5220e7 100644
--- a/compiler/perl/t/300-variable.t
+++ b/compiler/perl/t/300-variable.t
@@ -21,13 +21,14 @@ use Test::More tests => 13;
 BEGIN { use_ok('Clownfish::CFC::Model::Variable') }
 
 my $parser = Clownfish::CFC::Parser->new;
-$parser->parse('parcel Neato;')
+my $parcel = $parser->parse('parcel Neato;')
     or die "failed to process parcel_definition";
 
 sub new_type { $parser->parse(shift) }
 
 eval {
     my $death = Clownfish::CFC::Model::Variable->new(
+        parcel    => $parcel,
         micro_sym => 'foo',
         type      => new_type('int'),
         extra_arg => undef,
@@ -36,16 +37,22 @@ eval {
 like( $@, qr/extra_arg/, "Extra arg kills constructor" );
 
 eval {
-    my $death = Clownfish::CFC::Model::Variable->new( micro_sym => 'foo' );
+    my $death = Clownfish::CFC::Model::Variable->new(
+        parcel    => $parcel,
+        micro_sym => 'foo',
+    );
 };
 like( $@, qr/type/, "type is required" );
 eval {
-    my $death
-        = Clownfish::CFC::Model::Variable->new( type => new_type('int32_t') );
+    my $death = Clownfish::CFC::Model::Variable->new(
+        parcel => $parcel,
+        type   => new_type('int32_t'),
+    );
 };
 like( $@, qr/micro_sym/, "micro_sym is required" );
 
 my $var = Clownfish::CFC::Model::Variable->new(
+    parcel    => $parcel,
     micro_sym => 'foo',
     type      => new_type('float*')
 );
@@ -55,6 +62,7 @@ is( $var->local_declaration, 'float* foo;', "declaration" );
 ok( $var->local, "default to local access" );
 
 $var = Clownfish::CFC::Model::Variable->new(
+    parcel    => $parcel,
     micro_sym => 'foo',
     type      => new_type('float[1]')
 );

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/perl/t/401-class.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/401-class.t b/compiler/perl/t/401-class.t
index 1c83a90..85a1d09 100644
--- a/compiler/perl/t/401-class.t
+++ b/compiler/perl/t/401-class.t
@@ -21,6 +21,7 @@ use Clownfish::CFC::Model::Class;
 use Clownfish::CFC::Parser;
 
 my $parser = Clownfish::CFC::Parser->new;
+$parser->parse('parcel Neato;');
 
 my $thing = Clownfish::CFC::Model::Variable->new(
     parcel     => 'Neato',
@@ -29,6 +30,7 @@ my $thing = Clownfish::CFC::Model::Variable->new(
     micro_sym  => 'thing',
 );
 my $widget = Clownfish::CFC::Model::Variable->new(
+    parcel     => 'Neato',
     class_name => 'Widget',
     type       => $parser->parse('Widget*'),
     micro_sym  => 'widget',

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/src/CFCTestClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestClass.c b/compiler/src/CFCTestClass.c
index aa080ae..40c26f1 100644
--- a/compiler/src/CFCTestClass.c
+++ b/compiler/src/CFCTestClass.c
@@ -44,7 +44,7 @@ S_has_symbol(CFCSymbol **symbols, const char *micro_sym);
 
 const CFCTestBatch CFCTEST_BATCH_CLASS = {
     "Clownfish::CFC::Model::Class",
-    83,
+    85,
     S_run_tests
 };
 
@@ -52,7 +52,7 @@ static void
 S_run_tests(CFCTest *test) {
     CFCParser *parser = CFCParser_new();
 
-    CFCParcel *neato = CFCParcel_new("Neato", NULL, NULL, false);
+    CFCParcel *neato = CFCTest_parse_parcel(test, parser, "parcel Neato;");
     CFCFileSpec *file_spec = CFCFileSpec_new(".", "Foo/FooJr", 0);
     CFCClass *thing_class
         = CFCTest_parse_class(test, parser, "class Thing {}");
@@ -69,7 +69,7 @@ S_run_tests(CFCTest *test) {
                                 thing_type, 0);
 
         CFCType *widget_type = CFCTest_parse_type(test, parser, "Widget*");
-        widget = CFCVariable_new(NULL, NULL, "Widget", NULL, "widget",
+        widget = CFCVariable_new(neato, NULL, "Widget", NULL, "widget",
                                  widget_type, 0);
 
         CFCType *return_type = CFCTest_parse_type(test, parser, "void");

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/src/CFCTestSymbol.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestSymbol.c b/compiler/src/CFCTestSymbol.c
index 8f6518e..77659d8 100644
--- a/compiler/src/CFCTestSymbol.c
+++ b/compiler/src/CFCTestSymbol.c
@@ -36,7 +36,7 @@ const CFCTestBatch CFCTEST_BATCH_SYMBOL = {
 
 static void
 S_run_tests(CFCTest *test) {
-    CFCParcel *parcel = CFCParcel_default_parcel();
+    CFCParcel *parcel = CFCParcel_new("Parcel", NULL, NULL, false);
 
     {
         static const char *exposures[4] = {
@@ -145,6 +145,7 @@ S_run_tests(CFCTest *test) {
         CFCBase_decref((CFCBase*)eep);
     }
 
+    CFCBase_decref((CFCBase*)parcel);
     CFCParcel_reap_singletons();
 }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/src/CFCTestType.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestType.c b/compiler/src/CFCTestType.c
index 693613f..167a497 100644
--- a/compiler/src/CFCTestType.c
+++ b/compiler/src/CFCTestType.c
@@ -112,7 +112,7 @@ S_run_basic_tests(CFCTest *test) {
 
 static void
 S_run_primitive_tests(CFCTest *test) {
-    CFCParcel *parcel = CFCParcel_default_parcel();
+    CFCParcel *parcel = CFCParcel_new("Parcel", NULL, NULL, false);
     CFCType *type = CFCType_new(CFCTYPE_PRIMITIVE, parcel, "hump_t", 0);
     OK(test, CFCType_is_primitive(type), "is_primitive");
 
@@ -136,6 +136,7 @@ S_run_primitive_tests(CFCTest *test) {
     }
 
     CFCBase_decref((CFCBase*)type);
+    CFCBase_decref((CFCBase*)parcel);
 }
 
 static void
@@ -386,7 +387,8 @@ S_run_object_tests(CFCTest *test) {
     }
 
     {
-        CFCType *string_type = CFCType_new_object(0, NULL, "String", 1);
+        CFCType *string_type
+            = CFCType_new_object(0, neato_parcel, "String", 1);
         OK(test, CFCType_is_string_type(string_type), "%s", "is_string_type");
         OK(test, !CFCType_is_string_type(foo), "not %s", "not is_string_type");
         CFCBase_decref((CFCBase*)string_type);
@@ -462,6 +464,8 @@ S_run_arbitrary_tests(CFCTest *test) {
 static void
 S_run_composite_tests(CFCTest *test) {
     CFCParser *parser = CFCParser_new();
+    CFCParcel *neato_parcel = CFCParcel_new("Neato", NULL, NULL, false);
+    CFCParser_set_parcel(parser, neato_parcel);
 
     {
         static const char *type_strings[14] = {
@@ -490,8 +494,9 @@ S_run_composite_tests(CFCTest *test) {
     }
 
     {
-        CFCType *foo = CFCType_new_object(0, NULL, "Foo", 1);
-        CFCType *const_foo = CFCType_new_object(CFCTYPE_CONST, NULL, "Foo", 1);
+        CFCType *foo = CFCType_new_object(0, neato_parcel, "Foo", 1);
+        CFCType *const_foo
+            = CFCType_new_object(CFCTYPE_CONST, neato_parcel, "Foo", 1);
 
         CFCType *composite = CFCType_new_composite(0, foo, 1, NULL);
         OK(test, CFCType_is_composite(composite), "is_composite");
@@ -542,6 +547,7 @@ S_run_composite_tests(CFCTest *test) {
         CFCBase_decref((CFCBase*)foo_star_star);
     }
 
+    CFCBase_decref((CFCBase*)neato_parcel);
     CFCBase_decref((CFCBase*)parser);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c0a8d8d6/compiler/src/CFCTestVariable.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestVariable.c b/compiler/src/CFCTestVariable.c
index 022db0b..a68cd73 100644
--- a/compiler/src/CFCTestVariable.c
+++ b/compiler/src/CFCTestVariable.c
@@ -43,7 +43,7 @@ S_run_tests(CFCTest *test) {
     {
         CFCType *type = CFCTest_parse_type(test, parser, "float*");
         CFCVariable *var
-            = CFCVariable_new(NULL, NULL, NULL, NULL, "foo", type, 0);
+            = CFCVariable_new(neato_parcel, NULL, NULL, NULL, "foo", type, 0);
         CFCVariable_resolve_type(var);
         STR_EQ(test, CFCVariable_local_c(var), "float* foo", "local_c");
         STR_EQ(test, CFCVariable_local_declaration(var), "float* foo;",
@@ -57,7 +57,7 @@ S_run_tests(CFCTest *test) {
     {
         CFCType *type = CFCTest_parse_type(test, parser, "float[1]");
         CFCVariable *var
-            = CFCVariable_new(NULL, NULL, NULL, NULL, "foo", type, 0);
+            = CFCVariable_new(neato_parcel, NULL, NULL, NULL, "foo", type, 0);
         CFCVariable_resolve_type(var);
         STR_EQ(test, CFCVariable_local_c(var), "float foo[1]",
                "to_c appends array to var name rather than type specifier");


Mime
View raw message