caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Testing Camlp4-generated code
@ 2005-11-05 22:33 Matt Gushee
  2005-11-06 22:10 ` [Caml-list] " Martin Jambon
  2005-11-07  9:10 ` Hendrik Tews
  0 siblings, 2 replies; 4+ messages in thread
From: Matt Gushee @ 2005-11-05 22:33 UTC (permalink / raw)
  To: caml-list

I have developed a tool that generates a module using Camlp4, and I
would like to be able to test the output. The structure is fairly small
and simple, so it should be sufficient to verify that a generated module
is equivalent to a certain hand-coded module ... but is there a reliable
way to do that?

If it makes a difference, the output consists mainly of two values: a
data structure which is of an abstract type, and an object. The former
is implemented as follows:

   type data = S of string | L of string list | D of t
   and t = {
     data : (string, data) Hashtbl.t;
     mutable locked : bool;
   }

and the latter is an immediate object, but it inherits from a class
defined in another module. The object is associated with two instances
of the above type, has public methods that get and set values, and may
contain one or more sub-objects similar to itself.

Thanks in advance for any suggestions.

-- 
Matt Gushee
Englewood, CO, USA


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Testing Camlp4-generated code
  2005-11-05 22:33 Testing Camlp4-generated code Matt Gushee
@ 2005-11-06 22:10 ` Martin Jambon
  2005-11-06 22:16   ` Martin Jambon
  2005-11-07  9:10 ` Hendrik Tews
  1 sibling, 1 reply; 4+ messages in thread
From: Martin Jambon @ 2005-11-06 22:10 UTC (permalink / raw)
  To: Matt Gushee; +Cc: caml-list

On Sat, 5 Nov 2005, Matt Gushee wrote:

> I have developed a tool that generates a module using Camlp4, and I
> would like to be able to test the output. The structure is fairly small
> and simple, so it should be sufficient to verify that a generated module
> is equivalent to a certain hand-coded module ... but is there a reliable
> way to do that?

My 2 cents:
   camlp4o pa_yourextension.cmo pr_o.cmo input.ml > auto.ml
   camlp4o manual.ml > manual2.ml
   diff auto.ml manual2.ml

Of course if you have a lot of automatic identifiers, that's not very 
convenient. But at least you will get the same indentation if your 
identifiers have the same length.


> If it makes a difference, the output consists mainly of two values: a
> data structure which is of an abstract type, and an object. The former
> is implemented as follows:
>
>   type data = S of string | L of string list | D of t
>   and t = {
>     data : (string, data) Hashtbl.t;
>     mutable locked : bool;
>   }
>
> and the latter is an immediate object, but it inherits from a class
> defined in another module. The object is associated with two instances
> of the above type, has public methods that get and set values, and may
> contain one or more sub-objects similar to itself.
>
> Thanks in advance for any suggestions.
>
> -- 
> Matt Gushee
> Englewood, CO, USA
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

--
Martin Jambon, PhD


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Testing Camlp4-generated code
  2005-11-06 22:10 ` [Caml-list] " Martin Jambon
@ 2005-11-06 22:16   ` Martin Jambon
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Jambon @ 2005-11-06 22:16 UTC (permalink / raw)
  To: Martin Jambon; +Cc: Matt Gushee, caml-list

On Sun, 6 Nov 2005, Martin Jambon wrote:

> On Sat, 5 Nov 2005, Matt Gushee wrote:
>
>> I have developed a tool that generates a module using Camlp4, and I
>> would like to be able to test the output. The structure is fairly small
>> and simple, so it should be sufficient to verify that a generated module
>> is equivalent to a certain hand-coded module ... but is there a reliable
>> way to do that?
>
> My 2 cents:
>  camlp4o pa_yourextension.cmo pr_o.cmo input.ml > auto.ml
>  camlp4o manual.ml > manual2.ml

I meant reindenting:
    camlp4o pr_o.cmo manual.ml > manual2.ml

>  diff auto.ml manual2.ml
>
> Of course if you have a lot of automatic identifiers, that's not very 
> convenient. But at least you will get the same indentation if your 
> identifiers have the same length.
>
>
>> If it makes a difference, the output consists mainly of two values: a
>> data structure which is of an abstract type, and an object. The former
>> is implemented as follows:
>>
>>   type data = S of string | L of string list | D of t
>>   and t = {
>>     data : (string, data) Hashtbl.t;
>>     mutable locked : bool;
>>   }
>> 
>> and the latter is an immediate object, but it inherits from a class
>> defined in another module. The object is associated with two instances
>> of the above type, has public methods that get and set values, and may
>> contain one or more sub-objects similar to itself.
>> 
>> Thanks in advance for any suggestions.
>> 
>> -- 
>> Matt Gushee
>> Englewood, CO, USA
>> 
>> _______________________________________________
>> Caml-list mailing list. Subscription management:
>> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
>> Archives: http://caml.inria.fr
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>> 
>
> --
> Martin Jambon, PhD
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

--
Martin Jambon, PhD
Store and share your bioinformatics tips at http://wikiomics.org


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Testing Camlp4-generated code
  2005-11-05 22:33 Testing Camlp4-generated code Matt Gushee
  2005-11-06 22:10 ` [Caml-list] " Martin Jambon
@ 2005-11-07  9:10 ` Hendrik Tews
  1 sibling, 0 replies; 4+ messages in thread
From: Hendrik Tews @ 2005-11-07  9:10 UTC (permalink / raw)
  To: caml-list

Matt Gushee <matt@gushee.net> writes:

   I have developed a tool that generates a module using Camlp4, and I
   would like to be able to test the output. The structure is fairly small
   and simple, so it should be sufficient to verify that a generated module
   is equivalent to a certain hand-coded module ... 

In addition to Martin Jambon's suggestion you can also compare
the internal camlp4 abstract syntax trees of the generated and
the handcoded module:

- use camlp4 with a printer that marshal's the ast into a file
  for both, the generated and the handwritten module
- in a separate program marshal both files back and compare them

You probably want a handwritten equality test in the second step
because of the location info in the ast.

Bye,

Hendrik


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-11-07  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-05 22:33 Testing Camlp4-generated code Matt Gushee
2005-11-06 22:10 ` [Caml-list] " Martin Jambon
2005-11-06 22:16   ` Martin Jambon
2005-11-07  9:10 ` Hendrik Tews

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).