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/03/30 18:41:20 UTC
[lucy-commits] [1/2] git commit: refs/heads/master - Skip tests if RegexTokenizer is
not available
Updated Branches:
refs/heads/master 0df8da88c -> 22ea87d30
Skip tests if RegexTokenizer is not available
Add a function RegexTokenizer_is_available and skip tests requiring
RegexTokenizer if it returns false.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/0147d90f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/0147d90f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/0147d90f
Branch: refs/heads/master
Commit: 0147d90f008f5b34168e37481244f558e9d45b66
Parents: 0df8da8
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Mar 30 17:30:29 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Mar 30 17:33:11 2013 +0100
----------------------------------------------------------------------
c/src/Lucy/Analysis/RegexTokenizer.c | 10 ++++++++++
core/Lucy/Analysis/RegexTokenizer.cfh | 6 ++++++
core/Lucy/Test/Analysis/TestPolyAnalyzer.c | 11 ++++++++++-
core/Lucy/Test/Analysis/TestRegexTokenizer.c | 10 +++++++++-
core/Lucy/Test/Search/TestQueryParserSyntax.c | 15 +++++++++++++++
perl/xs/Lucy/Analysis/RegexTokenizer.c | 5 +++++
6 files changed, 55 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/0147d90f/c/src/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Analysis/RegexTokenizer.c b/c/src/Lucy/Analysis/RegexTokenizer.c
index ae4c7d1..2e2ebfc 100644
--- a/c/src/Lucy/Analysis/RegexTokenizer.c
+++ b/c/src/Lucy/Analysis/RegexTokenizer.c
@@ -37,6 +37,11 @@
static uint32_t
S_count_code_points(const char *string, size_t len);
+bool
+RegexTokenizer_is_available(void) {
+ return true;
+}
+
RegexTokenizer*
RegexTokenizer_init(RegexTokenizer *self, const CharBuf *pattern) {
Analyzer_init((Analyzer*)self);
@@ -141,6 +146,11 @@ S_count_code_points(const char *string, size_t len) {
#else // HAS_PCRE_H
+bool
+RegexTokenizer_is_available(void) {
+ return false;
+}
+
RegexTokenizer*
RegexTokenizer_init(RegexTokenizer *self, const CharBuf *pattern) {
THROW(ERR,
http://git-wip-us.apache.org/repos/asf/lucy/blob/0147d90f/core/Lucy/Analysis/RegexTokenizer.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/RegexTokenizer.cfh b/core/Lucy/Analysis/RegexTokenizer.cfh
index 77dc87c..72c7097 100644
--- a/core/Lucy/Analysis/RegexTokenizer.cfh
+++ b/core/Lucy/Analysis/RegexTokenizer.cfh
@@ -53,6 +53,12 @@ public class Lucy::Analysis::RegexTokenizer
CharBuf *pattern;
void *token_re;
+ /**
+ * @return true if RegexTokenizer is available in this build.
+ */
+ inert bool
+ is_available();
+
inert incremented RegexTokenizer*
new(const CharBuf *pattern = NULL);
http://git-wip-us.apache.org/repos/asf/lucy/blob/0147d90f/core/Lucy/Test/Analysis/TestPolyAnalyzer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestPolyAnalyzer.c b/core/Lucy/Test/Analysis/TestPolyAnalyzer.c
index 1d1e030..7c6178c 100644
--- a/core/Lucy/Test/Analysis/TestPolyAnalyzer.c
+++ b/core/Lucy/Test/Analysis/TestPolyAnalyzer.c
@@ -23,13 +23,15 @@
#include "Lucy/Test/Analysis/TestPolyAnalyzer.h"
#include "Lucy/Analysis/PolyAnalyzer.h"
#include "Lucy/Analysis/Normalizer.h"
+#include "Lucy/Analysis/RegexTokenizer.h"
#include "Lucy/Analysis/SnowballStopFilter.h"
#include "Lucy/Analysis/SnowballStemmer.h"
#include "Lucy/Analysis/StandardTokenizer.h"
TestPolyAnalyzer*
TestPolyAnalyzer_new(TestFormatter *formatter) {
- TestPolyAnalyzer *self = (TestPolyAnalyzer*)VTable_Make_Obj(TESTPOLYANALYZER);
+ TestPolyAnalyzer *self
+ = (TestPolyAnalyzer*)VTable_Make_Obj(TESTPOLYANALYZER);
return TestPolyAnalyzer_init(self, formatter);
}
@@ -40,6 +42,13 @@ TestPolyAnalyzer_init(TestPolyAnalyzer *self, TestFormatter *formatter) {
static void
test_Dump_Load_and_Equals(TestBatch *batch) {
+ if (!RegexTokenizer_is_available()) {
+ SKIP(batch, "RegexTokenizer not available");
+ SKIP(batch, "RegexTokenizer not available");
+ SKIP(batch, "RegexTokenizer not available");
+ return;
+ }
+
CharBuf *EN = (CharBuf*)ZCB_WRAP_STR("en", 2);
CharBuf *ES = (CharBuf*)ZCB_WRAP_STR("es", 2);
PolyAnalyzer *analyzer = PolyAnalyzer_new(EN, NULL);
http://git-wip-us.apache.org/repos/asf/lucy/blob/0147d90f/core/Lucy/Test/Analysis/TestRegexTokenizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestRegexTokenizer.c b/core/Lucy/Test/Analysis/TestRegexTokenizer.c
index 9208f62..4a97bf7 100644
--- a/core/Lucy/Test/Analysis/TestRegexTokenizer.c
+++ b/core/Lucy/Test/Analysis/TestRegexTokenizer.c
@@ -25,7 +25,8 @@
TestRegexTokenizer*
TestRegexTokenizer_new(TestFormatter *formatter) {
- TestRegexTokenizer *self = (TestRegexTokenizer*)VTable_Make_Obj(TESTREGEXTOKENIZER);
+ TestRegexTokenizer *self
+ = (TestRegexTokenizer*)VTable_Make_Obj(TESTREGEXTOKENIZER);
return TestRegexTokenizer_init(self, formatter);
}
@@ -36,6 +37,13 @@ TestRegexTokenizer_init(TestRegexTokenizer *self, TestFormatter *formatter) {
static void
test_Dump_Load_and_Equals(TestBatch *batch) {
+ if (!RegexTokenizer_is_available()) {
+ SKIP(batch, "RegexTokenizer not available");
+ SKIP(batch, "RegexTokenizer not available");
+ SKIP(batch, "RegexTokenizer not available");
+ return;
+ }
+
ZombieCharBuf *word_char_pattern = ZCB_WRAP_STR("\\w+", 3);
ZombieCharBuf *whitespace_pattern = ZCB_WRAP_STR("\\S+", 3);
RegexTokenizer *word_char_tokenizer
http://git-wip-us.apache.org/repos/asf/lucy/blob/0147d90f/core/Lucy/Test/Search/TestQueryParserSyntax.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestQueryParserSyntax.c b/core/Lucy/Test/Search/TestQueryParserSyntax.c
index 1d2025a..dd209e3 100644
--- a/core/Lucy/Test/Search/TestQueryParserSyntax.c
+++ b/core/Lucy/Test/Search/TestQueryParserSyntax.c
@@ -380,6 +380,21 @@ static Lucy_TestQPSyntax_Test_t syntax_test_funcs[] = {
static void
test_query_parser_syntax(TestBatch *batch) {
+ if (!RegexTokenizer_is_available()) {
+ for (uint32_t i = 0; leaf_test_funcs[i] != NULL; i++) {
+ SKIP(batch, "RegexTokenizer not available");
+ SKIP(batch, "RegexTokenizer not available");
+ SKIP(batch, "RegexTokenizer not available");
+ }
+
+ for (uint32_t i = 0; syntax_test_funcs[i] != NULL; i++) {
+ SKIP(batch, "RegexTokenizer not available");
+ SKIP(batch, "RegexTokenizer not available");
+ }
+
+ return;
+ }
+
Folder *index = build_index();
IndexSearcher *searcher = IxSearcher_new((Obj*)index);
QueryParser *qparser = QParser_new(IxSearcher_Get_Schema(searcher),
http://git-wip-us.apache.org/repos/asf/lucy/blob/0147d90f/perl/xs/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Analysis/RegexTokenizer.c b/perl/xs/Lucy/Analysis/RegexTokenizer.c
index a1dd905..aba7b80 100644
--- a/perl/xs/Lucy/Analysis/RegexTokenizer.c
+++ b/perl/xs/Lucy/Analysis/RegexTokenizer.c
@@ -33,6 +33,11 @@ S_set_token_re_but_not_pattern(lucy_RegexTokenizer *self, void *token_re);
static void
S_set_pattern_from_token_re(lucy_RegexTokenizer *self, void *token_re);
+bool
+lucy_RegexTokenizer_is_available(void) {
+ return true;
+}
+
lucy_RegexTokenizer*
lucy_RegexTokenizer_init(lucy_RegexTokenizer *self,
const lucy_CharBuf *pattern) {
[lucy-commits] [2/2] git commit: refs/heads/master - Make CFCParamList_to_c return
"void" for empty param lists
Posted by nw...@apache.org.
Make CFCParamList_to_c return "void" for empty param lists
So we get a compiler error if a nullary function is called with
arguments.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/22ea87d3
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/22ea87d3
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/22ea87d3
Branch: refs/heads/master
Commit: 22ea87d30464574c4359c9c37a2ac6e38a5569c3
Parents: 0147d90
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Mar 30 18:29:07 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Mar 30 18:35:14 2013 +0100
----------------------------------------------------------------------
clownfish/compiler/src/CFCParamList.c | 6 ++++++
clownfish/compiler/src/CFCTestParamList.c | 13 ++++++++++++-
2 files changed, 18 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/22ea87d3/clownfish/compiler/src/CFCParamList.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParamList.c b/clownfish/compiler/src/CFCParamList.c
index 279aecd..43e5408 100644
--- a/clownfish/compiler/src/CFCParamList.c
+++ b/clownfish/compiler/src/CFCParamList.c
@@ -105,6 +105,9 @@ S_generate_c_strings(CFCParamList *self) {
if (self->variadic) {
c_string_size += sizeof(", ...");
}
+ if (self->num_vars == 0) {
+ c_string_size += sizeof("void");
+ }
FREEMEM(self->c_string);
FREEMEM(self->name_list);
self->c_string = (char*)MALLOCATE(c_string_size);
@@ -127,6 +130,9 @@ S_generate_c_strings(CFCParamList *self) {
strcat(self->name_list, ", ");
}
}
+ if (self->num_vars == 0) {
+ strcat(self->c_string, "void");
+ }
}
CFCVariable**
http://git-wip-us.apache.org/repos/asf/lucy/blob/22ea87d3/clownfish/compiler/src/CFCTestParamList.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestParamList.c b/clownfish/compiler/src/CFCTestParamList.c
index dd43d5b..0fd552c 100644
--- a/clownfish/compiler/src/CFCTestParamList.c
+++ b/clownfish/compiler/src/CFCTestParamList.c
@@ -27,7 +27,7 @@ S_run_tests(CFCTest *test);
const CFCTestBatch CFCTEST_BATCH_PARAM_LIST = {
"Clownfish::CFC::Model::ParamList",
- 16,
+ 21,
S_run_tests
};
@@ -69,6 +69,17 @@ S_run_tests(CFCTest *test) {
CFCBase_decref((CFCBase*)param_list);
}
+ {
+ CFCParamList *param_list
+ = CFCTest_parse_param_list(test, parser, "()");
+ STR_EQ(test, CFCParamList_to_c(param_list), "void", "to_c");
+ INT_EQ(test, CFCParamList_num_vars(param_list), 0, "num_vars");
+ CFCVariable **variables = CFCParamList_get_variables(param_list);
+ OK(test, variables[0] == NULL, "get_variables");
+
+ CFCBase_decref((CFCBase*)param_list);
+ }
+
CFCBase_decref((CFCBase*)parser);
CFCBase_decref((CFCBase*)neato_parcel);