Search in sources :

Example 1 with Int_Int

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

the class BinarySearchTest method testDesc.

private void testDesc(int l) {
    Int_Int f = i -> l + 1 - i;
    var is = NewInt.array(l, f);
    assertEquals(l - 1, searchDesc(is, Integer.MIN_VALUE));
    assertEquals(-1, searchDesc(is, Integer.MAX_VALUE));
    for (var i = 0; i < l; i++) assertEquals(i, searchDesc(is, f.apply(i)));
}
Also used : Test(org.junit.jupiter.api.Test) Int_Int(primal.primitive.Int_Int) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NewInt(primal.primitive.IntVerbs.NewInt) Int_Int(primal.primitive.Int_Int)

Example 2 with Int_Int

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

the class FunCreatorTest method testObject.

@Test
public void testObject() {
    Int_Int inc = i -> i + 1;
    Iterate<FunExpr> fun = i -> f.object(inc).invoke("apply", i);
    assertEquals(3, LambdaInstance.of(Int_Int.class, fun).newFun().apply(2));
}
Also used : Reference(suite.node.Reference) Suite(suite.Suite) BaseOp(suite.node.io.BaseOp) Dump(suite.inspect.Dump) PrintlnFunExpr(suite.jdk.gen.FunExprM.PrintlnFunExpr) Fun(primal.fp.Funs.Fun) Source(primal.fp.Funs.Source) IntSource(primal.primitive.IntPrim.IntSource) Iterate(primal.fp.Funs.Iterate) ProfileFunExpr(suite.jdk.gen.FunExprM.ProfileFunExpr) Tree(suite.node.Tree) Node(suite.node.Node) Test(org.junit.jupiter.api.Test) BiPredicate(java.util.function.BiPredicate) LambdaInstance(suite.jdk.lambda.LambdaInstance) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) Type(org.apache.bcel.generic.Type) Int_Int(primal.primitive.Int_Int) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FunExpr(suite.jdk.gen.FunExpression.FunExpr) Int(suite.node.Int) Flt_Flt(primal.primitive.Flt_Flt) LambdaInterface(suite.jdk.lambda.LambdaInterface) Int_Int(primal.primitive.Int_Int) PrintlnFunExpr(suite.jdk.gen.FunExprM.PrintlnFunExpr) ProfileFunExpr(suite.jdk.gen.FunExprM.ProfileFunExpr) FunExpr(suite.jdk.gen.FunExpression.FunExpr) Test(org.junit.jupiter.api.Test)

Example 3 with Int_Int

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

the class BinarySearchTest method testAsc.

private void testAsc(int l) {
    Int_Int f = i -> i;
    var is = NewInt.array(l, f);
    assertEquals(0, searchAsc(is, Integer.MIN_VALUE));
    assertEquals(l, searchAsc(is, Integer.MAX_VALUE));
    for (var i = 0; i < l; i++) assertEquals(i, searchAsc(is, f.apply(i)));
}
Also used : Test(org.junit.jupiter.api.Test) Int_Int(primal.primitive.Int_Int) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NewInt(primal.primitive.IntVerbs.NewInt) Int_Int(primal.primitive.Int_Int)

Aggregations

Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Test (org.junit.jupiter.api.Test)3 Int_Int (primal.primitive.Int_Int)3 NewInt (primal.primitive.IntVerbs.NewInt)2 Map (java.util.Map)1 BiPredicate (java.util.function.BiPredicate)1 Type (org.apache.bcel.generic.Type)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Fun (primal.fp.Funs.Fun)1 Iterate (primal.fp.Funs.Iterate)1 Source (primal.fp.Funs.Source)1 Flt_Flt (primal.primitive.Flt_Flt)1 IntSource (primal.primitive.IntPrim.IntSource)1 Suite (suite.Suite)1 Dump (suite.inspect.Dump)1 PrintlnFunExpr (suite.jdk.gen.FunExprM.PrintlnFunExpr)1 ProfileFunExpr (suite.jdk.gen.FunExprM.ProfileFunExpr)1 FunExpr (suite.jdk.gen.FunExpression.FunExpr)1 LambdaInstance (suite.jdk.lambda.LambdaInstance)1 LambdaInterface (suite.jdk.lambda.LambdaInterface)1