コード例 #1
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #2
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #3
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
  @Before
  public void setUp() {
    fakePlayer = GetOnlinePlayer();
    fakeServer = GetFakeServer();

    varList = new IVariableList();
    varList.set(new IVariable("var", C.onstruct(1), Target.UNKNOWN));
    varList.set(new IVariable("var2", C.onstruct(2.5), Target.UNKNOWN));
    env.SetVarList(varList);
    env.SetPlayer(fakePlayer);
  }
コード例 #4
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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");
 }
コード例 #5
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @Test(timeout = 10000)
 public void testRand() {
   Math.rand a = new Math.rand();
   for (int i = 0; i < 1000; i++) {
     long j = Static.getInt(a.exec(Target.UNKNOWN, env, C.onstruct(10)));
     if (!(j < 10 && j >= 0)) {
       fail("Expected a number between 0 and 10, but got " + j);
     }
     j = Static.getInt(a.exec(Target.UNKNOWN, env, C.onstruct(10), C.onstruct(20)));
     if (!(j < 20 && j >= 10)) {
       fail("Expected a number between 10 and 20, but got " + j);
     }
   }
   try {
     a.exec(Target.UNKNOWN, env, C.onstruct(20), C.onstruct(10));
     fail("Didn't expect this test to pass");
   } catch (ConfigRuntimeException e) {
   }
   try {
     a.exec(Target.UNKNOWN, env, C.onstruct(-1));
     fail("Didn't expect this test to pass");
   } catch (ConfigRuntimeException e) {
   }
   try {
     a.exec(Target.UNKNOWN, env, C.onstruct(87357983597853791L));
     fail("Didn't expect this test to pass");
   } catch (ConfigRuntimeException e) {
   }
 }
コード例 #6
0
ファイル: EchoesTest.java プロジェクト: Thezomg/commandhelper
 @Test(timeout = 10000)
 public void testBroadcast()
     throws NoSuchFieldException, InstantiationException, IllegalAccessException,
         NoSuchMethodException, IllegalArgumentException, InvocationTargetException,
         CancelCommandException {
   Echoes.broadcast a = new Echoes.broadcast();
   when(fakePlayer.getServer()).thenReturn(fakeServer);
   CommandHelperPlugin.myServer = fakeServer;
   a.exec(Target.UNKNOWN, env, C.onstruct("Hello World!"));
   verify(fakeServer).broadcastMessage("Hello World!");
 }
コード例 #7
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #8
0
ファイル: EchoesTest.java プロジェクト: Thezomg/commandhelper
 @Test(timeout = 10000)
 public void testChat() throws CancelCommandException {
   Echoes.chat a = new Echoes.chat();
   a.exec(Target.UNKNOWN, env, C.onstruct("Hello World!"));
   verify(fakePlayer).chat("Hello World!");
 }
コード例 #9
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #10
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #11
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #12
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #13
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }
コード例 #14
0
ファイル: MathTest.java プロジェクト: Thezomg/commandhelper
 @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)));
 }