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.44.213 with SMTP id 21mr25721937qtx.26.1509322603070; Sun, 29 Oct 2017 17:16:43 -0700 (PDT) X-Received: by 10.157.85.8 with SMTP id l8mr603077oth.7.1509322603036; Sun, 29 Oct 2017 17:16:43 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!k31no5164024qta.1!news-out.google.com!r5ni5387qtc.1!nntp.google.com!k31no5164023qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 29 Oct 2017 17:16:42 -0700 (PDT) In-Reply-To: <81f4fbf9-fef3-4592-a95e-64889e564df4@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.113.16.86; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 76.113.16.86 References: <81f4fbf9-fef3-4592-a95e-64889e564df4@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: What am I doing wrong with contracts? Why are they succeeding when they should be failing? From: Shark8 Injection-Date: Mon, 30 Oct 2017 00:16:43 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 1818 X-Received-Body-CRC: 1654098003 Xref: news.eternal-september.org comp.lang.ada:48650 Date: 2017-10-29T17:16:42-07:00 List-Id: > 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)".