Port HeatMap test to new infrastructure

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

Branch: refs/heads/clownfish-test
Commit: 263e9bb017693a980d9c4df3f47352ac03ceac7f
Parents: 7f59d22
Author: Nick Wellnhofer <[email protected]>
Authored: Fri Feb 15 23:46:24 2013 +0100
Committer: Nick Wellnhofer <[email protected]>
Committed: Fri Feb 15 23:54:24 2013 +0100

----------------------------------------------------------------------
 core/Lucy/Test/Highlight/TestHeatMap.c   |   56 ++++++++++++++-----------
 core/Lucy/Test/Highlight/TestHeatMap.cfh |   14 +++++-
 core/Lucy/Test/TestEngineLucy.c          |   41 ++++++++++++++++++
 core/Lucy/Test/TestEngineLucy.cfh        |   29 +++++++++++++
 perl/buildlib/Lucy/Build/Binding/Misc.pm |   12 ++++-
 perl/lib/Lucy/Test/TestEngineLucy.pm     |   25 +++++++++++
 perl/t/core/310-heat_map.t               |    8 +++-
 7 files changed, 153 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/263e9bb0/core/Lucy/Test/Highlight/TestHeatMap.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Highlight/TestHeatMap.c 
b/core/Lucy/Test/Highlight/TestHeatMap.c
index 02919b1..f2e5d3d 100644
--- a/core/Lucy/Test/Highlight/TestHeatMap.c
+++ b/core/Lucy/Test/Highlight/TestHeatMap.c
@@ -16,14 +16,26 @@
 
 #include "Lucy/Util/ToolSet.h"
 
-#include "Lucy/Test.h"
+#include "Clownfish/Test/TestEngine.h"
 #include "Lucy/Test/Highlight/TestHeatMap.h"
 #include "Lucy/Highlight/HeatMap.h"
 
 #include "Lucy/Search/Span.h"
 
+TestHeatMap*
+TestHeatMap_new() {
+    TestHeatMap *self = (TestHeatMap*)VTable_Make_Obj(TESTHEATMAP);
+    return TestHeatMap_init(self);
+}
+
+TestHeatMap*
+TestHeatMap_init(TestHeatMap *self) {
+    return (TestHeatMap*)TestBatch2_init(
+        (TestBatch2*)self, CB_newf("Lucy::Highlight::HeatMap"), 13);
+}
+
 static void
-test_calc_proximity_boost(TestBatch *batch) {
+test_calc_proximity_boost(TestEngine *engine) {
     VArray  *spans    = VA_new(0);
     HeatMap *heat_map = HeatMap_new(spans, 133);
     Span    *span1    = Span_new(  0, 10, 1.0f);
@@ -37,10 +49,10 @@ test_calc_proximity_boost(TestBatch *batch) {
     float smaller_boost = HeatMap_Calc_Proximity_Boost(heat_map, span1, span4);
     float zero_boost    = HeatMap_Calc_Proximity_Boost(heat_map, span1, span5);
 
-    TEST_TRUE(batch, big_boost == eq_big_boost,
+    TEST_TRUE(engine, big_boost == eq_big_boost,
               "overlapping and abutting produce the same proximity boost");
-    TEST_TRUE(batch, big_boost > smaller_boost, "closer is better");
-    TEST_TRUE(batch, zero_boost == 0.0,
+    TEST_TRUE(engine, big_boost > smaller_boost, "closer is better");
+    TEST_TRUE(engine, zero_boost == 0.0,
               "distance outside of window yields no prox boost");
 
     DECREF(span1);
@@ -53,7 +65,7 @@ test_calc_proximity_boost(TestBatch *batch) {
 }
 
 static void
-test_flatten_spans(TestBatch *batch) {
+test_flatten_spans(TestEngine *engine) {
     VArray  *spans    = VA_new(8);
     VArray  *wanted   = VA_new(8);
     HeatMap *heat_map = HeatMap_new(spans, 133);
@@ -66,12 +78,12 @@ test_flatten_spans(TestBatch *batch) {
     VA_Push(wanted, (Obj*)Span_new(10,  6, 1.0f));
     VA_Push(wanted, (Obj*)Span_new(16,  4, 3.0f));
     VA_Push(wanted, (Obj*)Span_new(20, 10, 2.0f));
-    TEST_TRUE(batch, VA_Equals(flattened, (Obj*)wanted),
+    TEST_TRUE(engine, VA_Equals(flattened, (Obj*)wanted),
               "flatten two overlapping spans");
     VA_Clear(wanted);
     boosts = HeatMap_Generate_Proximity_Boosts(heat_map, spans);
     VA_Push(wanted, (Obj*)Span_new(10, 20, 3.0f));
-    TEST_TRUE(batch, VA_Equals(boosts, (Obj*)wanted),
+    TEST_TRUE(engine, VA_Equals(boosts, (Obj*)wanted),
               "prox boosts for overlap");
     VA_Clear(wanted);
     VA_Clear(spans);
@@ -86,11 +98,11 @@ test_flatten_spans(TestBatch *batch) {
     VA_Push(wanted, (Obj*)Span_new(16,  4, 3.0f));
     VA_Push(wanted, (Obj*)Span_new(20, 10, 2.0f));
     VA_Push(wanted, (Obj*)Span_new(50,  1, 1.0f));
-    TEST_TRUE(batch, VA_Equals(flattened, (Obj*)wanted),
+    TEST_TRUE(engine, VA_Equals(flattened, (Obj*)wanted),
               "flatten two overlapping spans, leave hole, then third span");
     VA_Clear(wanted);
     boosts = HeatMap_Generate_Proximity_Boosts(heat_map, spans);
-    TEST_TRUE(batch, VA_Get_Size(boosts) == 2 + 1,
+    TEST_TRUE(engine, VA_Get_Size(boosts) == 2 + 1,
               "boosts generated for each unique pair, since all were in 
range");
     VA_Clear(spans);
     DECREF(boosts);
@@ -105,11 +117,11 @@ test_flatten_spans(TestBatch *batch) {
     VA_Push(wanted, (Obj*)Span_new(16,  2, 7.0f));
     VA_Push(wanted, (Obj*)Span_new(18,  2, 3.0f));
     VA_Push(wanted, (Obj*)Span_new(20, 10, 2.0f));
-    TEST_TRUE(batch, VA_Equals(flattened, (Obj*)wanted),
+    TEST_TRUE(engine, VA_Equals(flattened, (Obj*)wanted),
               "flatten three overlapping spans");
     VA_Clear(wanted);
     boosts = HeatMap_Generate_Proximity_Boosts(heat_map, spans);
-    TEST_TRUE(batch, VA_Get_Size(boosts) == 2 + 1,
+    TEST_TRUE(engine, VA_Get_Size(boosts) == 2 + 1,
               "boosts generated for each unique pair, since all were in 
range");
     VA_Clear(spans);
     DECREF(boosts);
@@ -124,11 +136,11 @@ test_flatten_spans(TestBatch *batch) {
     VA_Push(wanted, (Obj*)Span_new(16,  4,  7.0f));
     VA_Push(wanted, (Obj*)Span_new(20, 10,  6.0f));
     VA_Push(wanted, (Obj*)Span_new(30, 10, 10.0f));
-    TEST_TRUE(batch, VA_Equals(flattened, (Obj*)wanted),
+    TEST_TRUE(engine, VA_Equals(flattened, (Obj*)wanted),
               "flatten 4 spans, middle two have identical range");
     VA_Clear(wanted);
     boosts = HeatMap_Generate_Proximity_Boosts(heat_map, spans);
-    TEST_TRUE(batch, VA_Get_Size(boosts) == 3 + 2 + 1,
+    TEST_TRUE(engine, VA_Get_Size(boosts) == 3 + 2 + 1,
               "boosts generated for each unique pair, since all were in 
range");
     VA_Clear(spans);
     DECREF(boosts);
@@ -143,11 +155,11 @@ test_flatten_spans(TestBatch *batch) {
     VA_Push(wanted, (Obj*)Span_new( 16,  4,  7.0f));
     VA_Push(wanted, (Obj*)Span_new( 20, 10,  2.0f));
     VA_Push(wanted, (Obj*)Span_new(230, 10, 10.0f));
-    TEST_TRUE(batch, VA_Equals(flattened, (Obj*)wanted),
+    TEST_TRUE(engine, VA_Equals(flattened, (Obj*)wanted),
               "flatten 4 spans, middle two have identical starts but different 
ends");
     VA_Clear(wanted);
     boosts = HeatMap_Generate_Proximity_Boosts(heat_map, spans);
-    TEST_TRUE(batch, VA_Get_Size(boosts) == 2 + 1,
+    TEST_TRUE(engine, VA_Get_Size(boosts) == 2 + 1,
               "boosts not generated for out of range span");
     VA_Clear(spans);
     DECREF(boosts);
@@ -159,15 +171,11 @@ test_flatten_spans(TestBatch *batch) {
 }
 
 void
-TestHeatMap_run_tests() {
-    TestBatch *batch = TestBatch_new(13);
-
-    TestBatch_Plan(batch);
-
-    test_calc_proximity_boost(batch);
-    test_flatten_spans(batch);
+TestHeatMap_run_tests(TestHeatMap *self, TestEngine *engine) {
+    UNUSED_VAR(self);
 
-    DECREF(batch);
+    test_calc_proximity_boost(engine);
+    test_flatten_spans(engine);
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/263e9bb0/core/Lucy/Test/Highlight/TestHeatMap.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Highlight/TestHeatMap.cfh 
b/core/Lucy/Test/Highlight/TestHeatMap.cfh
index 70f65bd..10bbaf4 100644
--- a/core/Lucy/Test/Highlight/TestHeatMap.cfh
+++ b/core/Lucy/Test/Highlight/TestHeatMap.cfh
@@ -16,9 +16,17 @@
 
 parcel Lucy;
 
-inert class Lucy::Test::Highlight::TestHeatMap {
-    inert void
-    run_tests();
+class Lucy::Test::Highlight::TestHeatMap
+    inherits Clownfish::Test::TestBatch2 {
+
+    inert incremented TestHeatMap*
+    new();
+
+    inert TestHeatMap*
+    init(TestHeatMap *self);
+
+    void
+    Run_Tests(TestHeatMap *self, TestEngine *engine);
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/263e9bb0/core/Lucy/Test/TestEngineLucy.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/TestEngineLucy.c b/core/Lucy/Test/TestEngineLucy.c
new file mode 100644
index 0000000..d3f661a
--- /dev/null
+++ b/core/Lucy/Test/TestEngineLucy.c
@@ -0,0 +1,41 @@
+/* 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 C_LUCY_TESTENGINELUCY
+#define LUCY_USE_SHORT_NAMES
+
+#include "Lucy/Test/TestEngineLucy.h"
+#include "Clownfish/CharBuf.h"
+#include "Clownfish/VArray.h"
+#include "Clownfish/VTable.h"
+#include "Lucy/Test/Highlight/TestHeatMap.h"
+
+TestEngineLucy*
+TestEngineLucy_new(CharBuf *formatter_name) {
+    TestEngineLucy *self = (TestEngineLucy*)VTable_Make_Obj(TESTENGINELUCY);
+    return TestEngineLucy_init(self, formatter_name);
+}
+
+TestEngineLucy*
+TestEngineLucy_init(TestEngineLucy *self, CharBuf *formatter_name) {
+    TestEngine_init((TestEngine*)self, formatter_name);
+
+    VA_Push(self->batches, (Obj*)TestHeatMap_new());
+
+    return self;
+}
+
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/263e9bb0/core/Lucy/Test/TestEngineLucy.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/TestEngineLucy.cfh 
b/core/Lucy/Test/TestEngineLucy.cfh
new file mode 100644
index 0000000..130fc21
--- /dev/null
+++ b/core/Lucy/Test/TestEngineLucy.cfh
@@ -0,0 +1,29 @@
+/* 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.
+ */
+
+parcel Lucy;
+
+class Lucy::Test::TestEngineLucy
+    inherits Clownfish::Test::TestEngine {
+
+    inert incremented TestEngineLucy*
+    new(CharBuf *formatter_name);
+
+    inert TestEngineLucy*
+    init(TestEngineLucy *self, CharBuf *formatter_name);
+}
+
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/263e9bb0/perl/buildlib/Lucy/Build/Binding/Misc.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build/Binding/Misc.pm 
b/perl/buildlib/Lucy/Build/Binding/Misc.pm
index 6c9d8de..1168f6d 100644
--- a/perl/buildlib/Lucy/Build/Binding/Misc.pm
+++ b/perl/buildlib/Lucy/Build/Binding/Misc.pm
@@ -23,6 +23,7 @@ sub bind_all {
     my $class = shift;
     $class->bind_lucy;
     $class->bind_test;
+    $class->bind_testenginelucy;
     $class->bind_testutils;
     $class->bind_testqueryparsersyntax;
     $class->bind_testschema;
@@ -300,9 +301,6 @@ PPCODE:
         lucy_TestVArray_run_tests();
     }
     // Lucy::Highlight
-    else if (strEQ(package, "TestHeatMap")) {
-        lucy_TestHeatMap_run_tests();
-    }
     else if (strEQ(package, "TestHighlighter")) {
         lucy_TestHighlighter_run_tests();
     }
@@ -321,6 +319,14 @@ END_XS_CODE
     Clownfish::CFC::Binding::Perl::Class->register($binding);
 }
 
+sub bind_testenginelucy {
+    my $binding = Clownfish::CFC::Binding::Perl::Class->new(
+        parcel     => "Lucy",
+        class_name => "Lucy::Test::TestEngineLucy",
+    );
+    Clownfish::CFC::Binding::Perl::Class->register($binding);
+}
+
 sub bind_testutils {
     my $xs_code = <<'END_XS_CODE';
 MODULE = Lucy   PACKAGE = Lucy::Test::TestUtils

http://git-wip-us.apache.org/repos/asf/lucy/blob/263e9bb0/perl/lib/Lucy/Test/TestEngineLucy.pm
----------------------------------------------------------------------
diff --git a/perl/lib/Lucy/Test/TestEngineLucy.pm 
b/perl/lib/Lucy/Test/TestEngineLucy.pm
new file mode 100644
index 0000000..3cfa134
--- /dev/null
+++ b/perl/lib/Lucy/Test/TestEngineLucy.pm
@@ -0,0 +1,25 @@
+# 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 Lucy::Test::TestEngineLucy;
+use Lucy;
+our $VERSION = '0.003000';
+$VERSION = eval $VERSION;
+
+1;
+
+__END__
+
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/263e9bb0/perl/t/core/310-heat_map.t
----------------------------------------------------------------------
diff --git a/perl/t/core/310-heat_map.t b/perl/t/core/310-heat_map.t
index 1195e85..698153a 100644
--- a/perl/t/core/310-heat_map.t
+++ b/perl/t/core/310-heat_map.t
@@ -16,6 +16,10 @@
 use strict;
 use warnings;
 
-use Lucy::Test;
-Lucy::Test::run_tests("TestHeatMap");
+use Lucy::Test::TestEngineLucy;
+
+my $engine  = Lucy::Test::TestEngineLucy->new(formatter_name => 'tap');
+my $success = $engine->run_named_batch('Lucy::Highlight::HeatMap');
+
+exit($success ? 0 : 1);
 

Reply via email to