English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Testing Camlp4-generated code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-07 (09:10)
From: Hendrik Tews <tews@t...>
Subject: Re: [Caml-list] Testing Camlp4-generated code
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.