Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XP] Re: Duplicate Code in One's Testing Code

Expand Messages
  • Chris Dollin
    ... More like (tweak test, write Turtle, convert to RDF/XML):
    Message 1 of 16 , Nov 17, 2008
      On Monday 17 November 2008 02:10:48 Jeff Grigg wrote:
      > > --- Jeff Grigg <jeffgrigg@...> wrote:
      > >> The DSLs tend to be more of a syntactic thing than an
      > >> algorithm thing. I see them as a way to very compactly
      > >> express the inputs and expected outputs in a more
      > >> readable form than lines and lines of sets and asserts.
      >
      > --- "Steven Gordon" <sgordonphd@...> wrote:
      > > This is a good use of DSLs in tests, but there is a tradeoff - too
      > > compact can be harder to understand and verify. Did you understand
      > > what was going on in Chris's test code?
      >
      > Yes, I think I understand Chris' example. (Of course it's hard to be
      > sure without more contextual domain knowledge and looking at more code.)
      >
      > Offhand, it looks to me like he's testing to ensure that the result of
      > the inspection process produces an RDF (Resource Description Framework)
      > model like this (expressed in XML):
      >
      > <rdf:RDF
      > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      > xmlns:eye="{SomeURI}">
      > <rdf:Description rdf:about="{SomeOtherURI}">
      > <eye:mainProperty>
      > <eye:badDatatypeURI>
      > <eye:onLiteral>abc</eye:onLiteral>
      > <eye:badDatatypeURI>#:bar</eye:badDatatypeURI>
      > </eye:badDatatypeURI>
      > </eye:mainProperty>
      > </rdf:Description>
      > </rdf:RDF>

      More like (tweak test, write Turtle, convert to RDF/XML):

      <rdf:RDF
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:eye="http://jena.hpl.hp.com/Eyeball#"
      xmlns:ja="http://jena.hpl.hp.com/2005/11/Assembler#">
      <eye:Item>
      <eye:badDatatypeURI>#:bar</eye:badDatatypeURI>
      <eye:mainProperty rdf:resource="http://jena.hpl.hp.com/Eyeball#badDatatypeURI"/>
      <eye:onLiteral>abc</eye:onLiteral>
      </eye:Item>
      </rdf:RDF>

      There's no nesting inside this Item [1].

      > An alternate expression might be...
      >
      > verify(r.model()).mainProperty().badDatatypeURI("#:bar").onLiteral
      > ("abc");

      Hmm. I haven't given enough thought to expressing the tests in
      that fashion. I don't know whether I could make it clearer or
      not; I shall have to brood upon it. Writing the frameworky bits
      that allowed those methods to work might be subject to the same
      problems as Steven was suggesting though. (And while I'm arguing
      against Steven in this case, I do take his concerns seriously; I
      think I'm just in a different place along the tradeoff axis.)

      [1] Well, actually there's a bit I'm not mentioning; the statement S
      in the call to itemModel("that string", S) is encoded as properties
      of the Item as well, using the RDF reification properties [2].

      [2] Run away! Run away!

      --
      "We dance, and the worlds melt away." - Curved Air, /Metamorphosis/

      Hewlett-Packard Limited registered no:
      registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England
    Your message has been successfully submitted and would be delivered to recipients shortly.