View Javadoc
1   /*
2    * Copyright 2007, 2008 Ange Optimization ApS
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /**
17   * @author Kim Hansen
18   */
19  package eu.simuline.octave.io;
20  
21  import eu.simuline.octave.OctaveEngine;
22  import eu.simuline.octave.OctaveEngineFactory;
23  import eu.simuline.octave.type.Octave;
24  import eu.simuline.octave.type.OctaveDouble;
25  
26  import static org.junit.Assert.assertNull;
27  import static org.junit.Assert.assertEquals;
28  
29  import org.junit.Ignore;
30  import org.junit.Test;
31  
32  /** Tests */
33  public class TestUnknownVar {
34  
35      /**
36       * Test Octave.get() on unknown var
37       */
38      @Test public void testGetUnknownVar() {
39          final OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
40          final OctaveDouble x1 = octave.get(OctaveDouble.class, "x");
41          assertNull(x1);
42          final OctaveDouble x = Octave.scalar(42);
43          octave.put("x", x);
44          final OctaveDouble x2 = octave.get(OctaveDouble.class, "x");
45          assertEquals(x, x2);
46          octave.close();
47      }
48  
49  }