import junit.framework.*;

ruleset r
{
  float f;
  inout boolean b;
  out String s;
  out Byte by = new Byte((byte)2);
  int t = 2;
  double d;
}

rule r1
{
  when {
    Integer();
  }
  then {
    //    out.println("1.t = " + t);
    t++;
    //    out.println("2.t = " + t);
    t = 44;
    //    out.println("3.t = " + t);
  }
}

rule r2
{
  when {
    Integer();
  }
  then {
    s = "before";
    t--;
    t += 4;
  }
}

ruletask main
{
  initialaction {
    //    System.out.println("main");
    assert(new Integer(2));
  }
  body {
    r1,
      r2
  }
  algorithm = sequential;
  ordering = sorted;
  finalaction {
    retractAll();
    b = true;
    s += " end";
    by = new Byte((byte)4);
  }
}

function void ilrmain(Object o)
{
  bind map = execute();
  bind v0 = map.getBooleanValue("b");
  bind v1 = map.getStringValue("s");
  bind v2 = (Byte)map.getObjectValue("by");
  Assert.assertEquals("Wrong value for b", true, b);
  Assert.assertEquals("Wrong value for s", "before end", s);
  Assert.assertEquals("Wrong value for by", (byte)4, by.byteValue());  

  Assert.assertEquals("Wrong value for t", 47, t);  
}
