Repository: lucy-clownfish Updated Branches: refs/heads/master 615d033e4 -> 02c97b29c
Run and improve Boolean tests We didn't run the Boolean tests before. Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/08c29a7a Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/08c29a7a Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/08c29a7a Branch: refs/heads/master Commit: 08c29a7a36f7ec2f735a1f164749844a7fc949fe Parents: 615d033 Author: Nick Wellnhofer <[email protected]> Authored: Tue May 10 20:52:19 2016 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Sun May 15 17:40:59 2016 +0200 ---------------------------------------------------------------------- runtime/core/Clownfish/Boolean.c | 2 +- runtime/core/Clownfish/Test.c | 2 ++ runtime/core/Clownfish/Test/TestBoolean.c | 16 +++++++++++++++- runtime/perl/t/core/030-boolean.t | 23 +++++++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/08c29a7a/runtime/core/Clownfish/Boolean.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Boolean.c b/runtime/core/Clownfish/Boolean.c index 44a7c48..61328c8 100644 --- a/runtime/core/Clownfish/Boolean.c +++ b/runtime/core/Clownfish/Boolean.c @@ -51,7 +51,7 @@ Bool_singleton(bool value) { void Bool_Destroy_IMP(Boolean *self) { - if (self && self != CFISH_TRUE && self != CFISH_FALSE) { + if (self != CFISH_TRUE && self != CFISH_FALSE) { DECREF(self->string); SUPER_DESTROY(self, BOOLEAN); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/08c29a7a/runtime/core/Clownfish/Test.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test.c b/runtime/core/Clownfish/Test.c index e1a5e9d..e5a9f50 100644 --- a/runtime/core/Clownfish/Test.c +++ b/runtime/core/Clownfish/Test.c @@ -23,6 +23,7 @@ #include "Clownfish/TestHarness/TestSuite.h" #include "Clownfish/Test/TestBlob.h" +#include "Clownfish/Test/TestBoolean.h" #include "Clownfish/Test/TestByteBuf.h" #include "Clownfish/Test/TestString.h" #include "Clownfish/Test/TestCharBuf.h" @@ -53,6 +54,7 @@ Test_create_test_suite() { TestSuite_Add_Batch(suite, (TestBatch*)TestBB_new()); TestSuite_Add_Batch(suite, (TestBatch*)TestStr_new()); TestSuite_Add_Batch(suite, (TestBatch*)TestCB_new()); + TestSuite_Add_Batch(suite, (TestBatch*)TestBoolean_new()); TestSuite_Add_Batch(suite, (TestBatch*)TestNum_new()); TestSuite_Add_Batch(suite, (TestBatch*)TestStrHelp_new()); TestSuite_Add_Batch(suite, (TestBatch*)TestAtomic_new()); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/08c29a7a/runtime/core/Clownfish/Test/TestBoolean.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestBoolean.c b/runtime/core/Clownfish/Test/TestBoolean.c index 70c1257..8835fe1 100644 --- a/runtime/core/Clownfish/Test/TestBoolean.c +++ b/runtime/core/Clownfish/Test/TestBoolean.c @@ -32,6 +32,14 @@ TestBoolean_new() { } static void +test_singleton(TestBatchRunner *runner) { + TEST_TRUE(runner, Bool_singleton(true) == CFISH_TRUE, + "Bool_singleton true"); + TEST_TRUE(runner, Bool_singleton(false) == CFISH_FALSE, + "Bool_singleton false"); +} + +static void test_To_String(TestBatchRunner *runner) { String *true_string = Bool_To_String(CFISH_TRUE); String *false_string = Bool_To_String(CFISH_FALSE); @@ -75,7 +83,13 @@ test_Clone(TestBatchRunner *runner) { void TestBoolean_Run_IMP(TestBoolean *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 10); + TestBatchRunner_Plan(runner, (TestBatch*)self, 12); + + // Destroying the singletons should have no effect. + Bool_Destroy(CFISH_TRUE); + Bool_Destroy(CFISH_FALSE); + + test_singleton(runner); test_To_String(runner); test_accessors(runner); test_Equals_and_Compare_To(runner); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/08c29a7a/runtime/perl/t/core/030-boolean.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/core/030-boolean.t b/runtime/perl/t/core/030-boolean.t new file mode 100644 index 0000000..49ec725 --- /dev/null +++ b/runtime/perl/t/core/030-boolean.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::Test; +my $success = Clownfish::Test::run_tests("Clownfish::Test::TestBoolean"); + +exit($success ? 0 : 1); +
