<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    If you just need an example for generating and shrinking arbitrary
    ASTs, you can have a look here:
    <a class="moz-txt-link-freetext" href="https://github.com/jswebtools/language-ecmascript/blob/master/src/Language/ECMAScript3/Syntax/Arbitrary.hs">https://github.com/jswebtools/language-ecmascript/blob/master/src/Language/ECMAScript3/Syntax/Arbitrary.hs</a>
    . Note that I use the testing-feat package to generate Gen instances
    --- it tends to do better (explore interesting cases earlier) than
    handwritten code --- and then fix-up incorrect ASTs (another option
    is to simply discard them).<br>
    <br>
    <div class="moz-cite-prefix">On 02/16/2015 12:33 PM, Maurizio Vitale
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAAeLbQJ4OUp=7VYDKTw0MjN33BkS+6QJeZwGV51A_kxubijPxQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">By 'test size reduction' I mean the 'shrink'
        function. It seems to me (as I said, first Haskell program and
        no experience with quickcheck) that it works nicely with a
        topdown generation of the test, but I don't see how to easily
        generate correct programs that way.
        <div><br>
        </div>
        <div>Even if you cannot release your tests, maybe you can help
          me with a very simple case. Consider a trivial AST. A program
          is a possibly nested block. Each block is a bunch of
          declarations of variables and some use of them</div>
        <div><br>
        </div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div>
            <div>data Block = Block [Declaration] [Statement]</div>
          </div>
          <div>
            <div><br>
            </div>
          </div>
          <div>
            <div>data Declaration = Var String String</div>
          </div>
          <div>
            <div><br>
            </div>
          </div>
          <div>
            <div>data Statement = Statement Block | Use String</div>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>How one would generate things like:</div>
        <div><br>
        </div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div>Block [Var "a" "int"] [Use "a"] -- here a is declared in
            the same block</div>
          <div><br>
          </div>
          <div>Block [] [Statement Block [Var "s" "int"] [Statement
            Block [] [Use "s"]]] -- here s is declared in some other
            visible scope</div>
        </blockquote>
        <div><br>
        </div>
        <div>etc.</div>
        <div><br>
        </div>
        <div>Or am I trying to approach the problem from the wrong
          angle?</div>
        <div><br>
        </div>
        <div> </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Feb 16, 2015 at 12:02 PM,
          Andrey Chudnov <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:achudnov@gmail.com" target="_blank">achudnov@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> I use QuichCheck for
              compiler testing where I generate random, but well-formed
              programs and check some high-level syntactic properties on
              results. The QuickCheck instance is open-source (see
              language-ecmascript), but the compiler-test code is
              closed-source at this time. Still, I found that it's not
              the ultimate answer: many properties are hard to
              formalize, so I have to resort to unit tests. I'm not sure
              what you mean by "how this would play with test size
              reduction". I think it's worth giving a try, but keep in
              mind that you might still need to use unit tests.<br>
              <br>
              Let me know if you have any questions.<br>
              <br>
              /Andrey
              <div>
                <div class="h5"><br>
                  <br>
                  <div>On 02/16/2015 11:53 AM, Maurizio Vitale wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">I'm starting to work on my first real
                      haskell program (I've only RWH exercises under my
                      belt) and wondering whether people use quickcheck
                      at all for compiler testing.
                      <div><br>
                      </div>
                      <div>I've seen uses of quickcheck for testing
                        parsers, but I'm interested in generating
                        well-formed programs (e.g. random programs with
                        all declarations in reasonable random places).
                        This could be used to test passes other than
                        parsing (or even parsing, for languages that
                        needs to distinguish identifiers, like the
                        'typedef' problem in C/C++).</div>
                      <div><br>
                      </div>
                      <div>The only thing I can think of, is to use
                        quickcheck for randomly generating statements,
                        go over them and figure out free variables
                        (incl. functions) and generate declarations in
                        random places for them. But I'm not sure how
                        this would play with test size reduction and
                        doesn't look like a nice solution anyhow.</div>
                      <div><br>
                      </div>
                      <div>Any idea or pointers to examples? or should I
                        give up on quickcheck for this and just do
                        direct testing?</div>
                      <div><br>
                      </div>
                      <div>Thanks,</div>
                      <div><br>
                      </div>
                      <div>  Maurizio</div>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                  </div>
                </div>
                <pre>_______________________________________________
Haskell-Cafe mailing list
<a moz-do-not-send="true" href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a>
<a moz-do-not-send="true" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
</pre>
              </blockquote>
              <br>
            </div>
            <br>
            _______________________________________________<br>
            Haskell-Cafe mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
            <a moz-do-not-send="true"
              href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
              target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>