import junit.framework.*; ruleset r { char c1 = 'c'; char c2 = 'k'; byte b1 = (byte)12; byte b2 = (byte)45; short s1 = (short)2; short s2 = (short)21; long l1 = -12l; long l2 = -2l; boolean _2foundasObject=false; boolean _222notfoundasObject=false; boolean NOT2foundasObject=false; boolean NOT222notfoundasObject=false; boolean truefound=false; boolean falsenotfound=false; boolean NOTtruefound=false; boolean NOTfalsenotfound=false; boolean cfound=false; boolean dnotfound=false; boolean NOTcfound=false; boolean NOTdnotfound=false; boolean _12foundasbyte=false; boolean _46notfoundasbyte=false; boolean NOT12foundasbyte=false; boolean NOT46notfoundasbyte=false; boolean _2foundasshort=false; boolean _12notfoundasshort=false; boolean NOT2foundasshort=false; boolean NOT12notfoundasshort=false; boolean _2foundasint=false; boolean _222notfoundasint=false; boolean NOT2foundasint=false; boolean NOT222notfoundasint=false; boolean _2foundaslong=false; boolean _34notfoundaslong=false; boolean NOT2foundaslong=false; boolean NOT34notfoundaslong=false; boolean _2foundasfloat=false; boolean _3foundasfloat=false; boolean NOT2foundasfloat=false; boolean NOT3foundasfloat=false; boolean _2foundasdouble=false; boolean _3foundasdouble=false; boolean NOT2foundasdouble=false; boolean NOT3foundasdouble=false; } rule r1 { when { ?i: Integer(); evaluate(?i in { new Integer(1), new Integer(2)} ); } then { if (?i.intValue() == 2) _2foundasObject = true; } else { if (?i.intValue() == 222) _222notfoundasObject = true; } } rule r1_not { when { ?i: Integer(); evaluate(?i !in { new Integer(1), new Integer(2)} ); } then { if (?i.intValue() == 222) NOT222notfoundasObject = true; } else { if (?i.intValue() == 2) NOT2foundasObject = true; } } rule r2 { when { ?b: Boolean(); evaluate(?b.booleanValue() in { true } ); } then { if (?b.booleanValue() == true) truefound = true; } else { if (?b.booleanValue() == false) falsenotfound = true; } } rule r2_not { when { ?b: Boolean(); evaluate(?b.booleanValue() !in { true } ); } then { if (?b.booleanValue() == false) NOTfalsenotfound = true; } else { if (?b.booleanValue() == true) NOTtruefound = true; } } rule r3 { when { ?c: Character(); evaluate(?c.charValue() in { c1, c2 } ); } then { if (?c.charValue() == 'c') cfound = true; } else { if (?c.charValue() == 'd') dnotfound = true; } } rule r3_not { when { ?c: Character(); evaluate(?c.charValue() !in { c1, c2 } ); } then { if (?c.charValue() == 'd') NOTdnotfound = true; } else { if (?c.charValue() == 'c') NOTcfound = true; } } rule r4 { when { ?b: Byte(); evaluate(?b.byteValue() in { b1, b2 } ); } then { if (?b.byteValue() == b1) _12foundasbyte = true; } else { if (?b.byteValue() == (byte)46) _46notfoundasbyte = true; } } rule r4_not { when { ?b: Byte(); evaluate(?b.byteValue() !in { b1, b2 } ); } then { if (?b.byteValue() == (byte)46) NOT46notfoundasbyte = true; } else { if (?b.byteValue() == b1) NOT12foundasbyte = true; } } rule r5 { when { ?s: Short(); evaluate(?s.shortValue() in { s1, s2 } ); } then { if (?s.shortValue() == 2) _2foundasshort = true; } else { if (?s.shortValue() == 12) _12notfoundasshort = true; } } rule r5_not { when { ?s: Short(); evaluate(?s.shortValue() !in { s1, s2 } ); } then { if (?s.shortValue() == 12) NOT12notfoundasshort = true; } else { if (?s.shortValue() == 2) NOT2foundasshort = true; } } rule r6 { when { ?i: Integer(); evaluate(?i.intValue() in { -12, 2 } ); } then { if (?i.intValue() == 2) _2foundasint = true; } else { if (?i.intValue() == 222) _222notfoundasint = true; } } rule r6_not { when { ?i: Integer(); evaluate(?i.intValue() !in { -12, 2 } ); } then { if (?i.intValue() == 222) NOT222notfoundasint = true; } else { if (?i.intValue() == 2) NOT2foundasint = true; } } rule r7 { when { ?l: Long(); evaluate(?l.longValue() in { -12l, 2l } ); } then { if (?l.longValue() == 2l) _2foundaslong = true; } else { if (?l.longValue() == 34l) _34notfoundaslong = true; } } rule r7_not { when { ?l: Long(); evaluate(?l.longValue() !in { -12l, 2l } ); } then { if (?l.longValue() == 34l) NOT34notfoundaslong = true; } else { if (?l.longValue() == 2l) NOT2foundaslong = true; } } rule r8 { when { ?f: Float(); evaluate(?f.floatValue() in { 3f, -4f, 2f } ); } then { if (?f.floatValue() == 3f) _3foundasfloat = true; if (?f.floatValue() == 2f) _2foundasfloat = true; } } rule r8_not { when { ?f: Float(); evaluate(?f.floatValue() !in { 3f, -4f, 2f } ); } then { } else { if (?f.floatValue() == 2f) NOT2foundasfloat= true; if (?f.floatValue() == 3f) NOT3foundasfloat = true; } } rule r9 { when { ?d: Double(); evaluate(?d.doubleValue() in { 3d, -5d, 2d } ); } then { if (?d.doubleValue() == 3d) _3foundasdouble = true; if (?d.doubleValue() == 2d) _2foundasdouble = true; } } rule r9_not { when { ?d: Double(); evaluate(?d.doubleValue() !in { 3d, -5d, 2d } ); } then { } else { if (?d.doubleValue() == 3d) NOT3foundasdouble = true; if (?d.doubleValue() == 2d) NOT2foundasdouble = true; } } function void checkResult() { Assert.assertTrue("Error: 2 as Integer not found in { Integer(1), Integer(2)}", _2foundasObject); Assert.assertTrue("Error: 222 as Integer found in { Integer(1), Integer(2) }", _222notfoundasObject); Assert.assertTrue("Error: 2 as Integer NOT found in { Integer(1), Integer(2)}", NOT2foundasObject); Assert.assertTrue("Error: 222 as Integer found in { Integer(1), Integer(2) }", NOT222notfoundasObject); Assert.assertTrue("Error: true not found in { true }", truefound); Assert.assertTrue("Error: false found in { true }", falsenotfound); Assert.assertTrue("Error: true NOT found in { true }", NOTtruefound); Assert.assertTrue("Error: false found in { true }", NOTfalsenotfound); Assert.assertTrue("Error: c not found in { c, k }", cfound); Assert.assertTrue("Error: d found in { c, k }", dnotfound); Assert.assertTrue("Error: c NOT found in { c, k }", NOTcfound); Assert.assertTrue("Error: d found in { c, k }", NOTdnotfound); Assert.assertTrue("Error: 12 not found as byte in { (byte)12, (byte)45 }", _12foundasbyte); Assert.assertTrue("Error: 46 found as byte in { (byte)12, (byte)45 }", _46notfoundasbyte); Assert.assertTrue("Error: 12 NOT found as byte in { (byte)12, (byte)45 }", NOT12foundasbyte); Assert.assertTrue("Error: 46 found as byte in { (byte)12, (byte)45 }", NOT46notfoundasbyte); Assert.assertTrue("Error: 2 not found as short in { (short)2, (short)21 }", _2foundasshort); Assert.assertTrue("Error: 12 found as short in { (short)2, (short)21 }", _12notfoundasshort); Assert.assertTrue("Error: 2 NOT found as short in { (short)2, (short)21 }", NOT2foundasshort); Assert.assertTrue("Error: 12 found as short in { (short)2, (short)21 }", NOT12notfoundasshort); Assert.assertTrue("Error: 2 not found as int in { -12, 2 }", _2foundasint); Assert.assertTrue("Error: 222 found as int in { -12, 2 }", _222notfoundasint); Assert.assertTrue("Error: 2 NOT found as int in { -12, 2 }", NOT2foundasint); Assert.assertTrue("Error: 222 found as int in { -12, 2 }", NOT222notfoundasint); Assert.assertTrue("Error: 2 not found as long in { -12l, 2l }", _2foundaslong); Assert.assertTrue("Error:34 found as long in { -12l, 2l }", _34notfoundaslong); Assert.assertTrue("Error: 2 NOT found as long in { -12l, 2l }", NOT2foundaslong); Assert.assertTrue("Error:34 found as long in { -12l, 2l }", NOT34notfoundaslong); Assert.assertTrue("Error: 2 not found as float in { 3f, -4f, 2f }", _2foundasfloat); Assert.assertTrue("Error:3 not found as float in { 3f, -4f, 2f }", _3foundasfloat); Assert.assertTrue("Error: 2 NOT found as float in { 3f, -4f, 2f }", NOT2foundasfloat); Assert.assertTrue("Error:3 NOT found as float in { 3f, -4f, 2f }", NOT3foundasfloat); Assert.assertTrue("Error: 2 not found as float in { 3d, -5d, 2d }", _2foundasdouble); Assert.assertTrue("Error:3 not found as float in { 3d, -5d, 2d }", _3foundasdouble); Assert.assertTrue("Error: 2 NOT found as float in { 3d, -5d, 2d }", NOT2foundasdouble); Assert.assertTrue("Error:3 NOT found as float in { 3d, -5d, 2d }", NOT3foundasdouble); } function void ilrmain(Object o) { assert(new Integer(2)); assert(new Integer(222)); assert(new Boolean(true)); assert(new Boolean(false)); assert(new Character('c')); assert(new Character('d')); assert(new Byte(b1)); bind b3 = (byte)46; assert(new Byte(b1)); assert(new Byte(b3)); assert(new Short((short)12)); assert(new Short((short)2)); assert(new Long(34l)); assert(new Long(2l)); assert(new Float(3f)); assert(new Float(2f)); assert(new Double(3d)); assert(new Double(2d)); fireAllRules(); checkResult(); }