1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package eu.simuline.octave.io.impl;
17
18 import eu.simuline.octave.OctaveEngine;
19 import eu.simuline.octave.OctaveEngineFactory;
20 import eu.simuline.octave.io.OctaveIO;
21 import eu.simuline.octave.type.OctaveFunctionHandle;
22 import eu.simuline.octave.type.OctaveObject;
23
24 import static org.junit.Assert.assertEquals;
25
26 import org.junit.Ignore;
27 import org.junit.Test;
28
29
30
31
32
33 public class TestIoFunctionHandle {
34
35
36 @Test public void testToString() {
37 final OctaveObject fh =
38 new OctaveFunctionHandle("@(x) sqrt (1 - x ^ 2)");
39 assertEquals("# name: ans\n" +
40 "# type: function handle\n" +
41 "@<anonymous>\n" +
42 "@(x) sqrt (1 - x ^ 2)\n" +
43 "# length: 0\n",
44 OctaveIO.toText(fh));
45 }
46
47
48 @Test public void testToOctave() {
49 final OctaveObject fh =
50 new OctaveFunctionHandle("@(x) sqrt (1 - x ^ 2)");
51 assertEquals("# name: fh\n" +
52 "# type: function handle\n" +
53 "@<anonymous>\n" +
54 "@(x) sqrt (1 - x ^ 2)\n" +
55 "# length: 0\n",
56 OctaveIO.toText("fh", fh));
57 }
58
59
60 @Test public void testOctaveConnection() {
61 final OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
62 if (octave.getVersion().equals("3.0.5")) {
63 octave.close();
64 return;
65 }
66 final OctaveObject fh1 =
67 new OctaveFunctionHandle("@(x) sqrt (1 - x ^ 2)");
68 octave.put("fh", fh1);
69
70
71
72 octave.close();
73 }
74
75 }