[rules-dev] Smooth operator

Wolfgang Laun wolfgang.laun at gmail.com
Wed Jun 22 11:31:27 EDT 2011


Here it is:

 private void makeFacts(){
    kSession.insert( Integer.valueOf( 1 ) );
    kSession.insert( Long.valueOf( 1 ) );
    kSession.insert( Integer.valueOf( 0x10010 ) );
    kSession.insert( Integer.valueOf( 0x10020 ) );
    kSession.insert( Long.valueOf( 0x10010  ) );
    kSession.insert( Long.valueOf( 0x10020  ) );
    kSession.insert( Integer.valueOf( 0x10000 ) );
    kSession.insert( Long.valueOf( 0x100000000L ) );
    kSession.insert( Long.valueOf( 0x10000L ) );
 }

package shift

############### dialect "mvel"

rule test1
when
   $a: Integer( $one:   intValue == 1 )
   $b: Integer( $shift: intValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test1 " + $a + " << " + $b + " = " +
Integer.toHexString( $c ) );
end

rule test2
when
   $a: Integer( $one:   intValue == 1 )
   $b:  Long   ( $shift: longValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test2 " + $a + " << " + $b + " = " +
Integer.toHexString( $c ) );
end

rule test3
when
   $a: Long   ( $one:   longValue == 1 )
   $b: Long   ( $shift: longValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test3 " + $a + " << " + $b + " = " +
Integer.toHexString( $c ) );
end

rule test4
when
   $a: Long   ( $one:   longValue == 1 )
   $b: Integer( $shift: intValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test4 " + $a + " << " + $b + " = " +
Integer.toHexString( $c ) );
end

##############################

-W



On 22 June 2011 17:26, Michael Anstis <michael.anstis at gmail.com> wrote:

> The current conversation on IRC might benefit form your simplified test
> case?!?
>
> On 22 June 2011 16:24, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
>
>> Given a scant selection of facts taken from java.lang.Integer and
>> java.lang.Long (no value exceeds  and a rule base with just 4 rules using
>> simple constraints using nothing but the fact values, a single operator
>> besides "==", it compiles and executes according to my expectations.
>>
>> Getting high-spirited, I added
>>
>>    dialect "mvel";
>>
>> to my DRL file and re-run everything. Lo and behold! Some rules don't fire
>> any more!
>>
>> Is this to be expected? (There is no difference between 5.1.1 and 5.2.x.)
>>
>> Cheers
>> Wolfgang
>>
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20110622/2cb3b728/attachment.html 


More information about the rules-dev mailing list