[#7055] More on VC++ 2005 — Austin Ziegler <halostatue@...>

Okay. I've got Ruby compiling. I'm attempting to get everything in

17 messages 2006/01/05
[#7058] Re: More on VC++ 2005 — nobuyoshi nakada <nobuyoshi.nakada@...> 2006/01/06

Hi,

[#7084] mathn: ugly warnings — hadmut@... (Hadmut Danisch)

Hi,

22 messages 2006/01/10
[#7097] Re: mathn: ugly warnings — Daniel Berger <Daniel.Berger@...> 2006/01/10

Hadmut Danisch wrote:

[#7098] Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/10

Daniel Berger wrote:

[#7118] Re: Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/12

*Dean Wampler *<deanwampler gmail.com> writes:

[#7226] Fwd: Re: Question about massive API changes — "Sean E. Russell" <ser@...>

Hello,

23 messages 2006/01/28
[#7228] Re: Question about massive API changes — Caleb Tennis <caleb@...> 2006/01/28

>

Re: Design contracts and refactoring (was Re: mathn: ugly warnings)

From: Mathieu Bouchard <matju@...>
Date: 2006-01-12 20:05:19 UTC
List: ruby-core #7123
On Fri, 13 Jan 2006, mathew wrote:

> For example, consider a simple vector addition routine in a 3D library.
> The unit tests might test its behavior with Float and Integer vectors,
> since that's why it was written.

Here's another way to factor unit-tests that I haven't mentioned in the 
last mail.

suppose you test for + using:

  class IntegerTest
    def test; 2+2==4 or raise; end
  end
  class FloatTest
    def test; 2.0+2.0==4.0 or raise; end
  end
  class RationalTest
    def test; Rational(2,1)+Rational(2,1)==Rational(4,1) or raise; end
  end

you can refactor those tests like this:

  class NumericTest
    def initialize nt; @nt; end
    def make x; raise "abstract class" end
    def test; make(2)+make(2)==make(4) or raise; end
  end
  class  IntegerTest; def make x;  Integer(x)   end end
  class    FloatTest; def make x;    Float(x)   end end
  class RationalTest; def make x; Rational(x,1) end end

> However, to do that you need to know whether the feature of supporting
> (say) Complex vectors or BigDecimal vectors is intended or not. The unit
> tests won't tell you this.

I once called unit-tests "test-by-example" and contracts "test-by-rule". I 
think that those names are preferable to the more common names. I also had 
listed "test-by-use" which is to use the software in practice: this may 
include testing a component A using the unit tests for B because B uses A.
The last I had listed was "test-by-proof", which is rarer and is the only 
one that requires analysing the implementation.

> > One limitation of documentation is that it has no enforcement power,
> > so you have to write tests anyway to test conformance.
> Unit tests have no enforcement power either, because you can just change the
> test. Indeed, I've already had to do this once when it turned out that the
> unit test was wrong. (In net/ftp.)

That was a pretty bad case of strawman argument. Dean was assuming that 
your documentation was not executable when you had quite clearly stated 
that it was the contracts that acted as documentation!

I've thought of a triad:

  A. "the real thing"
  B. what it's documented as
  C. a way to verify that (1) and (2) agree

and another one:

  changing A to match B+C:
    programming

  changing B to match A+C:
    the scientific method (aka reverse engineering)

  changing C to match A+B:
    unit-tests and contracts and scientific experiments

 _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - t駘:+1.514.383.3801 - http://artengine.ca/matju
| Freelance Digital Arts Engineer, Montr饌l QC Canada


In This Thread