Configuration

The syntax for the configuration section is:

config {
  VARS*

  PHASE CONTEXT { CODE } *
}

The PHASE is either setup or test. CONTEXT is optional, and defaults to “”. For example:

config {
    File billing;
    Compiler compiler;
    File output;
    Unknown alice;

    setup {
        billing = new File();
        compiler = new Compiler(billing);
        output = new File();
        alice = new Unknown(compiler, output);
    }

    test {
        alice.test();
    }
}

Internally, SAM creates a class called _TestDriver based on the config section and creates an instance of it called _testDriver.

SAM first makes a copy of the current state, sets the phase to setup in the copy and runs all the setup blocks. Any objects generated by this run are added to the main state. Then the phase is set to test and all the test blocks are run.

This split allows you to see just those calls that resulting from the test phase, without seeing all the constructor calls executed during the setup.

Predicates

These predicates are used to describe the initial configuration of the system being modelled:

initialObject(Ref object, String type)

There is an object named Object which isA() Type.

initialInvocation(Ref object, String methodName, String invocation)

The method named MethodName on Object is initially active (does not need to be invoked by something else before it can take actions). The initial actions should be grouped under the named invocation context. By default, any invocations of other objects called from this one will be grouped using the same context name.

initialInvocation(Ref object, String invocation)

Similar to the three argument form, but marks all methods as active.

phase(String phase)

phase(“Setup”) will be a fact during the setup phase, and phase(“Test”) during the testing phase.

You can also use field() to define the initial references held by an object.

Table Of Contents

Previous topic

Datalog

Next topic

Base predicates