0

I have the problem with C4J framework.

So I have class, for example PhysicsUtils

package ua.avereschaka.Utils;

import de.vksi.c4j.ContractReference;
import ua.avereschaka.Contracts.PhysicsUtilsContract;

@ContractReference(PhysicsUtilsContract.class)
public class PhysicsUtils {

public double getMinSpeed(double busSpeed, double distToBus, double distToRoad){
    return (busSpeed * distToRoad) / distToBus;
}

}

And Contract class

package ua.avereschaka.Contracts;

import de.vksi.c4j.Contract;
import de.vksi.c4j.Target;
import ua.avereschaka.Utils.PhysicsUtils;

import static de.vksi.c4j.Condition.*;

@Contract
public class PhysicsUtilsContract extends PhysicsUtils {

@Target
private PhysicsUtils target;

@Override
public double getMinSpeed(double busSpeed, double distToBus, double distToRoad) {
    if (preCondition()) {
        assert busSpeed >= 0;
        assert distToBus >= 0;
        assert distToRoad >= 0;
    }
    if (postCondition()) {
        assert result() != null;
        assert result(Double.class) >= 0;
    }
    return ignored();
}
}

And when I call this method from some place with wrong params(for example, negative busSpeed) no error occurs.

I use Intellij IDEA 15, C4J Framework is added to the classpath by project settings.

Can you tell me where is my problem?

Artem Vereschaka
  • 125
  • 1
  • 1
  • 9

1 Answers1

0

UPD. SOLVED.

In Run/Debug Configurations you need to add next VM options:

-javaagent:<path> -ea

- it is path to c4j framework, and -ea is a key to enable assertions.

Artem Vereschaka
  • 125
  • 1
  • 1
  • 9