From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.200.18.132 with SMTP id y4mr26676143qti.24.1509327444890; Sun, 29 Oct 2017 18:37:24 -0700 (PDT) X-Received: by 10.157.0.7 with SMTP id 7mr645623ota.14.1509327444857; Sun, 29 Oct 2017 18:37:24 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!k31no5200974qta.1!news-out.google.com!r5ni5477qtc.1!nntp.google.com!k31no5200970qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 29 Oct 2017 18:37:24 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:18f:900:f900:890b:5da7:fc3a:7d41; posting-account=3pYsyQoAAACcI-ym7XtMOI2PDU8gRZS5 NNTP-Posting-Host: 2601:18f:900:f900:890b:5da7:fc3a:7d41 References: <81f4fbf9-fef3-4592-a95e-64889e564df4@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4924b0ad-47a2-497e-a363-a341726ca45d@googlegroups.com> Subject: Re: What am I doing wrong with contracts? Why are they succeeding when they should be failing? From: Andrew Shvets Injection-Date: Mon, 30 Oct 2017 01:37:24 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:48652 Date: 2017-10-29T18:37:24-07:00 List-Id: On Sunday, October 29, 2017 at 8:16:43 PM UTC-4, Shark8 wrote: > > procedure Multiply_By_Two(Arr : in out Int_Array) > > with Pre => (for all Item in Arr'Range => > > Arr(Item) /= 6), > > Post => (for all Item in Arr'Range => > > Arr(Item) = Arr'Old(Item) * 2); > > > > > > I simply pass in the array into Multiply_By_Two and then print out the array as needed. This is what gets me. The array has elements going from 6 to 45. > > Your precondition is wrong then, all it's checking is that the [elements of the] inputs aren't 6, leaving things like 2 or 3 (or -17) as valid. I would recommend something like "with Pre => (for all Item in Arr'Range => Arr(Item) in 6..45)". I did that on purpose. I was trying to figure out why my logic wasn't working, so I used a blatantly wrong comparison (the array did have one 6 in it, so I should have seen an error.)