lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 19be5c7 07/14: Don't initialize what's alread


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 19be5c7 07/14: Don't initialize what's already been initialized
Date: Sat, 29 Aug 2020 19:34:49 -0400 (EDT)

branch: master
commit 19be5c72c2da7a350e48fc171b09d07eca6a6fb7
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Don't initialize what's already been initialized
    
    The removed assignments only initialized certain variables in exactly
    the same way they had already been initialized.
    
    Replaced those assignments with assertions, because assertions are cheap
    and the conditions asserted are assumed to hold.
    
    Notably, these assertions would have failed in the place where the
    removed assignments resided before the immediately preceding commit.
    Important is the order of processing.
    
    Curiously, though, the added assertions always succeeded in a system
    test comprising 1510 cases, even without the 'ledger_invariant.cpp'
    change--demonstrating that
     - automated tests provide no affirmative proof of correctness, and
     - assertions are valuable, but
     - there's no substitute for studying the code.
    LedgerVariant::Init() already established the invariants asserted here,
    so 'ledger_variant.cpp' required no change.
---
 ihs_acctval.cpp      | 22 +++++++++++-----------
 ledger_invariant.cpp |  1 +
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index fccf9be..3c2840d 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -424,17 +424,17 @@ void AccountValue::InitializeLife(mcenum_run_basis 
a_Basis)
     VariantValues().Init(*this, GenBasis_, SepBasis_);
     InvariantValues().Init(this);
 
-    // Assume by default that the policy never lapses or becomes a MEC,
-    // so that the lapse and MEC durations are the last possible month.
-    // TODO ?? TAXATION !! Last possible month? Why? In that month, it doesn't 
quite
-    // lapse, and it's certainly wrong to assume it becomes a MEC then.
-
-    VariantValues().LapseMonth  = 11;
-    VariantValues().LapseYear   = BasicValues::GetLength();
-
-    InvariantValues().IsMec     = false;
-    InvariantValues().MecMonth  = 11;
-    InvariantValues().MecYear   = BasicValues::GetLength();
+    // Default initial values assume that the policy never lapses or
+    // becomes a MEC, so that the lapse and MEC durations are the last
+    // possible month.
+    // TODO ?? TAXATION !! Last possible month? Why? In that month, it
+    // doesn't quite lapse, and it's certainly wrong to assume it
+    // becomes a MEC then.
+    LMI_ASSERT(11                       == VariantValues().LapseMonth);
+    LMI_ASSERT(BasicValues::GetLength() == VariantValues().LapseYear );
+    LMI_ASSERT(false                    == InvariantValues().IsMec   );
+    LMI_ASSERT(11                       == InvariantValues().MecMonth);
+    LMI_ASSERT(BasicValues::GetLength() == InvariantValues().MecYear );
 
     OldDBOpt = DeathBfts_->dbopt()[0];
     // TAXATION !! 'OldSA' and 'OldDB' need to be distinguished for 7702 and 
7702A,
diff --git a/ledger_invariant.cpp b/ledger_invariant.cpp
index 25cb093..0fa60ee 100644
--- a/ledger_invariant.cpp
+++ b/ledger_invariant.cpp
@@ -508,6 +508,7 @@ void LedgerInvariant::Init()
     SurvivalMaxAge             = 0;
     InforceYear                = Length;
     InforceMonth               = 11;
+    IsMec                      = false;
     MecYear                    = Length;
     MecMonth                   = 11;
     SpouseIssueAge             = 100;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]