Search in sources :

Example 1 with Int_Int

use of suite.primitive.Int_Int in project suite by stupidsing.

the class FunCreatorTest method testIndex.

@Test
public void testIndex() {
    int[] ints = { 0, 1, 4, 9, 16 };
    Int_Int fun = LambdaInstance.of(Int_Int.class, i -> f.object(ints).index(i)).newFun();
    assertEquals(9, fun.apply(3));
    assertEquals(16, fun.apply(4));
}
Also used : Reference(suite.node.Reference) Suite(suite.Suite) Flt_Flt(suite.primitive.Flt_Flt) Dump(suite.inspect.Dump) PrintlnFunExpr(suite.jdk.gen.FunExprM.PrintlnFunExpr) Source(suite.util.FunUtil.Source) Assert.assertTrue(org.junit.Assert.assertTrue) TermOp(suite.node.io.TermOp) Test(org.junit.Test) Fun(suite.util.FunUtil.Fun) ProfileFunExpr(suite.jdk.gen.FunExprM.ProfileFunExpr) Tree(suite.node.Tree) Node(suite.node.Node) IntSource(suite.primitive.IntPrimitives.IntSource) Iterate(suite.util.FunUtil.Iterate) BiPredicate(java.util.function.BiPredicate) LambdaInstance(suite.jdk.lambda.LambdaInstance) Map(java.util.Map) Type(org.apache.bcel.generic.Type) FunExpr(suite.jdk.gen.FunExpression.FunExpr) Int(suite.node.Int) LambdaInterface(suite.jdk.lambda.LambdaInterface) Int_Int(suite.primitive.Int_Int) Assert.assertEquals(org.junit.Assert.assertEquals) Int_Int(suite.primitive.Int_Int) Test(org.junit.Test)

Example 2 with Int_Int

use of suite.primitive.Int_Int in project suite by stupidsing.

the class FunCreatorTest method testApply0.

@Test
public void testApply0() {
    String fieldName0 = "f0";
    String fieldName1 = "f1";
    FunCreator<Int_Int> fc0 = intFun(fieldName0, Type.INT);
    FunCreator<Int_Int> fc1 = intFun(fieldName1, Type.getType(Int_Int.class));
    Int_Int f0 = // 
    fc0.create(// 
    (i -> f.add(fc0.field(fieldName0), i))).apply(Map.of(fieldName0, 1));
    Int_Int f1 = // 
    fc1.create(// 
    i -> fc1.field(fieldName1).apply(f.int_(3))).apply(Map.of(fieldName1, f0));
    assertEquals(4, f1.apply(5));
}
Also used : Reference(suite.node.Reference) Suite(suite.Suite) Flt_Flt(suite.primitive.Flt_Flt) Dump(suite.inspect.Dump) PrintlnFunExpr(suite.jdk.gen.FunExprM.PrintlnFunExpr) Source(suite.util.FunUtil.Source) Assert.assertTrue(org.junit.Assert.assertTrue) TermOp(suite.node.io.TermOp) Test(org.junit.Test) Fun(suite.util.FunUtil.Fun) ProfileFunExpr(suite.jdk.gen.FunExprM.ProfileFunExpr) Tree(suite.node.Tree) Node(suite.node.Node) IntSource(suite.primitive.IntPrimitives.IntSource) Iterate(suite.util.FunUtil.Iterate) BiPredicate(java.util.function.BiPredicate) LambdaInstance(suite.jdk.lambda.LambdaInstance) Map(java.util.Map) Type(org.apache.bcel.generic.Type) FunExpr(suite.jdk.gen.FunExpression.FunExpr) Int(suite.node.Int) LambdaInterface(suite.jdk.lambda.LambdaInterface) Int_Int(suite.primitive.Int_Int) Assert.assertEquals(org.junit.Assert.assertEquals) Int_Int(suite.primitive.Int_Int) Test(org.junit.Test)

Aggregations

Map (java.util.Map)2 BiPredicate (java.util.function.BiPredicate)2 Type (org.apache.bcel.generic.Type)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Test (org.junit.Test)2 Suite (suite.Suite)2 Dump (suite.inspect.Dump)2 PrintlnFunExpr (suite.jdk.gen.FunExprM.PrintlnFunExpr)2 ProfileFunExpr (suite.jdk.gen.FunExprM.ProfileFunExpr)2 FunExpr (suite.jdk.gen.FunExpression.FunExpr)2 LambdaInstance (suite.jdk.lambda.LambdaInstance)2 LambdaInterface (suite.jdk.lambda.LambdaInterface)2 Int (suite.node.Int)2 Node (suite.node.Node)2 Reference (suite.node.Reference)2 Tree (suite.node.Tree)2 TermOp (suite.node.io.TermOp)2 Flt_Flt (suite.primitive.Flt_Flt)2 IntSource (suite.primitive.IntPrimitives.IntSource)2