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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,9e7db243dfa070d7 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Do people who use Ada also use ocaml or F#? Date: Sat, 06 Nov 2010 16:56:14 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <87k4kz3mda.fsf@mid.deneb.enyo.de> <5jjgrklivesk$.z0is5qe7mgbt.dlg@40tude.net> <82mxpmz7t3.fsf@stephe-leake.org> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1289076974 20954 192.74.137.71 (6 Nov 2010 20:56:14 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 6 Nov 2010 20:56:14 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:Id40SOV/2vaZMtHCpCfRlK8I3VE= Xref: g2news2.google.com comp.lang.ada:16320 Date: 2010-11-06T16:56:14-04:00 List-Id: Stephen Leake writes: > Robert A Duff writes: > >> "Dmitry A. Kazakov" writes: >> >>> How do you execute a generic body? Testable are generic instances. >> >> You can't test a generic without instantiating it. >> >> You can't test a procedure without calling it. >> >> You can't test an abstract type without declaring >> a concrete type, and some objects of that type. >> >> What am I missing? > > To truly test a generic, you need to test with all possible > instantiations. To "truly" test a procedure, you have to call it with all possible parameter values (and all possible globals, if it uses those). > Or at least with a representative subset. Right, it's usually impossible to try all possibilities, so we pick some subset -- for generics and for procedures. >...If the generic parameters are > well structured, it may be possible to show that a few instances are > sufficient. For something like Ada.Containers.Vectors, it's fairly easy to know that the code doesn't much care what the element type is. If you find a bug in a generic, it is almost certainly a bug in every instance, in my experience. Only rarely does the bug depend on specific properties of some instance. > That's much more effort than testing a single concrete procedure. Well, I agree that testing a generic is typically harder than testing a single procedure. That's because generics are typically more, um, "general". But the claim was that generics are untestable, which seems too extreme to me. And if you replace generics with some other feature, then if that feature has the generality desired, it will be equally hard to test. > It may be worth it, of course; I often use generics precisely to reduce > testing burden. Right, it's certainly easier to test a generic, than to write similar code 20 times for 20 different types, and test all of those. Just like it's easier to test a single procedure than to test 20 cut&pasted versions of the same code (each of which has been slightly modified so they're not quite identical anymore). - Bob