예제 #1
0
 @Test(timeout = 10000)
 public void testSqrt() throws ConfigCompileException {
   assertEquals("3", StaticTest.SRun("sqrt(9)", fakePlayer));
   assertEquals(
       "Test failed",
       java.lang.Math.sqrt(2),
       Double.parseDouble(StaticTest.SRun("sqrt(2)", fakePlayer)),
       .000001);
   try {
     StaticTest.SRun("sqrt(-1)", fakePlayer);
     fail("Did not expect to pass");
   } catch (ConfigRuntimeException e) {
     // pass
   }
 }
 @Before
 public void setUp() throws Exception {
   fakeServer = GetFakeServer();
   fakePlayer = GetOnlinePlayer(fakeServer);
   env.getEnv(CommandHelperEnvironment.class).SetPlayer(fakePlayer);
   StaticTest.InstallFakeConvertor(fakePlayer);
   Static.InjectPlayer(fakePlayer);
 }
예제 #3
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");
 }
예제 #4
0
 @Before
 public void setUp() throws Exception {
   fakePlayer = StaticTest.GetOnlinePlayer();
   StaticTest.InstallFakeConvertor(fakePlayer);
   Static.InjectPlayer(fakePlayer);
 }
예제 #5
0
 @Test(timeout = 10000)
 public void testMax() throws ConfigCompileException {
   assertEquals("50", StaticTest.SRun("max(6, 7, array(4, 4, 50), 2, 5)", fakePlayer));
 }
예제 #6
0
 @Test(timeout = 10000)
 public void testMin() throws ConfigCompileException {
   assertEquals("-2", StaticTest.SRun("min(2, array(5, 6, 4), -2)", fakePlayer));
 }