lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master eff49eb 1/8: Assert more invariants


From: Greg Chicares
Subject: [lmi-commits] [lmi] master eff49eb 1/8: Assert more invariants
Date: Thu, 23 Feb 2017 05:29:06 -0500 (EST)

branch: master
commit eff49eb76e2ae25472c86e24e51c34f1022fe6ad
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Assert more invariants
    
    The added invariants have been established:
     - for the ctor-of-many-arguments, by fill_interval_gaps();
     - for the vector ctors, by ValueInterval().
    
    assert_not_insane_or_disordered() was made the first assertion for
    InputSequence because it is a postcondition of SequenceParser, so it
    is established first. This doesn't change valid observable behavior
    because the order of these assertions is arbitrary.
---
 input_sequence.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/input_sequence.cpp b/input_sequence.cpp
index 89c4724..a913126 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -302,18 +302,18 @@ std::vector<ValueInterval> const& 
InputSequence::interval_representation() const
 
 void InputSequence::realize_intervals()
 {
-    // Post-construction invariants.
-    // Every ctor must already have established this...
-    LMI_ASSERT(!intervals_.empty());
-    // ...and this:
-    LMI_ASSERT(years_to_maturity_ == intervals_.back().end_duration);
-    // It cannot be assumed that all ctors have yet established this...
-    intervals_.back().end_mode = e_maturity;
-    // ...though now of course it has been established:
-    LMI_ASSERT(e_maturity        == intervals_.back().end_mode    );
+    // Post-construction invariants that every ctor has already established.
 
     assert_not_insane_or_disordered(intervals_, years_to_maturity_);
 
+    LMI_ASSERT(!intervals_.empty());
+
+    LMI_ASSERT(0                  == intervals_.front().begin_duration);
+    LMI_ASSERT(e_inception        == intervals_.front().begin_mode    );
+
+    LMI_ASSERT(years_to_maturity_ == intervals_.back().end_duration);
+    LMI_ASSERT(e_maturity         == intervals_.back().end_mode    );
+
     std::vector<double>      r(years_to_maturity_);
     std::vector<std::string> s(years_to_maturity_, default_keyword_);
     number_result_  = r;



reply via email to

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