X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2FTestCommandSession.java;fp=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2FTestCommandSession.java;h=0000000000000000000000000000000000000000;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hp=a93f706a5fa220861715feb8a51374fff5795bdb;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/TestCommandSession.java b/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/TestCommandSession.java deleted file mode 100644 index a93f706a5..000000000 --- a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/TestCommandSession.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.simantics.scl.compiler.tests; - -import org.junit.Before; -import org.junit.Test; -import org.simantics.scl.compiler.commands.CommandSession; -import org.simantics.scl.compiler.module.repository.ModuleRepository; -import org.simantics.scl.compiler.source.repository.CompositeModuleSourceRepository; -import org.simantics.scl.compiler.source.repository.SourceRepositories; -import org.simantics.scl.runtime.reporting.AbstractSCLReportingHandler; -import org.simantics.scl.runtime.reporting.SCLReportingHandler; - -public class TestCommandSession { - - ModuleRepository moduleRepository; - - @Before - public void initialize() throws Exception { - moduleRepository = new ModuleRepository( - new CompositeModuleSourceRepository( - SourceRepositories.BUILTIN_SOURCE_REPOSITORY, - SourceRepositories.PRELUDE_SOURCE_REPOSITORY - )); - } - - private static class SCLErrorMessageException extends RuntimeException { - private static final long serialVersionUID = 418954639267697065L; - public SCLErrorMessageException(String message) { - super(message); - } - } - - private static final SCLReportingHandler TEST_HANDLER = new AbstractSCLReportingHandler() { - @Override - public void print(String text) { - System.out.println(text); - } - - public void printError(String error) { - System.err.println(error); - throw new SCLErrorMessageException(error); - } - }; - - @Test - public void testCommandSession() { - CommandSession session = new CommandSession(moduleRepository, TEST_HANDLER); - - session.execute("a = 1"); - session.execute("b = 2"); - session.execute("a + b"); - - session.execute("x = 1\ny = 2"); - session.execute("x + y"); - } - - @Test - public void testCommandSession2() { - CommandSession session = new CommandSession(moduleRepository, TEST_HANDLER); - - session.execute("f name coords = print \"\\(name :: String) \\(coords :: (Double, Double))\""); - session.execute("g name (x,y) = f name (x,y)"); - } - - @Test - public void testTyping1() { - CommandSession session = new CommandSession(moduleRepository, TEST_HANDLER); - - session.execute("apply f = f ()"); - session.execute("printHello () = print \"Hello\""); - session.execute("apply printHello"); - } - - @Test - public void testTyping2() { - CommandSession session = new CommandSession(moduleRepository, TEST_HANDLER); - - session.execute("iter f (list :: [a]) = loop 0 where { len = length list ; loop i | i == len = 0 | otherwise = do f (list!i) ; loop (i+1) }"); - session.execute("iter (\\i -> print i) [1,2,3]"); - session.execute("iter (\\i -> print i) [(),(),()]"); - } - -}