]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSessionWithModules.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / TestCommandSessionWithModules.java
1 package org.simantics.scl.compiler.tests;
2
3 import java.io.StringReader;
4 import java.io.StringWriter;
5
6 import org.junit.Assert;
7 import org.junit.Test;
8 import org.simantics.scl.compiler.commands.CommandSessionWithModules;
9 import org.simantics.scl.osgi.SCLOsgi;
10
11 public class TestCommandSessionWithModules {
12     @Test
13     public void testCommandSessionWithModules() {
14         CommandSessionWithModules session = new CommandSessionWithModules(SCLOsgi.MODULE_REPOSITORY);
15         session.putModule("My/Test/Module", "someValue = 13");
16         
17         {
18             StringWriter writer = new StringWriter();
19             session.runCommands(new StringReader("import \"My/Test/Module\"\nsomeValue"), writer);
20             Assert.assertEquals("13\n", writer.toString());
21         }
22         
23         session.putModule("My/Test/Module", "someValue = 14");
24         
25         {
26             StringWriter writer = new StringWriter();
27             session.runCommands(new StringReader("someValue\nsomeValue+1"), writer);
28             Assert.assertEquals("14\n15\n", writer.toString());
29         }
30     }
31 }