]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/markdown/RunMarkdownTests.java
Merged changes from feature/scl to master.
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / markdown / RunMarkdownTests.java
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/markdown/RunMarkdownTests.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/markdown/RunMarkdownTests.java
deleted file mode 100644 (file)
index 9971a02..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.simantics.scl.compiler.tests.markdown;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.nio.charset.Charset;
-
-import org.simantics.scl.compiler.markdown.internal.MarkdownParser;
-import org.simantics.scl.compiler.markdown.nodes.Node;
-
-public class RunMarkdownTests {
-    
-    public static int FAILED = 0;
-    public static int SUCCEEDED = 1;
-    public static int SKIPPED = 2;
-    
-    public static void main(String[] args) throws IOException {
-        BufferedReader reader = new BufferedReader(
-                new InputStreamReader(
-                        RunMarkdownTests.class.getResourceAsStream("spec.txt"),
-                        Charset.forName("UTF-8")));
-        
-        StringBuilder in = new StringBuilder();
-        StringBuilder out = new StringBuilder();
-        int state = 0;
-        int testId = 0;
-        int passed = 0;
-        int failed = 0;
-        int skipped = 0;
-        while(true) {
-            String line = reader.readLine();
-            if(line == null)
-                break;
-            switch(state) {
-            case 0:
-                if(line.equals("```````````````````````````````` example"))
-                    ++state;
-                break;
-            case 1:
-                if(line.equals("."))
-                    ++state;
-                else {
-                    if(in.length() > 0)
-                        in.append('\n');
-                    in.append(line);
-                }
-                break;
-            case 2:
-                if(line.equals("````````````````````````````````")) {
-                    ++testId;
-                    int status = test(testId, in.toString(), out.toString());
-                    if(status == SUCCEEDED)
-                        ++passed;
-                    else if(status == FAILED)
-                        ++failed;
-                    else
-                        ++skipped;
-                    in = new StringBuilder();
-                    out = new StringBuilder();
-                    state = 0;
-                }
-                else {
-                    if(out.length() > 0)
-                        out.append('\n');
-                    out.append(line);
-                }
-                break;
-            }
-        }
-        
-        System.out.println("Passed: " + passed + "/" + testId);
-        System.out.println("Failed: " + failed + "/" + testId);
-        System.out.println("Skipped: " + skipped + "/" + testId);
-    }
-
-    public static int test(int id, String in, String out) throws IOException {
-        MarkdownParser parser = new MarkdownParser();
-        Node node = parser.parseDocument(new StringReader(in.replace('\u2192', '\t')));
-        
-        String result = node.toHtml().replace('\t', '\u2192');
-                
-        boolean passed = result.equals(out);
-        
-        if(!passed) {
-            System.out.println("Example " + id); // + (passed ? " passed" : " failed"));
-            System.out.println("---- in --------------------------------------------------------------------");
-            System.out.println(in);
-            System.out.println("---- expected --------------------------------------------------------------");
-            System.out.println(out);
-            System.out.println("---- actual ----------------------------------------------------------------");
-            System.out.println(result);
-            System.out.println("----------------------------------------------------------------------------");
-            System.out.println();
-        }
-            
-        return passed ? SUCCEEDED : FAILED;
-    }
-    
-}