[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;
- [lmi-commits] [lmi] master updated (c463357 -> 520bb97), Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 4c54e90 02/14: Self test: explicitly specify product, Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master c2f6854 03/14: Self test: print more timings, Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master ccb70ce 04/14: Self test: measure speed for 'finra' as well as 'ill_reg', Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master f6dfcf1 05/14: Filter out self-test timings, Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 19be5c7 07/14: Don't initialize what's already been initialized,
Greg Chicares <=
- [lmi-commits] [lmi] master 5dec884 01/14: Include appropriate headers, Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master fa15960 06/14: Don't touch a ledger object before calling its Init(), Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 520bb97 14/14: Call ledger Init() less repeatedly [340], Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 74927c6 13/14: Eradicate 'EePmt' and 'ErPmt', Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master c017212 08/14: Make 'daily_interest_accounting' harder to overlook, Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 80f3ab4 09/14: Don't touch a ledger object before calling its Init() (bis), Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 4a28bc2 10/14: Replace 'EePmt' (antediluvian), Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 9ba754c 11/14: Replace 'EePmt' and 'ErPmt' (production), Greg Chicares, 2020/08/29
- [lmi-commits] [lmi] master 5827c93 12/14: No longer assign to 'EePmt' and 'ErPmt', Greg Chicares, 2020/08/29