You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/01/28 20:30:40 UTC

[lucy-commits] git commit: refs/heads/cfc-tests - Start to port CFC tests to C

Updated Branches:
  refs/heads/cfc-tests [created] 3a9cef14e


Start to port CFC tests to C


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

Branch: refs/heads/cfc-tests
Commit: 3a9cef14e0bb64934fece3b56afb2254ef7c97ba
Parents: 1715fcd
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Jan 23 22:56:33 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Jan 28 20:29:59 2013 +0100

----------------------------------------------------------------------
 clownfish/compiler/include/CFC.h                  |    1 +
 clownfish/compiler/perl/lib/Clownfish/CFC.pm      |   19 +
 clownfish/compiler/perl/lib/Clownfish/CFC.xs      |   42 ++
 clownfish/compiler/perl/lib/Clownfish/CFC/Test.pm |   20 +
 clownfish/compiler/perl/t/core/001-util.t         |   23 +
 clownfish/compiler/perl/t/core/050-docucomment.t  |   23 +
 clownfish/compiler/perl/t/core/051-symbol.t       |   23 +
 clownfish/compiler/perl/t/core/052-version.t      |   23 +
 clownfish/compiler/perl/t/core/100-type.t         |   23 +
 clownfish/compiler/perl/t/core/200-function.t     |   23 +
 clownfish/compiler/perl/t/core/201-method.t       |   23 +
 clownfish/compiler/perl/typemap                   |    1 +
 clownfish/compiler/src/CFCTest.c                  |  399 ++++++++++++
 clownfish/compiler/src/CFCTest.h                  |  101 +++
 clownfish/compiler/src/CFCTestDocuComment.c       |  106 ++++
 clownfish/compiler/src/CFCTestFunction.c          |   76 +++
 clownfish/compiler/src/CFCTestMethod.c            |  244 ++++++++
 clownfish/compiler/src/CFCTestSymbol.c            |  144 +++++
 clownfish/compiler/src/CFCTestType.c              |  507 ++++++++++++++++
 clownfish/compiler/src/CFCTestUtil.c              |  169 +++++
 clownfish/compiler/src/CFCTestVersion.c           |   69 +++
 21 files changed, 2059 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/include/CFC.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/include/CFC.h b/clownfish/compiler/include/CFC.h
index 93f530e..643263e 100644
--- a/clownfish/compiler/include/CFC.h
+++ b/clownfish/compiler/include/CFC.h
@@ -29,6 +29,7 @@
 #include "CFCParcel.h"
 #include "CFCParser.h"
 #include "CFCSymbol.h"
+#include "CFCTest.h"
 #include "CFCType.h"
 #include "CFCUtil.h"
 #include "CFCVariable.h"

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/lib/Clownfish/CFC.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC.pm b/clownfish/compiler/perl/lib/Clownfish/CFC.pm
index 29487be..6635096 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.pm
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.pm
@@ -849,6 +849,25 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.01' ) }
     }
 }
 
+{
+    package Clownfish::CFC::Test;
+    BEGIN { push our @ISA, 'Clownfish::CFC::Base' }
+    use Clownfish::CFC::Util qw( verify_args );
+    use Carp;
+
+    my %new_PARAMS = (
+        formatter_name => 'tap',
+    );
+
+    sub new {
+        my ( $either, %args ) = @_;
+        verify_args( \%new_PARAMS, %args ) or confess $@;
+        confess "no subclassing allowed" unless $either eq __PACKAGE__;
+        $args{formatter_name} = 'tap' unless defined $args{formatter_name};
+        return _new( @args{qw( formatter_name )} );
+    }
+}
+
 1;
 
 =head1 NAME

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC.xs b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
index 415338e..c461922 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.xs
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
@@ -2389,3 +2389,45 @@ CODE:
     RETVAL = S_cfcbase_to_perlref((CFCBase*)parcel);
 OUTPUT: RETVAL
 
+
+MODULE = Clownfish::CFC   PACKAGE = Clownfish::CFC::Test
+
+SV*
+_new(formatter_name)
+    const char *formatter_name;
+CODE:
+    CFCTest *self = CFCTest_new(formatter_name);
+    RETVAL = S_cfcbase_to_perlref(self);
+    CFCBase_decref((CFCBase*)self);
+OUTPUT: RETVAL
+
+void
+run_batch(self, klass)
+    CFCTest *self;
+    const char *klass;
+PPCODE:
+    if (strcmp(klass, "Clownfish::CFC::Model::DocuComment") == 0) {
+        CFCTestDocuComment_run(self);
+    }
+    else if (strcmp(klass, "Clownfish::CFC::Model::Function") == 0) {
+        CFCTestFunction_run(self);
+    }
+    else if (strcmp(klass, "Clownfish::CFC::Model::Method") == 0) {
+        CFCTestMethod_run(self);
+    }
+    else if (strcmp(klass, "Clownfish::CFC::Model::Symbol") == 0) {
+        CFCTestSymbol_run(self);
+    }
+    else if (strcmp(klass, "Clownfish::CFC::Model::Type") == 0) {
+        CFCTestType_run(self);
+    }
+    else if (strcmp(klass, "Clownfish::CFC::Model::Version") == 0) {
+        CFCTestVersion_run(self);
+    }
+    else if (strcmp(klass, "Clownfish::CFC::Util") == 0) {
+        CFCTestUtil_run(self);
+    }
+    else {
+        croak("No tests found for class '%s'", klass);
+    }
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/lib/Clownfish/CFC/Test.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC/Test.pm b/clownfish/compiler/perl/lib/Clownfish/CFC/Test.pm
new file mode 100644
index 0000000..bebd673
--- /dev/null
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC/Test.pm
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+package Clownfish::CFC::Test;
+use Clownfish::CFC;
+
+1;
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/001-util.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/core/001-util.t b/clownfish/compiler/perl/t/core/001-util.t
new file mode 100644
index 0000000..1508f25
--- /dev/null
+++ b/clownfish/compiler/perl/t/core/001-util.t
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+use Clownfish::CFC::Test;
+
+my $test = Clownfish::CFC::Test->new;
+$test->run_batch('Clownfish::CFC::Util');
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/050-docucomment.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/core/050-docucomment.t b/clownfish/compiler/perl/t/core/050-docucomment.t
new file mode 100644
index 0000000..5054cd3
--- /dev/null
+++ b/clownfish/compiler/perl/t/core/050-docucomment.t
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+use Clownfish::CFC::Test;
+
+my $test = Clownfish::CFC::Test->new;
+$test->run_batch('Clownfish::CFC::Model::DocuComment');
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/051-symbol.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/core/051-symbol.t b/clownfish/compiler/perl/t/core/051-symbol.t
new file mode 100644
index 0000000..b3a7307
--- /dev/null
+++ b/clownfish/compiler/perl/t/core/051-symbol.t
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+use Clownfish::CFC::Test;
+
+my $test = Clownfish::CFC::Test->new;
+$test->run_batch('Clownfish::CFC::Model::Symbol');
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/052-version.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/core/052-version.t b/clownfish/compiler/perl/t/core/052-version.t
new file mode 100644
index 0000000..ef220bb
--- /dev/null
+++ b/clownfish/compiler/perl/t/core/052-version.t
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+use Clownfish::CFC::Test;
+
+my $test = Clownfish::CFC::Test->new;
+$test->run_batch('Clownfish::CFC::Model::Version');
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/100-type.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/core/100-type.t b/clownfish/compiler/perl/t/core/100-type.t
new file mode 100644
index 0000000..3a7cdc5
--- /dev/null
+++ b/clownfish/compiler/perl/t/core/100-type.t
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+use Clownfish::CFC::Test;
+
+my $test = Clownfish::CFC::Test->new;
+$test->run_batch('Clownfish::CFC::Model::Type');
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/200-function.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/core/200-function.t b/clownfish/compiler/perl/t/core/200-function.t
new file mode 100644
index 0000000..e22af70
--- /dev/null
+++ b/clownfish/compiler/perl/t/core/200-function.t
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+use Clownfish::CFC::Test;
+
+my $test = Clownfish::CFC::Test->new;
+$test->run_batch('Clownfish::CFC::Model::Function');
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/201-method.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/core/201-method.t b/clownfish/compiler/perl/t/core/201-method.t
new file mode 100644
index 0000000..c926593
--- /dev/null
+++ b/clownfish/compiler/perl/t/core/201-method.t
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+use Clownfish::CFC::Test;
+
+my $test = Clownfish::CFC::Test->new;
+$test->run_batch('Clownfish::CFC::Model::Method');
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/typemap
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/typemap b/clownfish/compiler/perl/typemap
index d746181..17be341 100644
--- a/clownfish/compiler/perl/typemap
+++ b/clownfish/compiler/perl/typemap
@@ -29,6 +29,7 @@ CFCParamList*	CLOWNFISH_MODEL
 CFCParcel*	CLOWNFISH_MODEL
 CFCParser*	CLOWNFISH_TYPE
 CFCSymbol*	CLOWNFISH_MODEL
+CFCTest*	CLOWNFISH_TYPE
 CFCType*	CLOWNFISH_MODEL
 CFCVariable*	CLOWNFISH_MODEL
 CFCVersion*	CLOWNFISH_MODEL

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTest.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTest.c b/clownfish/compiler/src/CFCTest.c
new file mode 100644
index 0000000..0085aa9
--- /dev/null
+++ b/clownfish/compiler/src/CFCTest.c
@@ -0,0 +1,399 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#define CFC_NEED_BASE_STRUCT_DEF
+#define CFC_USE_TEST_MACROS
+#include "CFCTest.h"
+#include "CFCBase.h"
+#include "CFCFunction.h"
+#include "CFCMethod.h"
+#include "CFCParamList.h"
+#include "CFCParcel.h"
+#include "CFCParser.h"
+#include "CFCType.h"
+#include "CFCUtil.h"
+
+struct CFCTestFormatter {
+    void (*start_batch)(const char *name, int num_planned);
+    void (*vtest_result)(int pass, int test_num, const char *fmt,
+                         va_list args);
+    void (*test_comment)(const char *fmt, ...);
+    void (*batch_comment)(const char *fmt, ...);
+    void (*summary)(CFCTest *test);
+};
+typedef struct CFCTestFormatter CFCTestFormatter;
+
+struct CFCTest {
+    CFCBase base;
+    CFCTestFormatter *formatter;
+    int num_tests;
+    int num_tests_failed;
+    int num_batches;
+    int num_batches_failed;
+    int batch_num_tests;
+    int batch_num_failed;
+    int batch_num_planned;
+};
+
+const static CFCMeta CFCTEST_META = {
+    "Clownfish::CFC::Test",
+    sizeof(CFCTest),
+    (CFCBase_destroy_t)CFCTest_destroy
+};
+
+static void
+S_vtest_true(CFCTest *self, int cond, const char *fmt, va_list args);
+
+static void
+S_finish_batch(CFCTest *self);
+
+static void
+S_format_cfish_start_batch(const char *name, int num_planned);
+
+static void
+S_format_cfish_vtest_result(int pass, int test_num, const char *fmt,
+                            va_list args);
+
+static void
+S_format_cfish_test_comment(const char *fmt, ...);
+
+static void
+S_format_cfish_batch_comment(const char *fmt, ...);
+
+static void
+S_format_cfish_summary(CFCTest *test);
+
+static CFCTestFormatter S_formatter_cfish = {
+    S_format_cfish_start_batch,
+    S_format_cfish_vtest_result,
+    S_format_cfish_test_comment,
+    S_format_cfish_batch_comment,
+    S_format_cfish_summary
+};
+
+static void
+S_format_tap_start_batch(const char *name, int num_planned);
+
+static void
+S_format_tap_vtest_result(int pass, int test_num, const char *fmt,
+                         va_list args);
+
+static void
+S_format_tap_test_comment(const char *fmt, ...);
+
+static void
+S_format_tap_batch_comment(const char *fmt, ...);
+
+static void
+S_format_tap_summary(CFCTest *test);
+
+static CFCTestFormatter S_formatter_tap = {
+    S_format_tap_start_batch,
+    S_format_tap_vtest_result,
+    S_format_tap_test_comment,
+    S_format_tap_batch_comment,
+    S_format_tap_summary
+};
+
+CFCTest*
+CFCTest_new(const char *formatter_name) {
+    CFCTest *self = (CFCTest*)CFCBase_allocate(&CFCTEST_META);
+    return CFCTest_init(self, formatter_name);
+}
+
+CFCTest*
+CFCTest_init(CFCTest *self, const char *formatter_name) {
+    if (strcmp(formatter_name, "clownfish") == 0) {
+        self->formatter = &S_formatter_cfish;
+    }
+    else if (strcmp(formatter_name, "tap") == 0) {
+        self->formatter = &S_formatter_tap;
+    }
+    else {
+        CFCUtil_die("Unknown formatter name '%s'", formatter_name);
+    }
+
+    self->num_tests          = 0;
+    self->num_tests_failed   = 0;
+    self->num_batches        = 0;
+    self->num_batches_failed = 0;
+    self->batch_num_planned  = 0;
+    self->batch_num_tests    = 0;
+    self->batch_num_failed   = 0;
+
+    return self;
+}
+
+void
+CFCTest_destroy(CFCTest *self) {
+    CFCBase_destroy((CFCBase*)self);
+}
+
+void
+CFCTest_start_batch(CFCTest *self, const char *name, int num_planned) {
+    S_finish_batch(self);
+
+    self->formatter->start_batch(name, num_planned);
+
+    self->batch_num_planned = num_planned;
+}
+
+void
+CFCTest_test_true(CFCTest *self, int cond, const char *fmt, ...) {
+    va_list args;
+    va_start(args, fmt);
+    S_vtest_true(self, cond, fmt, args);
+    va_end(args);
+}
+
+void
+CFCTest_test_string_equals(CFCTest *self, const char *result,
+                           const char *expected, const char *fmt, ...) {
+    int cond = (strcmp(result, expected) == 0);
+
+    va_list args;
+    va_start(args, fmt);
+    S_vtest_true(self, cond, fmt, args);
+    va_end(args);
+
+    if (!cond) {
+        self->formatter->test_comment("Expected '%s', got '%s'.\n",
+                                      expected, result);
+    }
+}
+
+void
+CFCTest_test_int_equals(CFCTest *self, long result, long expected,
+                        const char *fmt, ...) {
+    int cond = (result == expected);
+
+    va_list args;
+    va_start(args, fmt);
+    S_vtest_true(self, cond, fmt, args);
+    va_end(args);
+
+    if (!cond) {
+        self->formatter->test_comment("Expected '%ld', got '%ld'.\n",
+                                      expected, result);
+    }
+}
+
+void
+CFCTest_skip(CFCTest *self, int num) {
+    self->num_tests       += num;
+    self->batch_num_tests += num;
+}
+
+int
+CFCTest_finish(CFCTest *self) {
+    S_finish_batch(self);
+
+    self->formatter->summary(self);
+
+    return self->num_batches != 0 && self->num_batches_failed == 0;
+}
+
+static void
+S_vtest_true(CFCTest *self, int cond, const char *fmt, va_list args) {
+    self->num_tests       += 1;
+    self->batch_num_tests += 1;
+
+    if (!cond) {
+        self->num_tests_failed += 1;
+        self->batch_num_failed += 1;
+    }
+
+    self->formatter->vtest_result(cond, self->batch_num_tests, fmt, args);
+}
+
+static void
+S_finish_batch(CFCTest *self) {
+    int batch_failed = 0;
+    void (*batch_comment)(const char *fmt, ...)
+        = self->formatter->batch_comment;
+
+    if (self->batch_num_planned == 0) {
+        if (self->batch_num_tests != 0) {
+            batch_failed = 1;
+            batch_comment("Bad plan: You ran %d tests without plan.\n",
+                          self->batch_num_tests);
+        }
+        else {
+            // No tests run
+            return;
+        }
+    }
+    else {
+        if (self->batch_num_failed > 0) {
+            batch_failed = 1;
+            batch_comment("%d/%d tests failed.\n", self->batch_num_failed,
+                   self->batch_num_tests);
+        }
+        if (self->batch_num_tests != self->batch_num_planned) {
+            batch_failed = 1;
+            batch_comment("Bad plan: You planned %d tests but ran %d.\n",
+                          self->batch_num_planned, self->batch_num_tests);
+        }
+    }
+
+    if (batch_failed) {
+        self->num_batches_failed += 1;
+    }
+
+    self->num_batches += 1;
+    self->batch_num_planned = 0;
+    self->batch_num_tests  = 0;
+    self->batch_num_failed = 0;
+}
+
+static void
+S_format_cfish_start_batch(const char *name, int num_planned) {
+    printf("Testing %s...\n", name);
+}
+
+static void
+S_format_cfish_vtest_result(int pass, int test_num, const char *fmt,
+                          va_list args) {
+    if (!pass) {
+        printf("  Failed test %d: ", test_num);
+        vprintf(fmt, args);
+        printf("\n");
+    }
+}
+
+static void
+S_format_cfish_test_comment(const char *fmt, ...) {
+    printf("    ");
+
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+}
+
+static void
+S_format_cfish_batch_comment(const char *fmt, ...) {
+    printf("  ");
+
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+}
+
+static void
+S_format_cfish_summary(CFCTest *test) {
+    if (test->num_batches == 0) {
+        printf("No tests planned or run.\n");
+    }
+    else if (test->num_batches_failed == 0) {
+        printf("Result: PASS\n");
+    }
+    else {
+        printf("Result: FAIL\n");
+        printf("%d/%d batches failed. %d/%d tests failed.\n",
+               test->num_batches_failed, test->num_batches,
+               test->num_tests_failed, test->num_tests);
+    }
+}
+
+static void
+S_format_tap_start_batch(const char *name, int num_planned) {
+    printf("1..%d\n", num_planned);
+}
+
+static void
+S_format_tap_vtest_result(int pass, int test_num, const char *fmt,
+                         va_list args) {
+    const char *result = pass ? "ok" : "not ok";
+    printf("%s %d - ", result, test_num);
+    vprintf(fmt, args);
+    printf("\n");
+}
+
+static void
+S_format_tap_test_comment(const char *fmt, ...) {
+    printf("#   ");
+
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+}
+
+static void
+S_format_tap_batch_comment(const char *fmt, ...) {
+    printf("# ");
+
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+}
+
+static void
+S_format_tap_summary(CFCTest *test) {
+}
+
+CFCParcel*
+CFCTest_parse_parcel(CFCTest *test, CFCParser *parser, const char *src) {
+    CFCBase *result = CFCParser_parse(parser, src);
+    OK(test, result != NULL, "parse '%s'", src);
+    STR_EQ(test, CFCBase_get_cfc_class(result),
+           "Clownfish::CFC::Model::Parcel", "result class of '%s'", src);
+    return (CFCParcel*)result;
+}
+
+CFCType*
+CFCTest_parse_type(CFCTest *test, CFCParser *parser, const char *src) {
+    CFCBase *result = CFCParser_parse(parser, src);
+    OK(test, result != NULL, "parse '%s'", src);
+    STR_EQ(test, CFCBase_get_cfc_class(result),
+           "Clownfish::CFC::Model::Type", "result class of '%s'", src);
+    return (CFCType*)result;
+}
+
+CFCParamList*
+CFCTest_parse_param_list(CFCTest *test, CFCParser *parser, const char *src) {
+    CFCBase *result = CFCParser_parse(parser, src);
+    OK(test, result != NULL, "parse '%s'", src);
+    STR_EQ(test, CFCBase_get_cfc_class(result),
+           "Clownfish::CFC::Model::ParamList", "result class of '%s'", src);
+    return (CFCParamList*)result;
+}
+
+CFCFunction*
+CFCTest_parse_function(CFCTest *test, CFCParser *parser, const char *src) {
+    CFCBase *result = CFCParser_parse(parser, src);
+    OK(test, result != NULL, "parse '%s'", src);
+    STR_EQ(test, CFCBase_get_cfc_class(result),
+           "Clownfish::CFC::Model::Function", "result class of '%s'", src);
+    return (CFCFunction*)result;
+}
+
+CFCMethod*
+CFCTest_parse_method(CFCTest *test, CFCParser *parser, const char *src) {
+    CFCBase *result = CFCParser_parse(parser, src);
+    OK(test, result != NULL, "parse '%s'", src);
+    STR_EQ(test, CFCBase_get_cfc_class(result),
+           "Clownfish::CFC::Model::Method", "result class of '%s'", src);
+    return (CFCMethod*)result;
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTest.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTest.h b/clownfish/compiler/src/CFCTest.h
new file mode 100644
index 0000000..cf8f3ac
--- /dev/null
+++ b/clownfish/compiler/src/CFCTest.h
@@ -0,0 +1,101 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef H_TEST_CFC
+#define H_TEST_CFC
+
+#ifdef CFC_USE_TEST_MACROS
+  #define OK      CFCTest_test_true
+  #define STR_EQ  CFCTest_test_string_equals
+  #define INT_EQ  CFCTest_test_int_equals
+#endif
+
+typedef struct CFCTest CFCTest;
+struct CFCFunction;
+struct CFCParamList;
+struct CFCParcel;
+struct CFCParser;
+struct CFCType;
+
+CFCTest*
+CFCTest_new(const char *formatter_name);
+
+CFCTest*
+CFCTest_init(CFCTest *self, const char *formatter_name);
+
+void
+CFCTest_destroy(CFCTest *self);
+
+void
+CFCTest_start_batch(CFCTest *self, const char *name, int num_planned);
+
+void
+CFCTest_test_true(CFCTest *self, int cond, const char *fmt, ...);
+
+void
+CFCTest_test_string_equals(CFCTest *self, const char *result,
+                           const char *expect, const char *fmt, ...);
+
+void
+CFCTest_test_int_equals(CFCTest *self, long result, long expected,
+                        const char *fmt, ...);
+
+void
+CFCTest_skip(CFCTest *self, int num);
+
+int
+CFCTest_finish(CFCTest *self);
+
+struct CFCParcel*
+CFCTest_parse_parcel(CFCTest *test, struct CFCParser *parser, const char *src);
+
+struct CFCType*
+CFCTest_parse_type(CFCTest *test, struct CFCParser *parser, const char *src);
+
+struct CFCParamList*
+CFCTest_parse_param_list(CFCTest *test, struct CFCParser *parser,
+                         const char *src);
+
+struct CFCFunction*
+CFCTest_parse_function(CFCTest *test, struct CFCParser *parser,
+                       const char *src);
+
+struct CFCMethod*
+CFCTest_parse_method(CFCTest *test, struct CFCParser *parser, const char *src);
+
+void
+CFCTestDocuComment_run(CFCTest *test);
+
+void
+CFCTestFunction_run(CFCTest *test);
+
+void
+CFCTestMethod_run(CFCTest *test);
+
+void
+CFCTestSymbol_run(CFCTest *test);
+
+void
+CFCTestType_run(CFCTest *test);
+
+void
+CFCTestUtil_run(CFCTest *test);
+
+void
+CFCTestVersion_run(CFCTest *test);
+
+#endif /* H_TEST_CFC */
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTestDocuComment.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestDocuComment.c b/clownfish/compiler/src/CFCTestDocuComment.c
new file mode 100644
index 0000000..c17f27d
--- /dev/null
+++ b/clownfish/compiler/src/CFCTestDocuComment.c
@@ -0,0 +1,106 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CFC_USE_TEST_MACROS
+#include "CFCBase.h"
+#include "CFCDocuComment.h"
+#include "CFCParser.h"
+#include "CFCTest.h"
+#include "CFCUtil.h"
+
+static void
+S_run_tests(CFCTest *test);
+
+void
+CFCTestDocuComment_run(CFCTest *test) {
+    CFCTest_start_batch(test, "docucomment", 15);
+    S_run_tests(test);
+}
+
+static void
+S_run_tests(CFCTest *test) {
+    CFCDocuComment *docucomment;
+
+    docucomment = CFCDocuComment_parse("/** foo. */");
+    OK(test, docucomment != NULL, "parse");
+    CFCBase_decref((CFCBase*)docucomment);
+
+    CFCParser *parser = CFCParser_new();
+    const char *text =
+        "/**\n"
+        " * Brief description.  Long description.\n"
+        " *\n"
+        " * More long description.\n"
+        " *\n"
+        " * @param foo A foo.\n"
+        " * @param bar A bar.\n"
+        " *\n"
+        " * @param baz A baz.\n"
+        " * @return a return value.\n"
+        " */\n";
+    CFCBase *result = CFCParser_parse(parser, text);
+    OK(test, result != NULL, "parse with CFCParser");
+    const char *klass = CFCBase_get_cfc_class(result);
+    STR_EQ(test, klass, "Clownfish::CFC::Model::DocuComment", "result class");
+    docucomment = (CFCDocuComment*)result;
+
+    const char *brief_desc = CFCDocuComment_get_brief(docucomment);
+    const char *brief_expect = "Brief description.";
+    STR_EQ(test, brief_desc, brief_expect, "brief description");
+
+    const char *long_desc = CFCDocuComment_get_long(docucomment);
+    const char *long_expect =
+        "Long description.\n"
+        "\n"
+        "More long description.";
+    STR_EQ(test, long_desc, long_expect, "long description");
+
+    const char *description = CFCDocuComment_get_description(docucomment);
+    char *desc_expect = CFCUtil_sprintf("%s  %s", brief_expect, long_expect);
+    STR_EQ(test, description, desc_expect, "description");
+    FREEMEM(desc_expect);
+
+    const char **param_names = CFCDocuComment_get_param_names(docucomment);
+    int num_param_names = 0;
+    for (const char **p = param_names; *p; ++p) { ++num_param_names; }
+    INT_EQ(test, num_param_names, 3, "number of param names");
+    const char *param_names_expect[3] = { "foo", "bar", "baz" };
+    for (int i = 0; i < 3; ++i) {
+        STR_EQ(test, param_names[i], param_names_expect[i],
+               "param name %d", i);
+    }
+
+    const char **param_docs = CFCDocuComment_get_param_docs(docucomment);
+    int num_param_docs = 0;
+    for (const char **p = param_docs; *p; ++p) { ++num_param_docs; }
+    INT_EQ(test, num_param_docs, 3, "number of param docs");
+    const char *param_docs_expect[3] = { "A foo.", "A bar.", "A baz." };
+    const char *param_docs_test[3] = {
+        "@param terminated by @",
+        "@param terminated by empty line",
+        "@param terminated next element, @return"
+    };
+    for (int i = 0; i < 3; ++i) {
+        STR_EQ(test, param_docs[i], param_docs_expect[i], param_docs_test[i]);
+    }
+
+    const char *retval = CFCDocuComment_get_retval(docucomment);
+    const char *retval_expect = "a return value.";
+    STR_EQ(test, retval, retval_expect, "retval");
+
+    CFCBase_decref((CFCBase*)docucomment);
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTestFunction.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestFunction.c b/clownfish/compiler/src/CFCTestFunction.c
new file mode 100644
index 0000000..8907254
--- /dev/null
+++ b/clownfish/compiler/src/CFCTestFunction.c
@@ -0,0 +1,76 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CFC_USE_TEST_MACROS
+#include "CFCBase.h"
+#include "CFCFunction.h"
+#include "CFCParamList.h"
+#include "CFCParcel.h"
+#include "CFCParser.h"
+#include "CFCTest.h"
+#include "CFCType.h"
+
+static void
+S_run_tests(CFCTest *test);
+
+void
+CFCTestFunction_run(CFCTest *test) {
+    CFCTest_start_batch(test, "function", 11);
+    S_run_tests(test);
+}
+
+static void
+S_run_tests(CFCTest *test) {
+    CFCParser *parser = CFCParser_new();
+    CFCParcel *neato_parcel
+        = CFCTest_parse_parcel(test, parser, "parcel Neato;");
+
+    {
+        CFCType *return_type = CFCTest_parse_type(test, parser, "Obj*");
+        CFCParamList *param_list
+            = CFCTest_parse_param_list(test, parser, "(int32_t some_num)");
+        CFCFunction *func
+            = CFCFunction_new(neato_parcel, NULL, "Neato::Foo", "Foo",
+                              "return_an_obj", return_type, param_list,
+                              NULL, 0);
+        OK(test, func != NULL, "new");
+
+        CFCBase_decref((CFCBase*)return_type);
+        CFCBase_decref((CFCBase*)param_list);
+        CFCBase_decref((CFCBase*)func);
+    }
+
+    {
+        CFCParser_set_class_name(parser, "Neato::Obj");
+        CFCParser_set_class_cnick(parser, "Obj");
+        static const char *func_strings[2] = {
+            "inert int running_count(int biscuit);",
+            "public inert Hash* init_fave_hash(int32_t num_buckets,"
+            " bool o_rly);"
+        };
+        for (int i = 0; i < 2; ++i) {
+            CFCFunction *func
+                = CFCTest_parse_function(test, parser, func_strings[i]);
+            CFCBase_decref((CFCBase*)func);
+        }
+    }
+
+    CFCBase_decref((CFCBase*)neato_parcel);
+    CFCBase_decref((CFCBase*)parser);
+
+    CFCParcel_reap_singletons();
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTestMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestMethod.c b/clownfish/compiler/src/CFCTestMethod.c
new file mode 100644
index 0000000..0144300
--- /dev/null
+++ b/clownfish/compiler/src/CFCTestMethod.c
@@ -0,0 +1,244 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CFC_USE_TEST_MACROS
+#include "CFCBase.h"
+#include "CFCMethod.h"
+#include "CFCParamList.h"
+#include "CFCParcel.h"
+#include "CFCParser.h"
+#include "CFCSymbol.h"
+#include "CFCTest.h"
+#include "CFCType.h"
+
+static void
+S_run_basic_tests(CFCTest *test);
+
+static void
+S_run_parser_tests(CFCTest *test);
+
+static void
+S_run_overridden_tests(CFCTest *test);
+
+static void
+S_run_final_tests(CFCTest *test);
+
+void
+CFCTestMethod_run(CFCTest *test) {
+    CFCTest_start_batch(test, "method", 62);
+
+    S_run_basic_tests(test);
+    S_run_parser_tests(test);
+    S_run_overridden_tests(test);
+    S_run_final_tests(test);
+}
+
+static void
+S_run_basic_tests(CFCTest *test) {
+    CFCParser *parser = CFCParser_new();
+    CFCParcel *neato_parcel
+        = CFCTest_parse_parcel(test, parser, "parcel Neato;");
+
+    CFCType *return_type = CFCTest_parse_type(test, parser, "Obj*");
+    CFCParamList *param_list
+        = CFCTest_parse_param_list(test, parser,
+                                   "(Foo *self, int32_t count = 0)");
+    CFCMethod *method
+        = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo",
+                        "Return_An_Obj", return_type, param_list,
+                        NULL, 0, 0);
+    OK(test, method != NULL, "new");
+    OK(test, CFCSymbol_parcel((CFCSymbol*)method),
+       "parcel exposure by default");
+
+    {
+        CFCMethod *dupe
+            = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo",
+                            "Return_An_Obj", return_type, param_list,
+                            NULL, 0, 0);
+        OK(test, CFCMethod_compatible(method, dupe), "compatible");
+        CFCBase_decref((CFCBase*)dupe);
+    }
+
+    {
+        CFCMethod *macro_sym_differs
+            = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo", "Eat",
+                            return_type, param_list, NULL, 0, 0);
+        OK(test, !CFCMethod_compatible(method, macro_sym_differs),
+           "different macro_sym spoils compatible");
+        OK(test, !CFCMethod_compatible(macro_sym_differs, method),
+           "... reversed");
+        CFCBase_decref((CFCBase*)macro_sym_differs);
+    }
+
+    {
+        static const char *param_strings[5] = {
+            "(Foo *self, int32_t count = 0, int b)",
+            "(Foo *self, int32_t count = 1)",
+            "(Foo *self, int32_t count)",
+            "(Foo *self, int32_t countess)",
+            "(Foo *self, uint32_t count = 0)"
+        };
+        static const char *test_names[5] = {
+            "extra param",
+            "different initial_value",
+            "missing initial_value",
+            "different param name",
+            "different param type"
+        };
+        for (int i = 0; i < 5; ++i) {
+            CFCParamList *other_param_list
+                = CFCTest_parse_param_list(test, parser, param_strings[i]);
+            CFCMethod *other
+                = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo",
+                                "Return_An_Obj", return_type, other_param_list,
+                                NULL, 0, 0);
+            OK(test, !CFCMethod_compatible(method, other),
+               "%s spoils compatible", test_names[i]);
+            OK(test, !CFCMethod_compatible(other, method),
+               "... reversed");
+            CFCBase_decref((CFCBase*)other_param_list);
+            CFCBase_decref((CFCBase*)other);
+        }
+    }
+
+    {
+        CFCParamList *self_differs_list
+            = CFCTest_parse_param_list(test, parser,
+                                       "(Bar *self, int32_t count = 0)");
+        CFCMethod *self_differs
+            = CFCMethod_new(neato_parcel, NULL, "Neato::Bar", "Bar",
+                            "Return_An_Obj", return_type, self_differs_list,
+                            NULL, 0, 0);
+        OK(test, CFCMethod_compatible(method, self_differs),
+           "different self type still compatible(),"
+           " since can't test inheritance");
+        OK(test, CFCMethod_compatible(self_differs, method),
+           "... reversed");
+        CFCBase_decref((CFCBase*)self_differs_list);
+        CFCBase_decref((CFCBase*)self_differs);
+    }
+
+    CFCBase_decref((CFCBase*)parser);
+    CFCBase_decref((CFCBase*)neato_parcel);
+    CFCBase_decref((CFCBase*)return_type);
+    CFCBase_decref((CFCBase*)param_list);
+    CFCBase_decref((CFCBase*)method);
+
+    CFCParcel_reap_singletons();
+}
+
+static void
+S_run_parser_tests(CFCTest *test) {
+    CFCParser *parser = CFCParser_new();
+    CFCParcel *neato_parcel
+        = CFCTest_parse_parcel(test, parser, "parcel Neato;");
+    CFCParser_set_class_name(parser, "Neato::Obj");
+    CFCParser_set_class_cnick(parser, "Obj");
+
+    {
+        static const char *method_strings[4] = {
+            "public int Do_Foo(Obj *self);",
+            "parcel Obj* Gimme_An_Obj(Obj *self);",
+            "void Do_Whatever(Obj *self, uint32_t a_num, float real);",
+            "private Foo* Fetch_Foo(Obj *self, int num);",
+        };
+        for (int i = 0; i < 2; ++i) {
+            CFCMethod *method
+                = CFCTest_parse_method(test, parser, method_strings[i]);
+            CFCBase_decref((CFCBase*)method);
+        }
+    }
+
+    {
+        CFCMethod *method
+            = CFCTest_parse_method(test, parser,
+                                   "public final void The_End(Obj *self);");
+        OK(test, CFCMethod_final(method), "final");
+        CFCBase_decref((CFCBase*)method);
+    }
+
+    CFCBase_decref((CFCBase*)neato_parcel);
+    CFCBase_decref((CFCBase*)parser);
+
+    CFCParcel_reap_singletons();
+}
+
+static void
+S_run_overridden_tests(CFCTest *test) {
+    CFCParser *parser = CFCParser_new();
+    CFCParcel *neato_parcel
+        = CFCTest_parse_parcel(test, parser, "parcel Neato;");
+    CFCType *return_type = CFCTest_parse_type(test, parser, "Obj*");
+
+    CFCParamList *param_list
+        = CFCTest_parse_param_list(test, parser, "(Foo *self)");
+    CFCMethod *orig
+        = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo",
+                        "Return_An_Obj", return_type, param_list,
+                        NULL, 0, 0);
+
+    CFCParamList *overrider_param_list
+        = CFCTest_parse_param_list(test, parser, "(FooJr *self)");
+    CFCMethod *overrider
+        = CFCMethod_new(neato_parcel, NULL, "Neato::Foo::FooJr", "FooJr",
+                        "Return_An_Obj", return_type, overrider_param_list,
+                        NULL, 0, 0);
+
+    CFCMethod_override(overrider, orig);
+    OK(test, !CFCMethod_novel(overrider),
+       "A Method which overrides another is not 'novel'");
+
+    CFCBase_decref((CFCBase*)parser);
+    CFCBase_decref((CFCBase*)neato_parcel);
+    CFCBase_decref((CFCBase*)return_type);
+    CFCBase_decref((CFCBase*)param_list);
+    CFCBase_decref((CFCBase*)orig);
+    CFCBase_decref((CFCBase*)overrider_param_list);
+    CFCBase_decref((CFCBase*)overrider);
+
+    CFCParcel_reap_singletons();
+}
+
+static void
+S_run_final_tests(CFCTest *test) {
+    CFCParser *parser = CFCParser_new();
+    CFCParcel *neato_parcel
+        = CFCTest_parse_parcel(test, parser, "parcel Neato;");
+    CFCType *return_type = CFCTest_parse_type(test, parser, "Obj*");
+    CFCParamList *param_list
+        = CFCTest_parse_param_list(test, parser, "(Foo *self)");
+
+    CFCMethod *not_final
+        = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo",
+                        "Return_An_Obj", return_type, param_list,
+                        NULL, 0, 0);
+    CFCMethod *final = CFCMethod_finalize(not_final);
+    OK(test, CFCMethod_compatible(not_final, final),
+       "finalize clones properly");
+    OK(test, !CFCMethod_final(not_final), "not final by default");
+    OK(test, CFCMethod_final(final), "finalize");
+
+    CFCBase_decref((CFCBase*)parser);
+    CFCBase_decref((CFCBase*)neato_parcel);
+    CFCBase_decref((CFCBase*)return_type);
+    CFCBase_decref((CFCBase*)param_list);
+    CFCBase_decref((CFCBase*)not_final);
+    CFCBase_decref((CFCBase*)final);
+
+    CFCParcel_reap_singletons();
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTestSymbol.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestSymbol.c b/clownfish/compiler/src/CFCTestSymbol.c
new file mode 100644
index 0000000..3321f6c
--- /dev/null
+++ b/clownfish/compiler/src/CFCTestSymbol.c
@@ -0,0 +1,144 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CFC_USE_TEST_MACROS
+#include "CFCBase.h"
+#include "CFCParcel.h"
+#include "CFCSymbol.h"
+#include "CFCTest.h"
+
+static void
+S_run_tests(CFCTest *test);
+
+void
+CFCTestSymbol_run(CFCTest *test) {
+    CFCTest_start_batch(test, "symbol", 28);
+    S_run_tests(test);
+}
+
+static void
+S_run_tests(CFCTest *test) {
+    CFCParcel *parcel = CFCParcel_default_parcel();
+
+    {
+        static const char *exposures[4] = {
+            "public", "private", "parcel", "local"
+        };
+        static int (*accessors[4])(CFCSymbol *sym) = {
+            CFCSymbol_public,
+            CFCSymbol_private,
+            CFCSymbol_parcel,
+            CFCSymbol_local
+        };
+        for (int i = 0; i < 4; ++i) {
+            CFCSymbol *symbol
+                = CFCSymbol_new(parcel, exposures[i], NULL, NULL, "sym");
+            for (int j = 0; j < 4; ++j) {
+                int has_exposure = accessors[j](symbol);
+                if (i == j) {
+                    OK(test, has_exposure, "exposure %s", exposures[i]);
+                }
+                else {
+                    OK(test, !has_exposure, "%s means not %s", exposures[i],
+                       exposures[j]);
+                }
+            }
+            CFCBase_decref((CFCBase*)symbol);
+        }
+    }
+
+    {
+        CFCSymbol *foo = CFCSymbol_new(parcel, "parcel", "Foo", NULL, "sym");
+        CFCSymbol *foo_jr
+            = CFCSymbol_new(parcel, "parcel", "Foo::FooJr", NULL, "sym");
+
+        int equal = CFCSymbol_equals(foo, foo_jr);
+        OK(test, !equal, "different class_name spoils equals");
+        const char *foo_jr_name = CFCSymbol_get_class_name(foo_jr);
+        STR_EQ(test, foo_jr_name, "Foo::FooJr", "get_class_name");
+        const char *foo_jr_cnick = CFCSymbol_get_class_cnick(foo_jr);
+        STR_EQ(test, foo_jr_cnick, "FooJr",
+               "derive class_cnick from class_name");
+
+        CFCBase_decref((CFCBase*)foo);
+        CFCBase_decref((CFCBase*)foo_jr);
+    }
+
+    {
+        CFCSymbol *public_exposure
+            = CFCSymbol_new(parcel, "public", NULL, NULL, "sym");
+        CFCSymbol *parcel_exposure
+            = CFCSymbol_new(parcel, "parcel", NULL, NULL, "sym");
+        int equal = CFCSymbol_equals(public_exposure, parcel_exposure);
+        OK(test, !equal, "different exposure spoils equals");
+        CFCBase_decref((CFCBase*)public_exposure);
+        CFCBase_decref((CFCBase*)parcel_exposure);
+    }
+
+    {
+        CFCParcel *lucifer_parcel = CFCParcel_new("Lucifer", NULL, NULL);
+        CFCParcel_register(lucifer_parcel);
+        CFCSymbol *lucifer
+            = CFCSymbol_new(lucifer_parcel, "parcel", NULL, NULL, "sym");
+
+        CFCParcel *symbol_parcel = CFCSymbol_get_parcel(lucifer);
+        OK(test, symbol_parcel == lucifer_parcel, "derive parcel");
+        const char *prefix = CFCSymbol_get_prefix(lucifer);
+        STR_EQ(test, prefix, "lucifer_", "get_prefix");
+        const char *Prefix = CFCSymbol_get_Prefix(lucifer);
+        STR_EQ(test, Prefix, "Lucifer_", "get_Prefix");
+        const char *PREFIX = CFCSymbol_get_PREFIX(lucifer);
+        STR_EQ(test, PREFIX, "LUCIFER_", "get_PREFIX");
+
+        CFCParcel *luser_parcel = CFCParcel_new("Luser", NULL, NULL);
+        CFCParcel_register(luser_parcel);
+        CFCSymbol *luser
+            = CFCSymbol_new(luser_parcel, "parcel", NULL, NULL, "sym");
+        int equal = CFCSymbol_equals(lucifer, luser);
+        OK(test, !equal, "different exposure spoils equals");
+
+        CFCBase_decref((CFCBase*)lucifer_parcel);
+        CFCBase_decref((CFCBase*)lucifer);
+        CFCBase_decref((CFCBase*)luser_parcel);
+        CFCBase_decref((CFCBase*)luser);
+    }
+
+    {
+        CFCSymbol *ooga = CFCSymbol_new(parcel, "parcel", NULL, NULL, "ooga");
+        CFCSymbol *booga
+            = CFCSymbol_new(parcel, "parcel", NULL, NULL, "booga");
+        int equal = CFCSymbol_equals(ooga, booga);
+        OK(test, !equal, "different micro_sym spoils equals");
+        CFCBase_decref((CFCBase*)ooga);
+        CFCBase_decref((CFCBase*)booga);
+    }
+
+    {
+        CFCParcel *eep_parcel = CFCParcel_new("Eep", NULL, NULL);
+        CFCParcel_register(eep_parcel);
+        CFCSymbol *eep
+            = CFCSymbol_new(eep_parcel, "parcel", "Op::Ork", NULL, "ah_ah");
+        const char *short_sym = CFCSymbol_short_sym(eep);
+        STR_EQ(test, short_sym, "Ork_ah_ah", "short_sym");
+        const char *full_sym = CFCSymbol_full_sym(eep);
+        STR_EQ(test, full_sym, "eep_Ork_ah_ah", "full_sym");
+        CFCBase_decref((CFCBase*)eep_parcel);
+        CFCBase_decref((CFCBase*)eep);
+    }
+
+    CFCParcel_reap_singletons();
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTestType.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestType.c b/clownfish/compiler/src/CFCTestType.c
new file mode 100644
index 0000000..0d971d4
--- /dev/null
+++ b/clownfish/compiler/src/CFCTestType.c
@@ -0,0 +1,507 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CFC_USE_TEST_MACROS
+#include "CFCBase.h"
+#include "CFCParcel.h"
+#include "CFCParser.h"
+#include "CFCTest.h"
+#include "CFCType.h"
+#include "CFCUtil.h"
+
+static void
+S_run_basic_tests(CFCTest *test);
+
+static void
+S_run_primitive_tests(CFCTest *test);
+
+static void
+S_run_integer_tests(CFCTest *test);
+
+static void
+S_run_float_tests(CFCTest *test);
+
+static void
+S_run_void_tests(CFCTest *test);
+
+static void
+S_run_object_tests(CFCTest *test);
+
+static void
+S_run_va_list_tests(CFCTest *test);
+
+static void
+S_run_arbitrary_tests(CFCTest *test);
+
+static void
+S_run_composite_tests(CFCTest *test);
+
+void
+CFCTestType_run(CFCTest *test) {
+    CFCTest_start_batch(test, "type", 349);
+
+    S_run_basic_tests(test);
+    S_run_primitive_tests(test);
+    S_run_integer_tests(test);
+    S_run_float_tests(test);
+    S_run_void_tests(test);
+    S_run_object_tests(test);
+    S_run_va_list_tests(test);
+    S_run_arbitrary_tests(test);
+    S_run_composite_tests(test);
+}
+
+static void
+S_run_basic_tests(CFCTest *test) {
+    CFCParcel *neato_parcel = CFCParcel_new("Neato", NULL, NULL);
+    CFCParcel_register(neato_parcel);
+    CFCType *type = CFCType_new(0, neato_parcel, "mytype_t", 0, NULL);
+
+    OK(test, CFCType_get_parcel(type) == neato_parcel, "get_parcel");
+    STR_EQ(test, CFCType_to_c(type), "", "to_c");
+    CFCType_set_c_string(type, "mytype_t");
+    STR_EQ(test, CFCType_to_c(type), "mytype_t", "set_c_string");
+    STR_EQ(test, CFCType_get_specifier(type), "mytype_t", "get_specifier");
+
+#define TEST_BOOL_ACCESSOR(type, name) \
+    OK(test, !CFCType_ ## name(type), #name " false by default");
+
+    TEST_BOOL_ACCESSOR(type, const);
+    TEST_BOOL_ACCESSOR(type, nullable);
+    TEST_BOOL_ACCESSOR(type, incremented);
+    TEST_BOOL_ACCESSOR(type, decremented);
+    TEST_BOOL_ACCESSOR(type, is_void);
+    TEST_BOOL_ACCESSOR(type, is_object);
+    TEST_BOOL_ACCESSOR(type, is_primitive);
+    TEST_BOOL_ACCESSOR(type, is_integer);
+    TEST_BOOL_ACCESSOR(type, is_floating);
+    TEST_BOOL_ACCESSOR(type, is_string_type);
+    TEST_BOOL_ACCESSOR(type, is_va_list);
+    TEST_BOOL_ACCESSOR(type, is_arbitrary);
+    TEST_BOOL_ACCESSOR(type, is_composite);
+
+    CFCBase_decref((CFCBase*)neato_parcel);
+    CFCBase_decref((CFCBase*)type);
+
+    CFCParcel_reap_singletons();
+}
+
+static void
+S_run_primitive_tests(CFCTest *test) {
+    CFCParcel *parcel = CFCParcel_default_parcel();
+    CFCType *type = CFCType_new(CFCTYPE_PRIMITIVE, parcel, "hump_t", 0, NULL);
+    OK(test, CFCType_is_primitive(type), "is_primitive");
+
+    {
+        CFCType *twin
+            = CFCType_new(CFCTYPE_PRIMITIVE, parcel, "hump_t", 0, NULL);
+        OK(test, CFCType_equals(type, twin), "equals");
+        CFCBase_decref((CFCBase*)twin);
+    }
+
+    {
+        CFCType *other
+            = CFCType_new(CFCTYPE_PRIMITIVE, parcel, "dump_t", 0, NULL);
+        OK(test, !CFCType_equals(type, other), "equals spoiled by specifier");
+        CFCBase_decref((CFCBase*)other);
+    }
+
+    {
+        CFCType *other
+            = CFCType_new(CFCTYPE_PRIMITIVE|CFCTYPE_CONST, parcel, "hump_t", 0,
+                          NULL);
+        OK(test, !CFCType_equals(type, other), "equals spoiled by const");
+        CFCBase_decref((CFCBase*)other);
+    }
+
+    CFCBase_decref((CFCBase*)type);
+}
+
+static void
+S_run_integer_tests(CFCTest *test) {
+    {
+        CFCType *type = CFCType_new_integer(CFCTYPE_CONST, "int32_t");
+        OK(test, CFCType_const(type), "const");
+        STR_EQ(test, CFCType_get_specifier(type), "int32_t", "get_specifier");
+        STR_EQ(test, CFCType_to_c(type), "const int32_t",
+               "'const' in C representation");
+        CFCBase_decref((CFCBase*)type);
+    }
+
+    {
+        CFCParser *parser = CFCParser_new();
+        static const char *specifiers[14] = {
+            "bool",
+            "char",
+            "short",
+            "int",
+            "long",
+            "size_t",
+            "int8_t",
+            "int16_t",
+            "int32_t",
+            "int64_t",
+            "uint8_t",
+            "uint16_t",
+            "uint32_t",
+            "uint64_t"
+        };
+        for (int i = 0; i < 14; ++i) {
+            const char *specifier = specifiers[i];
+            CFCType *type;
+
+            type = CFCTest_parse_type(test, parser, specifier);
+            OK(test, CFCType_is_integer(type), "%s is_integer", specifier);
+            CFCBase_decref((CFCBase*)type);
+
+            char *const_specifier = CFCUtil_sprintf("const %s", specifier);
+            type = CFCTest_parse_type(test, parser, const_specifier);
+            OK(test, CFCType_is_integer(type), "%s is_integer",
+               const_specifier);
+            OK(test, CFCType_const(type), "%s is const", const_specifier);
+            FREEMEM(const_specifier);
+            CFCBase_decref((CFCBase*)type);
+        }
+        CFCBase_decref((CFCBase*)parser);
+    }
+}
+
+static void
+S_run_float_tests(CFCTest *test) {
+    {
+        CFCType *type = CFCType_new_float(CFCTYPE_CONST, "float");
+        OK(test, CFCType_const(type), "const");
+        STR_EQ(test, CFCType_get_specifier(type), "float", "get_specifier");
+        STR_EQ(test, CFCType_to_c(type), "const float",
+               "'const' in C representation");
+        CFCBase_decref((CFCBase*)type);
+    }
+
+    {
+        CFCParser *parser = CFCParser_new();
+        static const char *specifiers[2] = {
+            "float",
+            "double"
+        };
+        for (int i = 0; i < 2; ++i) {
+            const char *specifier = specifiers[i];
+            CFCType *type;
+
+            type = CFCTest_parse_type(test, parser, specifier);
+            OK(test, CFCType_is_floating(type), "%s is_floating", specifier);
+            CFCBase_decref((CFCBase*)type);
+
+            char *const_specifier = CFCUtil_sprintf("const %s", specifier);
+            type = CFCTest_parse_type(test, parser, const_specifier);
+            OK(test, CFCType_is_floating(type), "%s is_floating",
+               const_specifier);
+            OK(test, CFCType_const(type), "%s is const", const_specifier);
+            FREEMEM(const_specifier);
+            CFCBase_decref((CFCBase*)type);
+        }
+        CFCBase_decref((CFCBase*)parser);
+    }
+}
+
+static void
+S_run_void_tests(CFCTest *test) {
+    CFCParser *parser = CFCParser_new();
+
+    {
+        CFCType *type = CFCType_new_void(0);
+        STR_EQ(test, CFCType_get_specifier(type), "void", "get_specifier");
+        STR_EQ(test, CFCType_to_c(type), "void", "to_c");
+        OK(test, CFCType_is_void(type), "is_void");
+        CFCBase_decref((CFCBase*)type);
+    }
+
+    {
+        CFCType *type = CFCType_new_void(CFCTYPE_CONST);
+        STR_EQ(test, CFCType_to_c(type), "const void",
+               "'const' in C representation");
+        CFCBase_decref((CFCBase*)type);
+    }
+
+    {
+        CFCType *type = CFCTest_parse_type(test, parser, "void");
+        OK(test, CFCType_is_void(type), "void is_void");
+        CFCBase_decref((CFCBase*)type);
+    }
+
+    {
+        CFCType *type = CFCTest_parse_type(test, parser, "const void");
+        OK(test, CFCType_is_void(type), "const void is_void");
+        OK(test, CFCType_const(type), "const void is const");
+        CFCBase_decref((CFCBase*)type);
+    }
+
+    CFCBase_decref((CFCBase*)parser);
+}
+
+static void
+S_run_object_tests(CFCTest *test) {
+    static const char *modifiers[4] = {
+        "const", "incremented", "decremented", "nullable"
+    };
+    static int flags[4] = {
+        CFCTYPE_CONST,
+        CFCTYPE_INCREMENTED,
+        CFCTYPE_DECREMENTED,
+        CFCTYPE_NULLABLE
+    };
+    static int (*accessors[4])(CFCType *type) = {
+        CFCType_const,
+        CFCType_incremented,
+        CFCType_decremented,
+        CFCType_nullable
+    };
+
+    {
+        CFCParser *parser = CFCParser_new();
+        CFCParcel *neato_parcel
+            = CFCTest_parse_parcel(test, parser, "parcel Neato;");
+
+        static const char *specifiers[4] = {
+            "Foo", "FooJr", "FooIII", "Foo4th"
+        };
+        for (int i = 0; i < 4; ++i) {
+            const char *specifier = specifiers[i];
+
+            static const char *prefixes[2] = { "", "neato_" };
+            char *expect = CFCUtil_sprintf("neato_%s", specifier);
+            for (int j = 0; j < 2; ++j) {
+                char *src = CFCUtil_sprintf("%s%s*", prefixes[j], specifier);
+                CFCType *type = CFCTest_parse_type(test, parser, src);
+                STR_EQ(test, CFCType_get_specifier(type), expect,
+                       "object_type_specifier: %s", src);
+                OK(test, CFCType_is_object(type), "%s is_object", src);
+                INT_EQ(test, CFCType_get_indirection(type), 1,
+                       "%s indirection", src);
+
+                FREEMEM(src);
+                CFCBase_decref((CFCBase*)type);
+            }
+            FREEMEM(expect);
+
+            for (int j = 0; j < 4; ++j) {
+                char *src = CFCUtil_sprintf("%s %s*", modifiers[j], specifier);
+                CFCType *type = CFCTest_parse_type(test, parser, src);
+                OK(test, CFCType_is_object(type), "%s is_object", src);
+                OK(test, accessors[j](type), "%s accessor", src);
+
+                FREEMEM(src);
+                CFCBase_decref((CFCBase*)type);
+            }
+        }
+
+        CFCBase_decref((CFCBase*)neato_parcel);
+        CFCBase_decref((CFCBase*)parser);
+    }
+
+    CFCType *foo = CFCType_new_object(0, NULL, "Foo", 1);
+
+    {
+        CFCType *another_foo = CFCType_new_object(0, NULL, "Foo", 1);
+        OK(test, CFCType_equals(foo, another_foo), "equals");
+        CFCBase_decref((CFCBase*)another_foo);
+    }
+
+    {
+        CFCType *bar = CFCType_new_object(0, NULL, "Bar", 1);
+        OK(test, !CFCType_equals(foo, bar),
+           "different specifier spoils equals");
+        CFCBase_decref((CFCBase*)bar);
+    }
+
+    {
+        CFCParcel *foreign_parcel = CFCParcel_new("Foreign", NULL, NULL);
+        CFCParcel_register(foreign_parcel);
+        CFCType *foreign_foo = CFCType_new_object(0, foreign_parcel, "Foo", 1);
+        OK(test, !CFCType_equals(foo, foreign_foo),
+           "different parcel spoils equals");
+        STR_EQ(test, CFCType_get_specifier(foreign_foo), "foreign_Foo",
+               "prepend parcel prefix to specifier");
+        CFCBase_decref((CFCBase*)foreign_parcel);
+        CFCBase_decref((CFCBase*)foreign_foo);
+    }
+
+    {
+        for (int i = 0; i < 4; ++i) {
+            CFCType *modified_foo
+                = CFCType_new_object(flags[i], NULL, "Foo", 1);
+            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),
+               "different %s spoils equals", modifiers[i]);
+            CFCBase_decref((CFCBase*)modified_foo);
+        }
+    }
+
+    {
+        CFCType *string_type = CFCType_new_object(0, NULL, "CharBuf", 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);
+    }
+
+    CFCBase_decref((CFCBase*)foo);
+
+    CFCParcel_reap_singletons();
+}
+
+static void
+S_run_va_list_tests(CFCTest *test) {
+    {
+        CFCType *type = CFCType_new_va_list();
+        STR_EQ(test, CFCType_get_specifier(type), "va_list",
+               "specifier defaults to 'va_list'");
+        STR_EQ(test, CFCType_to_c(type), "va_list", "to_c");
+        CFCBase_decref((CFCBase*)type);
+    }
+
+    {
+        CFCParser *parser = CFCParser_new();
+        CFCType *type = CFCTest_parse_type(test, parser, "va_list");
+        OK(test, CFCType_is_va_list(type), "is_va_list");
+        CFCBase_decref((CFCBase*)type);
+        CFCBase_decref((CFCBase*)parser);
+    }
+}
+
+static void
+S_run_arbitrary_tests(CFCTest *test) {
+    {
+        CFCParcel *neato_parcel = CFCParcel_new("Neato", NULL, NULL);
+        CFCParcel_register(neato_parcel);
+
+        CFCType *foo = CFCType_new_arbitrary(neato_parcel, "foo_t");
+        STR_EQ(test, CFCType_get_specifier(foo), "foo_t", "get_specifier");
+        STR_EQ(test, CFCType_to_c(foo), "foo_t", "to_c");
+
+        CFCType *twin = CFCType_new_arbitrary(neato_parcel, "foo_t");
+        OK(test, CFCType_equals(foo, twin), "equals");
+
+        CFCType *compare_t
+            = CFCType_new_arbitrary(neato_parcel, "Sort_compare_t");
+        OK(test, !CFCType_equals(foo, compare_t),
+           "equals spoiled by different specifier");
+
+        CFCBase_decref((CFCBase*)neato_parcel);
+        CFCBase_decref((CFCBase*)foo);
+        CFCBase_decref((CFCBase*)compare_t);
+        CFCBase_decref((CFCBase*)twin);
+    }
+
+    {
+        CFCParser *parser = CFCParser_new();
+        static const char *specifiers[2] = { "foo_t", "Sort_compare_t" };
+        for (int i = 0; i < 2; ++i) {
+            const char *specifier = specifiers[i];
+            CFCType *type = CFCTest_parse_type(test, parser, specifier);
+            OK(test, CFCType_is_arbitrary(type), "arbitrary type %s",
+               specifier);
+            CFCBase_decref((CFCBase*)type);
+        }
+        CFCBase_decref((CFCBase*)parser);
+    }
+
+    CFCParcel_reap_singletons();
+}
+
+static void
+S_run_composite_tests(CFCTest *test) {
+    CFCParser *parser = CFCParser_new();
+
+    {
+        static const char *type_strings[14] = {
+            "char*",
+            "char**",
+            "char***",
+            "int32_t*",
+            "Obj**",
+            "int8_t[]",
+            "int8_t[1]",
+            "neato_method_t[]",
+            "neato_method_t[1]",
+            "multi_dimensional_t[1][10]",
+            "char * * ",
+            "const Obj**",
+            "const void*",
+            "int8_t[ 3 ]"
+        };
+        for (int i = 0; i < 14; ++i) {
+            const char *type_string = type_strings[i];
+            CFCType *type = CFCTest_parse_type(test, parser, type_string);
+            OK(test, CFCType_is_composite(type), "composite type %s",
+               type_string);
+            CFCBase_decref((CFCBase*)type);
+        }
+    }
+
+    {
+        CFCType *foo = CFCType_new_object(0, NULL, "Foo", 1);
+        CFCType *bar = CFCType_new_object(0, NULL, "Bar", 1);
+
+        CFCType *composite = CFCType_new_composite(0, foo, 1, NULL);
+        OK(test, CFCType_is_composite(composite), "is_composite");
+        STR_EQ(test, CFCType_get_specifier(composite), "Foo",
+               "get_specifier delegates to child" );
+
+        CFCType *twin = CFCType_new_composite(0, foo, 1, NULL);
+        OK(test, CFCType_equals(composite, twin), "equals");
+        CFCBase_decref((CFCBase*)twin);
+
+        CFCType *bar_composite = CFCType_new_composite(0, bar, 1, NULL);
+        OK(test, !CFCType_equals(composite, bar_composite),
+           "equals spoiled by different child");
+        CFCBase_decref((CFCBase*)bar_composite);
+
+        CFCBase_decref((CFCBase*)composite);
+        CFCBase_decref((CFCBase*)foo);
+        CFCBase_decref((CFCBase*)bar);
+    }
+
+    {
+        CFCType *foo_array = CFCTest_parse_type(test, parser, "foo_t[]");
+        STR_EQ(test, CFCType_get_array(foo_array), "[]", "get_array");
+        STR_EQ(test, CFCType_to_c(foo_array), "foo_t",
+               "array subscripts not included by to_c");
+        CFCType *foo_array_array
+            = CFCTest_parse_type(test, parser, "foo_t[][]");
+        OK(test, !CFCType_equals(foo_array, foo_array_array),
+           "equals spoiled by different array postfixes");
+
+        CFCBase_decref((CFCBase*)foo_array);
+        CFCBase_decref((CFCBase*)foo_array_array);
+    }
+
+    {
+        CFCType *foo_star = CFCTest_parse_type(test, parser, "foo_t*");
+        CFCType *foo_star_star = CFCTest_parse_type(test, parser, "foo_t**");
+        OK(test, !CFCType_equals(foo_star, foo_star_star),
+           "equals spoiled by different levels of indirection");
+        INT_EQ(test, CFCType_get_indirection(foo_star), 1,
+               "foo_t* indirection");
+        INT_EQ(test, CFCType_get_indirection(foo_star_star), 2,
+               "foo_t** indirection");
+
+        CFCBase_decref((CFCBase*)foo_star);
+        CFCBase_decref((CFCBase*)foo_star_star);
+    }
+
+    CFCBase_decref((CFCBase*)parser);
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTestUtil.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestUtil.c b/clownfish/compiler/src/CFCTestUtil.c
new file mode 100644
index 0000000..4918255
--- /dev/null
+++ b/clownfish/compiler/src/CFCTestUtil.c
@@ -0,0 +1,169 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define CFC_USE_TEST_MACROS
+#include "CFCUtil.h"
+#include "CFCTest.h"
+
+static void
+S_run_string_tests(CFCTest *test);
+
+static void
+S_run_file_tests(CFCTest *test);
+
+static time_t
+S_get_file_mtime(const char *path);
+
+static void
+S_set_file_times(const char *path, time_t time);
+
+void
+CFCTestUtil_run(CFCTest *test) {
+    CFCTest_start_batch(test, "util", 15);
+    S_run_string_tests(test);
+    S_run_file_tests(test);
+}
+
+static void
+S_run_string_tests(CFCTest *test) {
+    const char *src = "Source string";
+    char *str;
+
+    str = CFCUtil_strdup(src);
+    STR_EQ(test, str, src, "strdup");
+    FREEMEM(str);
+    str = CFCUtil_strndup(src, 6);
+    STR_EQ(test, str, "Source", "strndup");
+    FREEMEM(str);
+    str = CFCUtil_sprintf("%s: %d", src, 123456789);
+    STR_EQ(test, str, "Source string: 123456789", "sprintf");
+    str = CFCUtil_cat(str, " ", "abc", NULL);
+    STR_EQ(test, str, "Source string: 123456789 abc", "cat");
+    FREEMEM(str);
+    str = CFCUtil_strdup(" \r\n\tabc \r\n\tdef \r\n\t");
+    CFCUtil_trim_whitespace(str);
+    STR_EQ(test, str, "abc \r\n\tdef", "trim_whitespace");
+}
+
+static void
+S_run_file_tests(CFCTest *test) {
+    const char *foo_txt = "foo.txt";
+    remove(foo_txt);
+    CFCUtil_write_file(foo_txt, "foo", 3);
+
+    {
+        FILE *file = fopen(foo_txt, "rb");
+        OK(test, file != NULL, "can open file");
+        char buf[10];
+        size_t chars_read = fread(buf, 1, 10, file);
+        INT_EQ(test, chars_read, 3, "read correct number of chars");
+        OK(test, memcmp(buf, "foo", 3) == 0, "read correct string");
+
+        long file_length = CFCUtil_flength(file);
+        INT_EQ(test, file_length, 3, "flength");
+
+        fclose(file);
+    }
+
+    {
+        size_t content_len;
+        char *content = CFCUtil_slurp_text(foo_txt, &content_len);
+        INT_EQ(test, content_len, 3, "slurp_text len");
+        OK(test, memcmp(content, "foo", 3) == 0, "slurp_text content");
+    }
+
+    {
+        OK(test, CFCUtil_current(foo_txt, foo_txt), "current");
+        OK(test, !CFCUtil_current(foo_txt, "nonexistent_file"),
+             "not current when dest file missing");
+        // TODO: Test two different files.
+    }
+
+    {
+        time_t past_time = time(NULL) - 10;
+        S_set_file_times(foo_txt, past_time);
+        past_time = S_get_file_mtime(foo_txt);
+        time_t mtime;
+        CFCUtil_write_if_changed(foo_txt, "foo", 3);
+        mtime = S_get_file_mtime(foo_txt);
+        OK(test, mtime == past_time,
+           "write_if_changed does nothing if contents not changed");
+        CFCUtil_write_if_changed(foo_txt, "foofoo", 6);
+        mtime = S_get_file_mtime(foo_txt);
+        OK(test, mtime != past_time,
+           "write_if_changed writes if contents changed");
+    }
+
+    remove(foo_txt);
+}
+
+static time_t
+S_get_file_mtime(const char *path) {
+    struct stat buf;
+    if (stat(path, &buf)) {
+        CFCUtil_die("Can't stat '%s': %s", path, strerror(errno));
+    }
+    return buf.st_mtime;
+}
+
+#if 1 || defined(HAS_UTIME_H)
+
+#include <utime.h>
+
+static void
+S_set_file_times(const char *path, time_t time) {
+    struct utimbuf buf;
+    buf.actime  = time;
+    buf.modtime = time;
+    if (utime(path, &buf)) {
+        CFCUtil_die("Can't set file time of '%s': %s", path, strerror(errno));
+    }
+}
+
+#elif defined(HAS_WINDOWS_H)
+
+#include <windows.h>
+
+static void
+S_set_file_times(const char *path, time_t time) {
+    HANDLE handle = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL,
+                               OPEN_EXISTING, 0, NULL);
+    if (handle == INVALID_HANDLE_VALUE) {
+        CFCUtil_die("Can't open '%s': %u", path, GetLastError());
+    }
+    uint64_t ticks = 10000000 * (UINT64_C(11644473600) + time);
+    FILETIME time;
+    time.dwLowDateTime  = (DWORD)ticks;
+    time.dwHighDateTime = (DWORD)(ticks >> 32);
+    if (!SetFileTime(handle, time, time, time)) {
+        CFCUtil_die("Can't set file time of '%s': %u", path, GetLastError());
+    }
+    CloseHandle(handle);
+}
+
+#else
+
+#error Need either utime.h or windows.h
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/src/CFCTestVersion.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestVersion.c b/clownfish/compiler/src/CFCTestVersion.c
new file mode 100644
index 0000000..fcd89cb
--- /dev/null
+++ b/clownfish/compiler/src/CFCTestVersion.c
@@ -0,0 +1,69 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CFC_USE_TEST_MACROS
+#include "CFCBase.h"
+#include "CFCVersion.h"
+#include "CFCTest.h"
+
+static void
+S_run_tests(CFCTest *test);
+
+void
+CFCTestVersion_run(CFCTest *test) {
+    CFCTest_start_batch(test, "version", 11);
+    S_run_tests(test);
+}
+
+static void
+S_run_tests(CFCTest *test) {
+    CFCVersion *v3_2     = CFCVersion_new("v3.2");
+    CFCVersion *v3_2_0   = CFCVersion_new("v3.2.0");
+    CFCVersion *v3_2_1   = CFCVersion_new("v3.2.1");
+    CFCVersion *v3_2_1_0 = CFCVersion_new("v3.2.1.0");
+    CFCVersion *v3_3     = CFCVersion_new("v3.3");
+    CFCVersion *v90210   = CFCVersion_new("v90210");
+
+    INT_EQ(test, CFCVersion_get_major(v3_2_1), 3, "get_major");
+    INT_EQ(test, CFCVersion_get_major(v90210), 90210, "parse big number");
+    STR_EQ(test, CFCVersion_get_vstring(v3_2_1), "v3.2.1", "get_vstring");
+
+    int result;
+    result = CFCVersion_compare_to(v3_2_1, v3_2_1_0);
+    INT_EQ(test, result, 0, "ignore zeroes in compare_to");
+    result = CFCVersion_compare_to(v3_2_1_0, v3_2_1);
+    INT_EQ(test, result, 0, "ignore zeroes in compare_to");
+    result = CFCVersion_compare_to(v3_2_1, v3_3);
+    INT_EQ(test, result, -1, "compare_to A < B_fewer_digits");
+    result = CFCVersion_compare_to(v3_3, v3_2_1);
+    INT_EQ(test, result, 1, "compare_to A_fewer_digits > B");
+    result = CFCVersion_compare_to(v3_2_1, v3_2);
+    INT_EQ(test, result, 1, "compare_to A < B_fewer_digits");
+    result = CFCVersion_compare_to(v3_2, v3_2_1);
+    INT_EQ(test, result, -1, "compare_to A_fewer_digits > B");
+    result = CFCVersion_compare_to(v3_2_1, v3_2_0);
+    INT_EQ(test, result, 1, "compare_to A > B");
+    result = CFCVersion_compare_to(v3_2_0, v3_2_1);
+    INT_EQ(test, result, -1, "compare_to A < B");
+
+    CFCBase_decref((CFCBase*)v3_2);
+    CFCBase_decref((CFCBase*)v3_2_0);
+    CFCBase_decref((CFCBase*)v3_2_1);
+    CFCBase_decref((CFCBase*)v3_2_1_0);
+    CFCBase_decref((CFCBase*)v3_3);
+    CFCBase_decref((CFCBase*)v90210);
+}
+


Re: [lucy-dev] [lucy-commits] git commit: refs/heads/cfc-tests - Start to port CFC tests to C

Posted by Marvin Humphrey <ma...@rectangular.com>.
On Tue, Jan 29, 2013 at 11:38 AM, Nick Wellnhofer <we...@aevum.de> wrote:

> Another nice feature of TAP is that you have to split your tests into
> separate programs.  So if one of the test programs crashes, the others are
> not affected.

+1

> I thought about using TAP for testing the C bindings, but we'd also have to
> provide a TAP consumer like Perl's 'prove' utility to interpret the tests.

Sounds good.  My impression is that writing a test runner is pretty involved
in comparison to writing a TAP producer library.

> For now, I decided to go with pluggable formatters for the test output and
> provide a TAP formatter and a custom Clownfish formatter. The latter can be
> used to print a test summary from the test program directly.

It will be great if the pluggable formatter is all the scaffolding we need to
support all target platforms. :)

>> One thing I've wanted to do for a while is have our C tests return true on
>> success, false on failure, and then use that return value to determine the
>> exit value for the test script.  Right now our C-based test scripts still exit
>> success even when some tests fail.
>
> I just pushed a commit with some major reworks which also address this
> issue.

Nick++

> Another thing I'd like to have is some kind of central registry for
> tests, so we don't have to maintain code like the following in every host
> language binding:
>
>     http://s.apache.org/n3

That silly registry is only necessary because all our Lucy test classes are
inert.  If we make Lucy::Test::TestBatch subclassable[1] and have Lucy's test
classes subclass it, then we can use the following incantation:

    my $test_batch = Lucy::Test::Analysis::TestNormalizer->new(
        format => 'tap',
    );
    my $success = $test_batch->run_tests;
    exit($success ? 0 : 1);

I'd also like to propagate the work we did with Charmonizer's test harness a
while back to Clownfish/Lucy, and make the test macros operate on a hidden
global TestBatch...

    #define CFISH_TEST_OK(_expression, _message) \
        CFTest_TestBatch_Test_True(cfish_TestBatch_current, (_expression), \
                                   (_message))

... allowing us to make changes like this:

-    TEST_FALSE(batch,
-               Normalizer_Equals(normalizer[0], (Obj*)normalizer[1]),
+    TEST_FALSE(Normalizer_Equals(normalizer[0], (Obj*)normalizer[1]),
                "Equals() false with different normalization form");

Using a hidden global works fine until you need to test threads -- at which
point your tests can use full method invocations on local TestBatch objects.

Marvin Humphrey

[1] Eventually, that should be Clownfish::Test::TestBatch.

Re: [lucy-dev] [lucy-commits] git commit: refs/heads/cfc-tests - Start to port CFC tests to C

Posted by Nick Wellnhofer <we...@aevum.de>.
On Jan 29, 2013, at 03:39 , Marvin Humphrey <ma...@rectangular.com> wrote:

> Dreaming big dreams... I'd love to have a test harness that supported test
> classes like xUnit, but ran tests that don't throw exceptions, a la Perl tests
> instead of xUnit assertions.  Most of the time, a failing test does not
> invalidate subsequent tests -- and having additional information from tests
> which either succeed or fail can be a big help when trying to debug a CPAN
> Testers report where you don't have access to the machine on which the tests
> ran.

Another nice feature of TAP is that you have to split your tests into separate programs. So if one of the test programs crashes, the others are not affected.

I thought about using TAP for testing the C bindings, but we'd also have to provide a TAP consumer like Perl's 'prove' utility to interpret the tests. For now, I decided to go with pluggable formatters for the test output and provide a TAP formatter and a custom Clownfish formatter. The latter can be used to print a test summary from the test program directly.

>> +$test->run_batch('Clownfish::CFC::Util');
>> +
> 
> One thing I've wanted to do for a while is have our C tests return true on
> success, false on failure, and then use that return value to determine the
> exit value for the test script.  Right now our C-based test scripts still exit
> success even when some tests fail.

I just pushed a commit with some major reworks which also address this issue. Another thing I'd like to have is some kind of central registry for tests, so we don't have to maintain code like the following in every host language binding:

    http://s.apache.org/n3

For the CFC tests, I simply put all the needed information in a global array.

Nick


[lucy-dev] Re: [lucy-commits] git commit: refs/heads/cfc-tests - Start to port CFC tests to C

Posted by Marvin Humphrey <ma...@rectangular.com>.
On Mon, Jan 28, 2013 at 11:30 AM,  <nw...@apache.org> wrote:
> Start to port CFC tests to C

> Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/3a9cef14

Wow... lots of progress!

> http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9cef14/clownfish/compiler/perl/t/core/001-util.t

> +use strict;
> +use warnings;
> +
> +use Clownfish::CFC::Test;
> +
> +my $test = Clownfish::CFC::Test->new;

Nice to see us creating Test objects. :)

Dreaming big dreams... I'd love to have a test harness that supported test
classes like xUnit, but ran tests that don't throw exceptions, a la Perl tests
instead of xUnit assertions.  Most of the time, a failing test does not
invalidate subsequent tests -- and having additional information from tests
which either succeed or fail can be a big help when trying to debug a CPAN
Testers report where you don't have access to the machine on which the tests
ran.

Oh, and tests would run idiomatically under at least Perl, Python and
Ruby. :)

> +$test->run_batch('Clownfish::CFC::Util');
> +

One thing I've wanted to do for a while is have our C tests return true on
success, false on failure, and then use that return value to determine the
exit value for the test script.  Right now our C-based test scripts still exit
success even when some tests fail.

Marvin Humphrey