changeset 15:59bfbaf8847f

Updates to run.d - still errors
author Anders Johnsen <skabet@gmail.com>
date Fri, 18 Apr 2008 17:49:34 +0200
parents a297b53fa7ea (diff) a51bdf15a33d (current diff)
children 2a7b05d2e4f9
files lexer/Lexer.d sema/Declarations.d tests/run.d
diffstat 3 files changed, 101 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/lexer/Lexer.d	Fri Apr 18 15:25:10 2008 +0200
+++ b/lexer/Lexer.d	Fri Apr 18 17:49:34 2008 +0200
@@ -125,7 +125,8 @@
                                 if(source.data[position-1] == '/')
                                    return this.next;
                         }
-                        return Token(Tok.EOF, Location(position, this.source), 0);
+                        throw new Error("Unexpected end of file. Unclosed comment block", 
+                                Location(position, source));
 
                     case '+':
                         position += 2;
@@ -150,7 +151,8 @@
                             if(nesting == 0)
                                 return this.next;
                         }
-                        return Token(Tok.EOF, Location(position, this.source), 0);
+                        throw new Error("Unexpected end of file. Unclosed comment block", 
+                                Location(position, source));
 
                     default:
                         return Token(Tok.Div, Location(position - 1, this.source), 1);
--- a/sema/Declarations.d	Fri Apr 18 15:25:10 2008 +0200
+++ b/sema/Declarations.d	Fri Apr 18 17:49:34 2008 +0200
@@ -20,7 +20,8 @@
             "int":4,
             "uint":5,
             "long":6,
-            "ulong":7
+            "ulong":7,
+            "bool":8
                 ];
     }
 
--- a/tests/run.d	Fri Apr 18 15:25:10 2008 +0200
+++ b/tests/run.d	Fri Apr 18 17:49:34 2008 +0200
@@ -2,6 +2,13 @@
 
 import tango.io.Stdout,
        tango.io.FilePath,
+       tango.io.GrowBuffer,
+       tango.io.UnicodeFile,
+       tango.io.stream.BufferStream,
+       tango.text.Util,
+       tango.io.protocol.Reader,
+       tango.io.protocol.Writer,
+       tango.text.Unicode,
        tango.sys.Process;
 
 
@@ -11,7 +18,7 @@
 {
     auto cPath = FilePath("tests");
 
-    int succes, failure;
+    ubyte success_success, success_failure, failure_failure, failure_success;
 
     foreach( path ; cPath.toList((FilePath path, bool isFolder){return isFolder;}))
     {
@@ -23,19 +30,34 @@
                         return false;
                     }))
         {
-            auto test = new Test(p);
-            bool result = test.run();
-            if(result)
-                succes++;
-            else
-                failure++;
+            auto test = new Test(p);    
+            ubyte result = test.run();
+
+            switch(result)
+            {
+                case 0:
+                    success_success++;
+                    break;
+                case 1:
+                    success_failure++;
+                    break;
+                case 2:
+                    failure_failure++;
+                    break;
+                case 3:
+                    failure_success++;
+                    break;
+            }
+
         }
     }
 
     Stdout().newline.newline()
         ("Result:").newline()
-        ("  - Succes:   ")(succes).newline()
-        ("  - Failure:  ")(failure).newline;
+        ("  - Succes/Success:   ")(success_success).newline()
+        ("  - Succes/Failure:   ")(success_failure).newline()
+        ("  - Failure/Failure:  ")(failure_failure).newline()
+        ("  - Failure/Success:  ")(failure_success).newline;
 }
 
 class Test
@@ -46,24 +68,81 @@
         this.target = target;
     }
 
-    public bool run()
+    public ubyte run()
     {
-        auto process = new Process(prog,target.path~target.file);
+        auto process = new Process(prog,"--gen-llvm",target.path~target.file);
+
+        auto file = new UnicodeFile!(char)(target.path~target.file, Encoding.UTF_8);
+
+        int mode;
+
+        char[] data = file.read;
+        if(data.length > 6 && data[0..6] == "//test")
+        {
+            char[] str = data.splitLines()[0][6..$];
+
+            switch(toLower(trim(str)))
+            {
+                case "fail":
+                case "failure":
+                    mode = 1;
+                    break;
+                default:
+                    mode = 0;
+            }
+        }
 
         Stdout("  - ")(target.file)(".. ");
 
         process.execute;
+        auto buffer = new GrowBuffer();
+        buffer.copy(process.stdout);
+//        auto result = process.wait;
 
-        auto result = process.wait;
+        Process.Result result;
+
+        Stdout("1").newline;
+//        if(result.status == 0)
+//        {
+            Stdout("2").newline;
+            auto llvm_process = new Process("llvm-as",target.path~target.file);
+            llvm_process.execute;
+            if(llvm_process.isRunning)
+            {
+            Stdout("3")(process.stdout)(llvm_process.stdin).newline;
+ //           llvm_process.stdin.copy(buffer);
+            llvm_process.stdin.write("lalalala");
+            Stdout("4").newline;
+            result = llvm_process.wait;
+            }
+//        }
+
         if(result.status == 0)
         {
-            Stdout("SUCCES").newline;
-            return true;
+            if(mode == 0)
+            {
+                Stdout("SUCCES").newline;
+                return 0;
+            }
+            if(mode == 1)
+            {
+                Stdout("SUCCES - Unexpected").newline;
+                return 3;
+            }
         }
         else
         {
-            Stdout("FAILURE").newline;
-            return false;
+            if(mode == 1)
+            {
+                Stdout("FAILURE").newline;
+                return 2;
+            }
+            if(mode == 0)
+            {
+                Stdout("FAILURE - Unexpected").newline;
+                return 1;
+            }
         }
     }    
 }
+