예제 #1
0
  protected void doTest() {
    try {
      final String testName = getTestName(false);
      configureByFileNoComplete(testName + ".kt");

      final String fileText = getFile().getText();
      type = getCompletionType(testName, fileText);

      boolean withKotlinRuntime =
          InTextDirectivesUtils.getPrefixedInt(fileText, "// RUNTIME:") != null;

      try {
        if (withKotlinRuntime) {
          ConfigRuntimeUtil.configureKotlinRuntime(getModule(), getFullJavaJDK());
        }

        Integer completionTime = completionUtils.getExecutionTime(fileText);

        complete(completionTime == null ? 1 : completionTime);

        ExpectedCompletionUtils.CompletionProposal[] expected =
            completionUtils.itemsShouldExist(fileText);
        ExpectedCompletionUtils.CompletionProposal[] unexpected =
            completionUtils.itemsShouldAbsent(fileText);
        Integer itemsNumber = completionUtils.getExpectedNumber(fileText);

        assertTrue(
            "Should be some assertions about completion",
            expected.length != 0 || unexpected.length != 0 || itemsNumber != null);

        if (myItems == null) {
          myItems = new LookupElement[0];
        }

        ExpectedCompletionUtils.assertContainsRenderedItems(
            expected, myItems, completionUtils.isWithOrder(fileText));
        ExpectedCompletionUtils.assertNotContainsRenderedItems(unexpected, myItems);

        if (itemsNumber != null) {
          assertEquals(
              String.format(
                  "Invalid number of completion items: %s",
                  ExpectedCompletionUtils.listToString(
                      ExpectedCompletionUtils.getItemsInformation(myItems))),
              itemsNumber.intValue(),
              myItems.length);
        }
      } finally {
        if (withKotlinRuntime) {
          ConfigRuntimeUtil.unConfigureKotlinRuntime(getModule(), getProjectJDK());
        }
      }
    } catch (Exception e) {
      throw new AssertionError(e);
    }
  }
예제 #2
0
  @Override
  protected void runTest() throws Throwable {
    boolean isWithRuntime = name.endsWith("Runtime");

    if (isWithRuntime) {
      ConfigRuntimeUtil.configureKotlinRuntime(getModule(), getFullJavaJDK());
    }

    try {
      doSingleTest(name.substring("before".length()) + ".kt");
      checkForUnexpectedErrors();
    } finally {
      if (isWithRuntime) {
        ConfigRuntimeUtil.unConfigureKotlinRuntime(getModule(), getProjectJDK());
      }
    }
  }