Esempio n. 1
0
 @Test(timeout = 10000)
 public void testPow() {
   Math.pow a = new Math.pow();
   assertCEquals(C.onstruct(25), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2)));
   assertCEquals(C.onstruct(27), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3)));
   assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(-1), C.onstruct(-2)));
 }
Esempio n. 2
0
 @Test(timeout = 10000)
 public void testAbs() {
   Math.abs a = new Math.abs();
   assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, env, C.onstruct(5)));
   assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(-3)));
   assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, C.onstruct(0)));
 }
Esempio n. 3
0
 @Test(timeout = 10000)
 public void testMod() {
   Math.mod a = new Math.mod();
   assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2)));
   assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3)));
   assertCEquals(C.onstruct(-1), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-2)));
 }
Esempio n. 4
0
 @Test(timeout = 10000)
 public void testMultiply() {
   Math.multiply a = new Math.multiply();
   assertCEquals(C.onstruct(10), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2)));
   assertCEquals(C.onstruct(9), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3)));
   assertCEquals(C.onstruct(6), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-2)));
   assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, env, C.onstruct(10), C.onstruct(0.5)));
 }
Esempio n. 5
0
 @Test(timeout = 10000)
 public void testSubtract() {
   Math.subtract a = new Math.subtract();
   assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2)));
   assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3)));
   assertCEquals(C.onstruct(-1), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-2)));
   assertCEquals(
       C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(3.1415), C.onstruct(0.1415)));
 }
Esempio n. 6
0
 @Test(timeout = 10000)
 public void testDivide() {
   Math.divide a = new Math.divide();
   assertCEquals(C.onstruct(2.5), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2)));
   assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3)));
   assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-1)));
   assertCEquals(
       C.onstruct(Double.POSITIVE_INFINITY),
       a.exec(Target.UNKNOWN, env, C.onstruct(1), C.onstruct(0)));
 }
Esempio n. 7
0
 @Test(timeout = 10000)
 public void testAdd() {
   Math.add a = new Math.add();
   assertCEquals(C.onstruct(7), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2)));
   assertCEquals(C.onstruct(6), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3)));
   assertCEquals(C.onstruct(-4), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-1)));
   assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(1), C.onstruct(0)));
   assertCEquals(
       C.onstruct(3.1415), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(0.1415)));
 }
Esempio n. 8
0
 @Test(timeout = 10000)
 public void testInc() throws ConfigCompileException {
   Math.inc a = new Math.inc();
   IVariable v =
       (IVariable)
           a.exec(Target.UNKNOWN, env, new IVariable("var", C.onstruct(1), Target.UNKNOWN));
   IVariable v2 =
       (IVariable)
           a.exec(Target.UNKNOWN, env, new IVariable("var2", C.onstruct(2.5), Target.UNKNOWN));
   assertCEquals(C.onstruct(2), v.ival());
   assertCEquals(C.onstruct(3.5), v2.ival());
   StaticTest.SRun("assign(@var, 0) inc(@var, 2) msg(@var)", fakePlayer);
   verify(fakePlayer).sendMessage("2");
 }
Esempio n. 9
0
 @Test(timeout = 10000)
 public void testCeil() {
   Math.ceil a = new Math.ceil();
   assertCEquals(C.onstruct(4), a.exec(Target.UNKNOWN, env, C.onstruct(3.1415)));
   assertCEquals(C.onstruct(-3), a.exec(Target.UNKNOWN, env, C.onstruct(-3.1415)));
 }
Esempio n. 10
0
 @Test(timeout = 10000)
 public void testFloor() {
   Math.floor a = new Math.floor();
   assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(3.8415)));
   assertCEquals(C.onstruct(-4), a.exec(Target.UNKNOWN, env, C.onstruct(-3.1415)));
 }