3838import org .scijava .ops .math .Sqrt .MathSqrtOp ;
3939import org .scijava .ops .types .Nil ;
4040import org .scijava .ops .util .Adapt ;
41- import org .scijava .ops .util .Inject ;
4241
4342public class AdaptersTest extends AbstractTestEnvironment {
4443
4544 @ Test
4645 public void testFunctionAsCommand () {
4746 Class <Double > c = Double .class ;
4847 Function <Double , Double > sqrtFunction = ops ().findOp ( //
49- MathSqrtOp .class ,
50- new Nil <Function <Double , Double >>() {
48+ MathSqrtOp .class , new Nil <Function <Double , Double >>() {
5149 }, //
5250 new Type [] { c }, //
5351 c //
5452 );
55-
56- OneToOneCommand <Double , Double > sqrtCommand = Adapt .Functions .asCommand (sqrtFunction );
57- Inject .Commands .inputs (sqrtCommand , 25.0 );
53+
54+ OneToOneCommand <Double , Double > sqrtCommand = Adapt .Functions .asCommand (sqrtFunction , 25.0 );
5855 sqrtCommand .run ();
5956 assert sqrtCommand .get ().equals (5.0 );
6057 }
61-
58+
6259 @ Test
6360 public void testComputerAsCommand () {
6461 Class <double []> cArray = double [].class ;
6562 Computer <double [], double []> sqrtComputer = ops ().findOp ( //
66- MathSqrtOp .class ,
67- new Nil <Computer <double [], double []>>() {
63+ MathSqrtOp .class , new Nil <Computer <double [], double []>>() {
6864 }, //
6965 new Type [] { cArray , cArray }, //
7066 cArray //
7167 );
72-
73- OneToOneCommand <double [], double []> sqrtCommand = Adapt .Computers .asCommand (sqrtComputer );
74- Inject .Commands .inputs (sqrtCommand , new double [] {25 , 100 , 4 });
75- Inject .Commands .outputs (sqrtCommand , new double [3 ]);
68+
69+ OneToOneCommand <double [], double []> sqrtCommand = Adapt .Computers .asCommand (sqrtComputer ,
70+ new double [] { 25 , 100 , 4 }, new double [3 ]);
7671 sqrtCommand .run ();
77- assert arrayEquals (sqrtCommand .get (), 5.0 , 10.0 , 2.0 );
72+ assert arrayEquals (sqrtCommand .get (), 5.0 , 10.0 , 2.0 );
7873 }
79-
74+
8075 @ Test
8176 public void testComputerAsFunction () {
8277 Class <double []> cArray = double [].class ;
8378 final BiComputer <double [], double [], double []> computer = ops ().findOp ( //
84- MathAddOp .class ,
85- new Nil <BiComputer <double [], double [], double []>>() {
79+ MathAddOp .class , new Nil <BiComputer <double [], double [], double []>>() {
8680 }, //
8781 new Type [] { cArray , cArray , cArray }, //
8882 cArray //
8983 );
9084
91- BiFunction <double [], double [], double []> computerAsFunction = Adapt .Computers .asBiFunction (computer , (arr1 , arr2 ) -> {
92- return new double [arr1 .length ];
93- });
85+ BiFunction <double [], double [], double []> computerAsFunction = Adapt .Computers .asBiFunction (computer ,
86+ (arr1 , arr2 ) -> {
87+ return new double [arr1 .length ];
88+ });
9489
9590 final double [] a1 = { 3 , 5 , 7 };
9691 final double [] a2 = { 2 , 4 , 9 };
@@ -103,18 +98,18 @@ public void testFunctionAsComputer() {
10398 Class <double []> c = double [].class ;
10499 // look up a function: Double result = math.add(Double v1, Double v2)
105100 BiFunction <double [], double [], double []> function = ops ().findOp ( //
106- MathAddOp .class ,
107- new Nil <BiFunction <double [], double [], double []>>() {
101+ MathAddOp .class , new Nil <BiFunction <double [], double [], double []>>() {
108102 }, //
109103 new Type [] { c , c }, //
110104 c //
111105 );
112106
113- BiComputer <double [], double [], double []> functionAsComputer = Adapt .Functions .asBiComputer (function , (from , to ) -> {
114- for (int i = 0 ; i < from .length ; i ++) {
115- to [i ] = from [i ];
116- }
117- });
107+ BiComputer <double [], double [], double []> functionAsComputer = Adapt .Functions .asBiComputer (function ,
108+ (from , to ) -> {
109+ for (int i = 0 ; i < from .length ; i ++) {
110+ to [i ] = from [i ];
111+ }
112+ });
118113
119114 final double [] a1 = { 3 , 5 , 7 };
120115 final double [] a2 = { 2 , 4 , 9 };
0 commit comments