##############################################################################
# JBoss, Home of Professional Open Source
# Copyright 2009, Red Hat and individual contributors
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
# @authors Andrew Dinn
#

RULE test arithmetic plus
CLASS TestArithmetic
METHOD triggerMethod1(int,char,short,byte)
HELPER org.jboss.byteman.tests.helpers.Default
AFTER CALL log
BIND test : Test = $0;
     i : int = $1;
     c : char = $2;
     s : short = $3;
     b : byte = $4
IF TRUE
DO test.log("triggerMethod1 : i == " + i);
   test.log("triggerMethod1 : c == '" + c + "'");
   test.log("triggerMethod1 : s == " + s);
   test.log("triggerMethod1 : b == " + b);
   test.log("triggerMethod1 : i + 255 == " + (i + 255));
   test.log("triggerMethod1 : c + 255 == " + (c + 255));
   test.log("triggerMethod1 : s + 255 == " + (s + 255));
   test.log("triggerMethod1 : b + 255 == " + (b + 255));
   return (s + c)
ENDRULE

RULE test arithmetic minus
CLASS TestArithmetic
METHOD triggerMethod2(int,char,short,byte)
HELPER org.jboss.byteman.tests.helpers.Default
AFTER CALL log
BIND test : Test = $0;
     i : int = $1;
     c : char = $2;
     s : short = $3;
     b : byte = $4
IF TRUE
DO test.log("triggerMethod2 : i == " + i);
   test.log("triggerMethod2 : c == '" + c + "'");
   test.log("triggerMethod2 : s == " + s);
   test.log("triggerMethod2 : b == " + b);
   test.log("triggerMethod2 : i - 255 == " + (i - 255));
   test.log("triggerMethod2 : c - 255 == " + (c - 255));
   test.log("triggerMethod2 : s - 255 == " + (s - 255));
   test.log("triggerMethod2 : b - 255 == " + (b - 255));
   return (c + c)
ENDRULE

RULE test arithmetic mod, times and div
CLASS TestArithmetic
METHOD triggerMethod3(int,char,short,byte)
HELPER org.jboss.byteman.tests.helpers.Default
AFTER CALL log
BIND test : Test = $0;
     i : int = $1;
     c : char = $2;
     s : short = $3;
     b : byte = $4
IF TRUE
DO test.log("triggerMethod3 : i == " + i);
   test.log("triggerMethod3 : c == '" + c + "'");
   test.log("triggerMethod3 : s == " + s);
   test.log("triggerMethod3 : b == " + b);
   test.log("triggerMethod3 : 255 % b == " + (255 % b));
   test.log("triggerMethod3 : c / 2 == " + (c / 2));
   test.log("triggerMethod3 : s * 1.5 == " + (s * 1.5));
   test.log("triggerMethod3 : b * b == " + (b * b));
   return (s * b)
ENDRULE

RULE test arithmetic mod, times and div again
CLASS TestArithmetic
METHOD triggerMethod4(int,char,short,byte)
HELPER org.jboss.byteman.tests.helpers.Default
AFTER CALL log
BIND test : Test = $0;
     i : int = $1;
     c : char = $2;
     s : short = $3;
     b : byte = $4
IF TRUE
DO test.log("triggerMethod4 : i == " + i);
   test.log("triggerMethod4 : c == '" + c + "'");
   test.log("triggerMethod4 : s == " + s);
   test.log("triggerMethod4 : b == " + b);
   test.log("triggerMethod4 : 255 * b == " + (255 * b));
   test.log("triggerMethod4 : c / 0.5 == " + (c / 0.5));
   test.log("triggerMethod4 : s * c == " + (s * c));
   test.log("triggerMethod4 : b % 0.5 == " + (b % 0.5));
   return (c * (b + s))
ENDRULE

RULE test shifts
CLASS TestArithmetic
METHOD triggerMethod5(int,short,byte,long,float,double)
HELPER org.jboss.byteman.tests.helpers.Default
AFTER CALL log
BIND test : Test = $0;
     i : int = $1;
     s : short = $2;
     b : byte = $3;
     j : long = $4;
     f : float = $5;
     d : double = $6
IF TRUE
DO test.log("triggerMethod5 : i == " + i);
   test.log("triggerMethod5 : s == " + s);
   test.log("triggerMethod5 : b == " + b);
   test.log("triggerMethod5 : j == " + j);
   test.log("triggerMethod5 : f == " + f);
   test.log("triggerMethod5 : d == " + d);

   test.log("triggerMethod5 : i << 3 == " + (i << 3));
   test.log("triggerMethod5 : s << 3 == " + (s << 3));
   test.log("triggerMethod5 : b << 3 == " + (b << 3));
   test.log("triggerMethod5 : j << 33 == " + (j << 33));
   test.log("triggerMethod5 : f << 33 == " + (f << 33));
   test.log("triggerMethod5 : d << 33 == " + (d << 33));

   test.log("triggerMethod5 : i >> 3 == " + (i >> 3));
   test.log("triggerMethod5 : s >> 3 == " + (s >> 3));
   test.log("triggerMethod5 : b >> 3 == " + (b >> 3));
   test.log("triggerMethod5 : j >> 3 == " + (j >> 3));
   test.log("triggerMethod5 : f >> 3 == " + (f >> 3));
   test.log("triggerMethod5 : d >> 3 == " + (d >> 3));

   test.log("triggerMethod5 : i >>> 3 == " + (i >>> 3));
   test.log("triggerMethod5 : s >>> 3 == " + (s >>> 3));
   test.log("triggerMethod5 : b >>> 3 == " + (b >>> 3));
   test.log("triggerMethod5 : j >>> 3 == " + (j >>> 3));
   test.log("triggerMethod5 : f >>> 3 == " + (f >>> 3));
   test.log("triggerMethod5 : d >>> 3 == " + (d >>> 3));
ENDRULE

RULE test long literals
CLASS TestArithmetic
METHOD triggerMethod6(int,long,float,double)
HELPER org.jboss.byteman.tests.helpers.Default
AFTER CALL log
BIND test : Test = $0;
     l_lit : long = 5000000000L;
     i : int = $1;
     j : long = $2;
     f : float = $3;
     d : double = $4
IF TRUE
DO test.log("triggerMethod6 : l_lit == " + l_lit);
   test.log("triggerMethod6 : i + l_lit == " + (i + l_lit));
   test.log("triggerMethod6 : j + l_lit == " + (j + l_lit));
   test.log("triggerMethod6 : f + l_lit == " + (f + l_lit));
   test.log("triggerMethod6 : d + l_lit == " + (d + l_lit));
   return l_lit;
ENDRULE

RULE test double literals
CLASS TestArithmetic
METHOD triggerMethod7(int,long,float,double)
HELPER org.jboss.byteman.tests.helpers.Default
AFTER CALL log
BIND test : Test = $0;
     d_lit : double = 1.23456E-73D;
     i : int = $1;
     j : long = $2;
     f : float = $3;
     d : double = $4
IF TRUE
DO test.log("triggerMethod7 : d_lit == " + d_lit);
   test.log("triggerMethod7 : i + d_lit == " + (i + d_lit));
   test.log("triggerMethod7 : j + d_lit == " + (j + d_lit));
   test.log("triggerMethod7 : f + d_lit == " + (f + d_lit));
   test.log("triggerMethod7 : d + d_lit == " + (d + d_lit));
   return d_lit;
ENDRULE
