You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2013/07/17 16:12:52 UTC

[lucy-commits] [32/34] git commit: refs/heads/master - Avoid non-parcel member access in TestLucy.

Avoid non-parcel member access in TestLucy.

Use various techniques to avoid accessing member vars defined in other
parcels.


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

Branch: refs/heads/master
Commit: bef4852e664e0232267cc585a32275dd3031abae
Parents: abf9363
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Fri Jul 12 19:18:18 2013 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Tue Jul 16 16:08:44 2013 -0700

----------------------------------------------------------------------
 core/Lucy/Test/Search/TestQueryParserLogic.c |  2 +-
 core/Lucy/Test/Search/TestSortSpec.c         |  7 +-----
 core/Lucy/Test/TestSchema.c                  | 26 +++++++++++++----------
 core/Lucy/Test/TestSchema.cfh                |  6 ++++--
 4 files changed, 21 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/bef4852e/core/Lucy/Test/Search/TestQueryParserLogic.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestQueryParserLogic.c b/core/Lucy/Test/Search/TestQueryParserLogic.c
index 22a86c1..5bc51e9 100644
--- a/core/Lucy/Test/Search/TestQueryParserLogic.c
+++ b/core/Lucy/Test/Search/TestQueryParserLogic.c
@@ -858,7 +858,7 @@ static Lucy_TestQPLogic_Prune_Test_t prune_test_funcs[] = {
 
 static Folder*
 S_create_index() {
-    Schema     *schema  = (Schema*)TestSchema_new();
+    Schema     *schema  = (Schema*)TestSchema_new(false);
     RAMFolder  *folder  = RAMFolder_new(NULL);
     VArray     *doc_set = TestUtils_doc_set();
     Indexer    *indexer = Indexer_new(schema, (Obj*)folder, NULL, 0);

http://git-wip-us.apache.org/repos/asf/lucy/blob/bef4852e/core/Lucy/Test/Search/TestSortSpec.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestSortSpec.c b/core/Lucy/Test/Search/TestSortSpec.c
index 990ac9d..1a7df6d 100644
--- a/core/Lucy/Test/Search/TestSortSpec.c
+++ b/core/Lucy/Test/Search/TestSortSpec.c
@@ -153,12 +153,7 @@ TestReverseType_init(TestReverseType *self) {
 TestReverseType*
 TestReverseType_init2(TestReverseType *self, float boost, bool indexed,
                       bool stored, bool sortable) {
-    FType_init((FieldType*)self);
-    TestReverseTypeIVARS *const ivars = TestReverseType_IVARS(self);
-    ivars->boost      = boost;
-    ivars->indexed    = indexed;
-    ivars->stored     = stored;
-    ivars->sortable   = sortable;
+    Int32Type_init2((Int32Type*)self, boost, indexed, stored, sortable);
     return self;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/bef4852e/core/Lucy/Test/TestSchema.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/TestSchema.c b/core/Lucy/Test/TestSchema.c
index 2507bfb..6c28296 100644
--- a/core/Lucy/Test/TestSchema.c
+++ b/core/Lucy/Test/TestSchema.c
@@ -27,16 +27,18 @@
 #include "Lucy/Plan/Architecture.h"
 
 TestSchema*
-TestSchema_new() {
+TestSchema_new(bool use_alt_arch) {
     TestSchema *self = (TestSchema*)VTable_Make_Obj(TESTSCHEMA);
-    return TestSchema_init(self);
+    return TestSchema_init(self, use_alt_arch);
 }
 
 TestSchema*
-TestSchema_init(TestSchema *self) {
+TestSchema_init(TestSchema *self, bool use_alt_arch) {
     StandardTokenizer *tokenizer = StandardTokenizer_new();
     FullTextType *type = FullTextType_new((Analyzer*)tokenizer);
 
+    TestSchema_IVARS(self)->use_alt_arch = use_alt_arch;
+
     Schema_init((Schema*)self);
     FullTextType_Set_Highlightable(type, true);
     CharBuf *content = (CharBuf*)ZCB_WRAP_STR("content", 7);
@@ -49,8 +51,12 @@ TestSchema_init(TestSchema *self) {
 
 Architecture*
 TestSchema_architecture(TestSchema *self) {
-    UNUSED_VAR(self);
-    return (Architecture*)TestArch_new();
+    if (TestSchema_IVARS(self)->use_alt_arch) {
+        return Arch_new();
+    }
+    else {
+        return (Architecture*)TestArch_new();
+    }
 }
 
 TestBatchSchema*
@@ -60,9 +66,9 @@ TestBatchSchema_new() {
 
 static void
 test_Equals(TestBatchRunner *runner) {
-    TestSchema *schema = TestSchema_new();
-    TestSchema *arch_differs = TestSchema_new();
-    TestSchema *spec_differs = TestSchema_new();
+    TestSchema *schema = TestSchema_new(false);
+    TestSchema *arch_differs = TestSchema_new(true);
+    TestSchema *spec_differs = TestSchema_new(false);
     CharBuf    *content      = (CharBuf*)ZCB_WRAP_STR("content", 7);
     FullTextType *type = (FullTextType*)TestSchema_Fetch_Type(spec_differs,
                                                               content);
@@ -73,8 +79,6 @@ test_Equals(TestBatchRunner *runner) {
     TEST_FALSE(runner, TestSchema_Equals(schema, (Obj*)spec_differs),
                "Equals spoiled by differing FieldType");
 
-    DECREF(TestSchema_IVARS(arch_differs)->arch);
-    TestSchema_IVARS(arch_differs)->arch = Arch_new();
     TEST_FALSE(runner, TestSchema_Equals(schema, (Obj*)arch_differs),
                "Equals spoiled by differing Architecture");
 
@@ -85,7 +89,7 @@ test_Equals(TestBatchRunner *runner) {
 
 static void
 test_Dump_and_Load(TestBatchRunner *runner) {
-    TestSchema *schema = TestSchema_new();
+    TestSchema *schema = TestSchema_new(false);
     Obj        *dump   = (Obj*)TestSchema_Dump(schema);
     TestSchema *loaded = (TestSchema*)Obj_Load(dump, dump);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/bef4852e/core/Lucy/Test/TestSchema.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/TestSchema.cfh b/core/Lucy/Test/TestSchema.cfh
index c422435..87dd41a 100644
--- a/core/Lucy/Test/TestSchema.cfh
+++ b/core/Lucy/Test/TestSchema.cfh
@@ -23,11 +23,13 @@ parcel TestLucy;
  */
 
 class Lucy::Test::TestSchema inherits Lucy::Plan::Schema {
+    bool use_alt_arch;
+
     inert incremented TestSchema*
-    new();
+    new(bool use_alt_arch = false);
 
     inert TestSchema*
-    init(TestSchema *self);
+    init(TestSchema *self, bool use_alt_arch = false);
 
     public incremented Architecture*
     Architecture(TestSchema *self);