Alloy Community

User login

testers using alloy

 
Posted on: Tue, 10/28/2008 - 09:47
Joined: 2008-01-25
Points: 1874
User is offline
testers using alloy
Hello-

I have been experimenting with alloy, preparing to recommend it to
testing professionals as an everyday tool ("Cheap and effective formal
model-based testing"). The several reference papers on the subject of
automated testing are a bit too cryptic for everyday tester consumption
(my opinion, of course). And most of the papers take the easy way out
and fall back to a Java-only universe. Nice stuff, but what about
testing non-Java applications?

The alloy forum's "API Questions" section has been very helpful in
illustrating the mechanics of getting nicely formatted text out of an
alloy model. [That's the tester's goal--get test cases from whatever
resources are available.]  There was a nice exchange recently regarding
a class "EssaiAlloy". As an exercise, I copied it and got it working in
a win32 environment. There are some syntax and pathing issues with java
in windows; maybe my command lines will help someone.

This runs fine, giving text output, writing xml file and bringing up viz screen
   "\Program Files\Java\jdk1.6.0_10\bin\java" -cp \bin\alloy\alloy4.jar edu.mit.csail.sdg.alloy4whole.ExampleUsingTheCompiler  a.als

This compiles fine, giving EssaiAlloy.class and EssaiAlloy$1.class
   "\Program Files\Java\jdk1.6.0_10\bin\javac"  -cp \bin\alloy\alloy4.jar  EssaiAlloy.java

This runs fine, writing xml file and bringing up viz screen. Note, a.als param is superfluous.
   "\Program Files\Java\jdk1.6.0_10\bin\java" -cp \bin\alloy\alloy4.jar;\bin\alloy  EssaiAlloy  a.als

[a.als is a simpleminded model that enumerates colors. EssaiAlloy.java
is a clone from the forum. java is Sun's latest for win32. alloy4.jar is the latest.]

---------------------------------

I see that the existing "write file per found solution" examples are
xml-specific. But, what if I want to output, say, a double-quoted
string, or an integer, or a monetary amount? Is it just some java i/o
statement I need, to substitute for the function of ans.writeXML? [I am
weak in Java, my work has been done in C-ish languages, plus various
shell scripts and prolog]

A clever alloy modeling approach I saw recently was actually pretty
simple: if you want text, model the keywords of your language directly
in alloy sigs (plus a grammar for variable value generation, I am
presuming). That is the rationale of the alloy2sql module from the ADUSA
project. Is there any part of alloy2sql that is publicly available? [The
paper gives only hints at implementation].

Hope the specific windows command lines can help someone, and I'd
appreciate any advice on my text output questions.

Regards,
Jim Hanlon
 
Posted on: Tue, 10/28/2008 - 09:52    #1
Joined: 2008-05-15
Points: 334
User is offline
Hi, Jim:

> I see that the existing "write file per found solution" examples are
> xml-specific. But, what if I want to output, say, a double-quoted
> string, or an integer, or a monetary amount?

Yes, your tool can do more specific evaluations also.

The Essai example, as I recall, invokes the alloy compiler's
parseEverything() method to get a pointer to the root of the AST.
He then iterated over each Command defined in the AST,
and for each Command he invokes the executeCommand() method.
If a Command is successful, you'll get an A4Solution object back.
He then simply calls writeXML() on each A4Solution object he gets.

Instead of that, once you get an A4Solution, you can simply evaluate
any part of the AST you wish.  For example, suppose your model looks like

abstract sig Person { grades: Int }
one sig Alex, Bob, Cathy extends Person { }
fact { .... }

If you get an A4Solution object back, you can first of all
retrieve the list of Sig from the AST, and you'll see there are Sig
objects named "univ", "Int", "Person", "Alex", "Bob"...
You can go to the Person sig and retrieve its list of fields.
You'll see it has only one field.
Given sol is the A4Solution, a is Alex object, and g is the grades field,
you can call "sol.eval(a.join(g))" to evaluate the result of Alex.grades
The answer will be an Int atom, which you can convert to an integer
and you can then show that to your user.

> A clever alloy modeling approach I saw recently was actually pretty
> simple: if you want text, model the keywords of your language directly
> in alloy sigs (plus a grammar for variable value generation, I am
> presuming). That is the rationale of the alloy2sql module from the ADUSA
> project. Is there any part of alloy2sql that is publicly available? [The
> paper gives only hints at implementation].

You'll have to ask the authors of that project whether they could make the code available.

> Hope the specific windows command lines can help someone,
> and I'd appreciate any advice on my text output questions.

It sounds like a very interesting project.  Please let us know how else we can help.

Sincerely,
Felix Chang
Alloy4 Lead Developer

Syndicate content  

The development of this site is supported by the National Science Foundation under Computing Research Infrastructure Grant No. 0707612.

Theme originally designed by Chris Herberte