Package org.eclipse.php.core.tests

Examples of org.eclipse.php.core.tests.PdttFile


    for (String testsDirectory : TEST_DIRS) {

      for (final String fileName : getPDTTFiles(testsDirectory)) {
        try {
          final PdttFile pdttFile = new PdttFile(fileName);
          filesMap.put(pdttFile, null);

          suite.addTest(new PHP54ValidationReportingTests("/" + fileName) {

            protected void runTest() throws Throwable {
              IFile file = filesMap.get(pdttFile);
              Thread.sleep(4);

              StringBuilder buf = new StringBuilder();

              List<IMarker> markers = new ArrayList<IMarker>(
                  Arrays.asList(file.findMarkers(
                      PEXProblemIdentifier.MARKER_TYPE, true,
                      IResource.DEPTH_ZERO)));
              Collections.sort(markers,
                  new Comparator<IMarker>() {
                    @Override
                    public int compare(IMarker o1,
                        IMarker o2) {
                      try {
                        return ((Integer) o1
                            .getAttribute(IMarker.CHAR_START)).compareTo( (Integer) o2
                                .getAttribute(IMarker.CHAR_START));
                      } catch (CoreException e) {
                        return -1;
                      }
                    }
                  });
              for (IMarker marker : markers) {
                buf.append("\n[line=");
                buf.append(marker
                    .getAttribute(IMarker.LINE_NUMBER));
                buf.append(", start=");
                buf.append(marker
                    .getAttribute(IMarker.CHAR_START));
                buf.append(", end=");
                buf.append(marker
                    .getAttribute(IMarker.CHAR_END));
                buf.append("] ");
                buf.append(marker.getAttribute(IMarker.MESSAGE))
                    .append('\n');
              }

              assertContents(pdttFile.getExpected(),
                  buf.toString());
            }
          });
        } catch (final Exception e) {
          suite.addTest(new TestCase(fileName) { // dummy test
View Full Code Here


      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new DomParserTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void runTest() throws Throwable {
                newParser.setSource(pdttFile.getFile().trim()
                    .toCharArray());
                Program program = newParser
                    .createAST(new NullProgressMonitor());

                assertContents(pdttFile.getExpected(),
                    program.toString());
              }
            });
          } catch (final Exception e) {
            // dummy test indicating PDTT file parsing failure
View Full Code Here

      testsDirectory = testsDirectory.replaceAll("project", map.get(
          ProjectSuite.PROJECT).toString());
      for (final String fileName : getPDTTFiles(testsDirectory,
          PHPCorePerformanceTests.getDefault().getBundle())) {
        try {
          final PdttFile pdttFile = new PdttFile(
              PHPCorePerformanceTests.getDefault().getBundle(),
              fileName);
          final String pruner = getPrunerType(pdttFile);

          suite.addTest(new TypeInferenceTests(phpVersion.getAlias()
              + " - /" + fileName) {

            protected void setUp() throws Exception {
              PHPCoreTests.setProjectPhpVersion(project,
                  phpVersion);
            }

            protected void tearDown() throws Exception {
            }

            protected void runTest() throws Throwable {
              String criteriaFunction = new File(fileName)
                  .getName().replaceAll("\\.pdtt", "");
              String code = pdttFile.getFile();

              findEvaluatedType(fileName, code, criteriaFunction,
                  pruner);
            }
          });
View Full Code Here

      testsDirectory = testsDirectory.replaceAll("project", map.get(
          ProjectSuite.PROJECT).toString());
      for (final String fileName : getPDTTFiles(testsDirectory,
          PHPCorePerformanceTests.getDefault().getBundle())) {
        try {
          final PdttFile pdttFile = new PdttFile(
              PHPCorePerformanceTests.getDefault().getBundle(),
              fileName);
          FormatterTests test = new FormatterTests(fileName) {
            protected void tearDown() throws Exception {
              if (testFile != null) {
                testFile.delete(true, null);
                testFile = null;
              }
            }

            protected void runTest() throws Throwable {

              executeLocator(pdttFile.getFile(), fileName);
            }
          };
          suite.addTest(test);
        } catch (final Exception e) {
          suite.addTest(new TestCase(fileName) { // dummy
View Full Code Here

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            filesMap.put(pdttFile, null);

            phpVerSuite.addTest(new FormatterTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
              }

              protected void runTest() throws Throwable {

                IFile file = filesMap.get(pdttFile);
                ISourceModule modelElement = (ISourceModule) DLTKCore
                    .create(file);
                if (ScriptModelUtil.isPrimary(modelElement))
                  modelElement.becomeWorkingCopy(
                      new IProblemRequestor() {

                        public void acceptProblem(
                            IProblem problem) {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void beginReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void endReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public boolean isActive() {
                          // TODO Auto-generated
                          // method stub
                          return false;
                        }
                      }, null);
                IStructuredModel modelForEdit = StructuredModelManager
                    .getModelManager()
                    .getModelForEdit(file);
                try {
                  IDocument document = modelForEdit
                      .getStructuredDocument();
                  String beforeFormat = document.get();

                  PhpFormatProcessorImpl formatter = new PhpFormatProcessorImpl();
                  formatter.formatDocument(document, 0,
                      document.getLength());
                  assertContents(pdttFile.getExpected(),
                      document.get());

                  // change the document text as was before
                  // the formatting
                  document.set(beforeFormat);
View Full Code Here

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new DocumentLexerTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void runTest() throws Throwable {

                AbstractPhpLexer lexer = PhpLexerFactory
                    .createLexer(new ByteArrayInputStream(
                        pdttFile.getFile().trim()
                            .getBytes()),
                        phpVersion);
                int inScriptingState = lexer.getClass()
                    .getField("ST_PHP_IN_SCRIPTING")
                    .getInt(lexer); // different lexers have
                            // different state codes
                lexer.initialize(inScriptingState);

                StringBuilder actualBuf = new StringBuilder();
                String tokenType = lexer.yylex();
                while (tokenType != null) {
                  actualBuf.append(tokenType).append('|')
                      .append(lexer.yytext()).append('|')
                      .append(lexer.yystate())
                      .append('\n');
                  tokenType = lexer.yylex();
                }

                assertContents(pdttFile.getExpected(),
                    actualBuf.toString());
              }
            });
          } catch (final Exception e) {
            // dummy test indicating PDTT file parsing failure
View Full Code Here

      testsDirectory = testsDirectory.replaceAll("project", map.get(
          ProjectSuite.PROJECT).toString());
      for (final String fileName : getPDTTFiles(testsDirectory,
          PHPCorePerformanceTests.getDefault().getBundle())) {
        try {
          final PdttFile pdttFile = new PdttFile(
              PHPCorePerformanceTests.getDefault().getBundle(),
              fileName);
          PhpElementConciliatorTest test = new PhpElementConciliatorTest(
              fileName) {
            protected void tearDown() throws Exception {
              if (testFile != null) {
                testFile.delete(true, null);
                testFile = null;
              }
            }

            protected void runTest() throws Throwable {
              executeLocator(pdttFile.getFile(), fileName);
            }
          };
          suite.addTest(test);
        } catch (final Exception e) {
          suite.addTest(new TestCase(fileName) { // dummy
View Full Code Here

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new CompilerParserTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void runTest() throws Throwable {

                ByteArrayInputStream inputStream = new ByteArrayInputStream(
                    pdttFile.getFile().trim().getBytes());
                ModuleDeclaration moduleDeclaration = (ModuleDeclaration) parser
                    .parse(new InputStreamReader(
                        inputStream),
                        null,
                        ProjectOptions
                            .useShortTags((IProject) null));

                final StringBuilder builder = new StringBuilder();

                moduleDeclaration
                    .traverse(new TypeDeclarationVisitor() {
                      @Override
                      public void visitType(
                          TypeDeclaration s) {
                        builder.append(s.getName());
                        builder.append('\n');
                      }
                    });

                String actual = builder.toString();
                String expected = pdttFile.getExpected();

                assertContents(expected, actual);
              }
            });
          } catch (final Exception e) {
View Full Code Here

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new SearchFieldTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
              }

              protected void tearDown() throws Exception {
                if (testFile != null) {
                  testFile.delete(true, null);
                  testFile = null;
                }
              }

              protected void runTest() throws Throwable {
                List<String> paths = getSelection(pdttFile
                    .getFile());
                int occurrences = Integer.parseInt(pdttFile
                    .getExpected().trim());

                boolean proposalsEqual = true;
                if (paths.size() == occurrences) {
                } else {
                  proposalsEqual = false;
                }

                if (!proposalsEqual) {
                  StringBuilder errorBuf = new StringBuilder();
                  errorBuf.append("\nEXPECTED OCCURRENCE TIMES:\n-----------------------------\n");
                  errorBuf.append(pdttFile.getExpected());
                  errorBuf.append("\nACTUAL OCCURRENCE TIMES:\n-----------------------------\n");
                  errorBuf.append(paths.size());
                  fail(errorBuf.toString());
                }
              }
View Full Code Here

    for (String testsDirectory : TEST_DIRS) {

      for (final String fileName : getPDTTFiles(testsDirectory)) {
        try {
          final PdttFile pdttFile = new PdttFile(fileName);
          filesMap.put(pdttFile, null);

          suite.addTest(new PHP53ErrorReportingTests("/" + fileName) {

            protected void runTest() throws Throwable {
              IFile file = filesMap.get(pdttFile);

              StringBuilder buf = new StringBuilder();

              IMarker[] markers = file.findMarkers(
                  DefaultProblem.MARKER_TYPE_PROBLEM, true,
                  IResource.DEPTH_ZERO);
              Arrays.sort(markers, new MarkerComparator());
              for (IMarker marker : markers) {
                buf.append("\n[line=");
                buf.append(marker
                    .getAttribute(IMarker.LINE_NUMBER));
                buf.append(", start=");
                buf.append(marker
                    .getAttribute(IMarker.CHAR_START));
                buf.append(", end=");
                buf.append(marker
                    .getAttribute(IMarker.CHAR_END));
                buf.append("] ");
                buf.append(marker.getAttribute(IMarker.MESSAGE))
                    .append('\n');
              }

              assertContents(pdttFile.getExpected(),
                  buf.toString());
            }
          });
        } catch (final Exception e) {
          suite.addTest(new TestCase(fileName) { // dummy test
View Full Code Here

TOP

Related Classes of org.eclipse.php.core.tests.PdttFile

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.