Esempio n. 1
0
  /** Tests {@link OpService#run(Op, Object...)}. */
  @Test
  public void testRunByOp() {
    final DoubleType value = new DoubleType(123.456);

    assertFalse(Double.isInfinite(value.get()));
    final Object result = ops.run(new InfinityOp(), value);
    assertSame(value, result);
    assertTrue(Double.isInfinite(value.get()));
  }
Esempio n. 2
0
  /** Tests {@link OpService#op(String, Object...)}. */
  @Test
  public void testOpByName() {
    final DoubleType value = new DoubleType(123.456);

    final Op op = ops.op("test.infinity", value);
    assertSame(InfinityOp.class, op.getClass());

    assertFalse(Double.isInfinite(value.get()));
    op.run();
    assertTrue(Double.isInfinite(value.get()));
  }
Esempio n. 3
0
  /** Tests {@link OpService#module(Class, Object...)}. */
  @Test
  public void testModuleByType() {
    final DoubleType value = new DoubleType(123.456);

    final Module module = ops.module(InfinityOp.class, value);
    assertSame(value, module.getInput("arg"));

    assertFalse(Double.isInfinite(value.get()));
    module.run();
    assertTrue(Double.isInfinite(value.get()));
  }
Esempio n. 4
0
  /** Tests {@link OpService#run(String, Object...)}. */
  @Test
  public void testAliases() {
    final DoubleType value = new DoubleType(123.456);

    assertFalse(Double.isInfinite(value.get()));
    final Object result = ops.run("infin", value);
    assertSame(value, result);
    assertTrue(Double.isInfinite(value.get()));

    value.set(0.0);
    assertFalse(Double.isInfinite(value.get()));
    final Object result2 = ops.run("inf", value);
    assertSame(value, result2);
    assertTrue(Double.isInfinite(value.get()));

    value.set(0.0);
    boolean noSuchAlias = false;
    try {
      ops.run("infini", value);
    } catch (final IllegalArgumentException exc) {
      noSuchAlias = true;
    }
    assertTrue(noSuchAlias);
  }