Package com.rescripter.script

Examples of com.rescripter.script.RunScript


import com.rescripter.script.RunScript;

public class FindIntegrationTest extends BaseRescripterIntegrationTest {
  @Test public void
  finds_types_by_name() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    runScript.withContents("var person = Find.typeByName('Person');\n", null, "inline script");
    IType type = runScript.getProperty(IType.class, "person");
    assertThat(type, is(notNullValue()));
    assertThat(type, is(getJavaProject().findType("com.example.Person")));
  }
View Full Code Here


    assertThat(type, is(getJavaProject().findType("com.example.Person")));
  }
 
  @Test(expected=Exception.class) public void
  fails_to_find_missing_type_by_name() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    runScript.withContents("var person = Find.typeByName('NotAPerson');\n", null, "inline script");
  }
View Full Code Here

    runScript.withContents("var person = Find.typeByName('NotAPerson');\n", null, "inline script");
  }

  @Test public void
  finds_method_by_name() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    runScript.withContents(
        "var person = Find.typeByName('Person');\n" +
        "var getName = Find.methodByName(person, 'getName');\n", null, "inline script");
    assertThat(runScript.getProperty(IMethod.class, "getName"), is(notNullValue()));
  }
View Full Code Here

    assertThat(runScript.getProperty(IMethod.class, "getName"), is(notNullValue()));
  }

  @Test(expected=Exception.class) public void
  fails_to_find_missing_method_by_name() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    runScript.withContents(
        "var person = Find.typeByName('Person');\n" +
        "var getName = Find.methodByName(person, 'noSuchGetName');\n", null, "inline script");
  }
View Full Code Here

    assertThat(getJavaProject().findType("com.example.Person"), is(notNullValue()));
  }
 
  @Test public void
  runs_basic_script() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    runScript.withContents("var response = 42;\n", null, "inline script");
    assertThat(runScript.getIntegerProperty("response"), is(42));
  }
View Full Code Here

      return null;
    }
  }

  protected RunScript createRunScript(IWorkbenchWindow window) throws IOException, CoreException {
    return new RunScript(window);
  }
View Full Code Here

public class ASTIntegrationTest extends BaseRescripterIntegrationTest {
 
  @Test public void
  parses_compilation_unit() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    runScript.withContents(
        "var person = Find.typeByName('Person');\n" +
        "var ast = AST.parseCompilationUnit(person.getCompilationUnit());\n", null, "inline script");
   
    ASTNode ast = runScript.getProperty(ASTNode.class, "ast");
   
    assertThat(ast, is(notNullValue()));
    assertThat(ast.toString(), containsString("public class Person"));
    assertThat(ast.toString(), containsString("public Person("));
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Test public void
  finds_covered_node() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    String methodCallText = "person.setName(\"Bob\")";
    IType personType = getJavaProject().findType("com.example.Person");
    String personSource = personType.getCompilationUnit().getSource();
    int offsetOfCall = personSource.indexOf(methodCallText);
    runScript.withContents(
        "var person = Find.typeByName('Person');\n" +
        "var ast = AST.parseCompilationUnit(person.getCompilationUnit());\n" +
        "var node = AST.findCoveredNode(ast, " + offsetOfCall + ", " + methodCallText.length() + ");\n"
        , null, "inline script");

    MethodInvocation node = runScript.getProperty(MethodInvocation.class, "node");
   
    assertThat(node, is(notNullValue()));
    assertThat(node.getExpression().toString(), is("person"));
    assertThat(node.getName().toString(), is("setName"));
    assertThat((List<ASTNode>) node.arguments(),
View Full Code Here

  private Mockery context = new Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }};
 
  @Test public void
  runs_script_from_current_editor() throws ExecutionException {
    final RunScript runScript = context.mock(RunScript.class);
    final IFile file = context.mock(IFile.class);
    final IWorkbenchWindow window = context.mock(IWorkbenchWindow.class);
    final ITextEditor editor = context.mock(ITextEditor.class);
    final IFileEditorInput editorInput = context.mock(IFileEditorInput.class);
    final IDocumentProvider documentProvider = context.mock(IDocumentProvider.class);
View Full Code Here

TOP

Related Classes of com.rescripter.script.RunScript

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.