Package com.strobel.expressions

Examples of com.strobel.expressions.Expression


    }

    @Test
    public void testAndOr() throws Throwable {
        final OrCountdown counter = new OrCountdown(2);
        final Expression counterConstant = constant(counter);

        final LambdaExpression<Callable<String>> callback = lambda(
            Types.Callable.makeGenericType(Types.String),
            condition(
                orElse(
View Full Code Here


        runRelationalBranchTest(true, constant(2), constant(3));
        runRelationalBranchTest(true, constant(2L), constant(3L));
        runRelationalBranchTest(true, constant(2f), constant(3f));
        runRelationalBranchTest(true, constant(2d), constant(3d));

        final Expression leftString = constant("two");
        final Expression rightString = constant("three");
        final Expression nullString = constant(null, Types.String);

        runRelationalBranchTest(true, leftString, rightString);
        runRelationalBranchTest(true, leftString, nullString);
    }
View Full Code Here

        runRelationalBranchTest(false, constant(2), constant(3));
        runRelationalBranchTest(false, constant(2L), constant(3L));
        runRelationalBranchTest(false, constant(2f), constant(3f));
        runRelationalBranchTest(false, constant(2d), constant(3d));

        final Expression leftString = constant("two");
        final Expression rightString = constant("three");
        final Expression nullString = constant(null, Types.String);

        runRelationalBranchTest(false, leftString, rightString);
        runRelationalBranchTest(false, leftString, nullString);
    }
View Full Code Here

        final Expression left,
        final Expression right) throws Throwable {

        final OrCountdown counter1 = new OrCountdown(isAnd ? 1 : 2);
        final OrCountdown counter2 = new OrCountdown(isAnd ? 1 : 2);
        final Expression counterConstant1 = constant(counter1);
        final Expression counterConstant2 = constant(counter2);

        final LambdaExpression<Callable<String>> callback = lambda(
            Types.Callable.makeGenericType(Types.String),
            condition(
                makeBinary(
View Full Code Here

        delegate.run();
    }

    @Test
    public void testForEachWithArray() throws Exception {
        final Expression out = field(null, Type.of(System.class).getField("out"));
        final ParameterExpression item = variable(Types.String, "item");

        final ConstantExpression items = constant(
            new String[] { "one", "two", "three", "four", "five" }
        );
View Full Code Here

        delegate.run();
    }

    @Test
    public void testForEachWithIterable() throws Exception {
        final Expression out = field(null, Type.of(System.class).getField("out"));
        final ParameterExpression item = variable(Types.String, "item");

        final ConstantExpression items = constant(
            Arrays.asList("one", "two", "three", "four", "five"),
            Types.Iterable.makeGenericType(Types.String)
View Full Code Here

        delegate.run();
    }

    @Test
    public void testForLoop() throws Exception {
        final Expression out = field(null, Type.of(System.class).getField("out"));
        final ParameterExpression base = variable(PrimitiveTypes.Integer, "base");
        final ParameterExpression power = variable(PrimitiveTypes.Integer, "power");
        final ParameterExpression accumulator = variable(PrimitiveTypes.Integer, "accumulator");
        final ParameterExpression variable = variable(PrimitiveTypes.Integer, "i");
View Full Code Here

        assertEquals("something else", delegate.apply("6"));
    }

    @Test
    public void testTryCatchFinally() throws Exception {
        final Expression out = field(null, Type.of(System.class).getField("out"));
        final ParameterExpression tempException = variable(Types.RuntimeException, "$exception");

        final LambdaExpression<Runnable> lambda = lambda(
            Type.of(Runnable.class),
            block(
View Full Code Here

    }

    @Test
    public void testTryFinally() throws Exception {
        final MutableInteger counter = new MutableInteger(0);
        final Expression counterConstant = constant(counter);
        final ParameterExpression shouldThrow = parameter(PrimitiveTypes.Boolean);

        final LambdaExpression<ShouldThrowDelegate> lambda = lambda(
            Type.of(ShouldThrowDelegate.class),
            tryFinally(
View Full Code Here

        assertEquals(1, counter.getValue());
    }

    @Test
    public void testTryNestedCatchFinally() throws Exception {
        final Expression out = field(null, Type.of(System.class).getField("out"));
        final ParameterExpression tempException = variable(Types.RuntimeException, "$exception");

        final LambdaExpression<Runnable> lambda = lambda(
            Type.of(Runnable.class),
            block(
View Full Code Here

TOP

Related Classes of com.strobel.expressions.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.