Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #10555

Re: Question re testing constructor

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Question re testing constructor
Date Tue, 06 Dec 2011 07:23:28 -0800
Organization A noiseless patient Spider
Lines 14
Message-ID <jblc1i$n6u$1@dont-email.me> (permalink)
References <Xns9FB3682A7DBF6jpnasty@94.75.214.39>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 6 Dec 2011 15:23:30 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="23774"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LtgBvz4JHdh8feWNgGVjlcovbtejd0m8="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <Xns9FB3682A7DBF6jpnasty@94.75.214.39>
Cancel-Lock sha1:HG3ai28LDuYgSJDnxifhV/BN2BU=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10555

Show key headers only | View raw


On 12/6/2011 7:14 AM, Novice wrote:
> Unfortunately, the assertTrue() statement gets flagged by the compiler as
> being dead code. Am I right in assuming that it is essentially looking at
> the instantiation of the HexColor class and reasoning that it will
> inevitably create SOMETHING so that hexColor can't possibly be null,
> therefore the assertTrue() can't ever be executed?

I'm pretty sure, yes.  The "new" operator always has to return an 
object, or throw an error.  Factory methods are just methods, and can 
return null, but new *must* return an object if it completes.

P.S. Don't use assertTrue just to print something.  Just use 
System.out.println, it works fine, and makes your intent more clear.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Question re testing constructor Novice <novice@example..com> - 2011-12-06 15:14 +0000
  Re: Question re testing constructor markspace <-@.> - 2011-12-06 07:23 -0800
    Re: Question re testing constructor Novice <novice@example..com> - 2011-12-06 17:17 +0000
    Re: Question re testing constructor Tom Anderson <twic@urchin.earth.li> - 2011-12-06 21:25 +0000
    Re: Question re testing constructor Ian Shef <invalid@avoiding.spam> - 2011-12-07 00:29 +0000
      Re: Question re testing constructor Patricia Shanahan <pats@acm.org> - 2011-12-06 19:28 -0800
      Re: Question re testing constructor Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-12-06 22:57 -0600
      Re: Question re testing constructor Lew <lewbloch@gmail.com> - 2011-12-07 07:12 -0800
      Re: Question re testing constructor Lew <lewbloch@gmail.com> - 2011-12-07 07:14 -0800
        Re: Question re testing constructor Ian Shef <invalid@avoiding.spam> - 2011-12-07 15:59 +0000
          Re: Question re testing constructor Ian Shef <invalid@avoiding.spam> - 2011-12-08 19:19 +0000
      Re: Question re testing constructor ilAn <idonot@wantspam.net> - 2011-12-07 20:41 +0200
  Re: Question re testing constructor Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-12-06 07:34 -0800
    Re: Question re testing constructor Novice <novice@example..com> - 2011-12-06 17:15 +0000
  Re: Question re testing constructor Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-12-06 09:49 -0800
  Re: Question re testing constructor Roedy Green <see_website@mindprod.com.invalid> - 2011-12-06 16:40 -0800
  Re: Question re testing constructor Henk van Voorthuijsen <voorth@xs4all.nl> - 2011-12-07 00:33 -0800

csiph-web