# HG changeset patch # User Anders Johnsen # Date 1218558066 -7200 # Node ID 41ccd50e7cbc226ddd5bed1f785175e4e7f4d037 # Parent e0551773a005ed2570bc2b0813bc7457d382cf8e Added missing tests diff -r e0551773a005 -r 41ccd50e7cbc tests/code/float_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/float_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,11 @@ +int main() +{ + float a = 1.0 + 1; + double b = a + 1.0 + 2; + real c = b + a + 1e300; + c = c * a + a; + return c != f(); +} + +real f(); + diff -r e0551773a005 -r 41ccd50e7cbc tests/code/float_2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/float_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,8 @@ +int main() +{ + float a = 1.0 + 1; + double b = a + 1.0 + 2; + b = 1 + a; + return 0; +} + diff -r e0551773a005 -r 41ccd50e7cbc tests/code/function_pointer_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/function_pointer_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,15 @@ + +struct A +{ + int foo(int a) + { + return a; + } + int x; +} + +void main() +{ + A a; + int* d = &a.x; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/code/function_pointer_2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/function_pointer_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,11 @@ +//fail +int main() +{ + int function(int) f = &foo; + return f(); +} + +int foo(int x) +{ + return x*x*x; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/code/function_pointer_3.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/function_pointer_3.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,11 @@ + +int main() +{ + int function(int) f = &foo; + return f(3); +} + +int foo(int x) +{ + return x*x*x; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/code/public_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/public_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,15 @@ +//fail + +struct A +{ + private int b; + public int c; +} + + +int main() +{ + A a; + a.b = 4; // should fail + a.c = 5; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/code/sarray_2.d --- a/tests/code/sarray_2.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/code/sarray_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,8 +1,7 @@ -//fail int main() { int[10] a; - // static array assignment is illegal - we fail for other reasons though + // static array initialization is legal int[10] b = a; } diff -r e0551773a005 -r 41ccd50e7cbc tests/code/sarray_3.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/sarray_3.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,10 @@ +//fail +int main() +{ + int[10] a; + // static array initialization is legal + int[10] b = a; + // static array assignment is illegal + b = a; +} + diff -r e0551773a005 -r 41ccd50e7cbc tests/code/sarray_4.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/sarray_4.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,8 @@ + +int main() +{ + int[10] a; + int[10] b; + b[] = a; +} + diff -r e0551773a005 -r 41ccd50e7cbc tests/code/struct_6.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/struct_6.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,14 @@ + +struct A +{ + int foo() + { + return 5; + } +} + +int main() +{ + A a; + return a.foo(); +} diff -r e0551773a005 -r 41ccd50e7cbc tests/code/struct_7.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/code/struct_7.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,11 @@ +struct A { int a; } +A f() +{ + A a; + return a; +} + +void main() { + A a = f(); +} + diff -r e0551773a005 -r 41ccd50e7cbc tests/code/switch_1.d --- a/tests/code/switch_1.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/code/switch_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,6 +1,7 @@ -void main(int x) +void main() { + int x; switch (x) { } diff -r e0551773a005 -r 41ccd50e7cbc tests/code/switch_2.d --- a/tests/code/switch_2.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/code/switch_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,6 +1,7 @@ -void main(int x) +void main() { + int x; switch (x) { case 1: diff -r e0551773a005 -r 41ccd50e7cbc tests/code/switch_3.d --- a/tests/code/switch_3.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/code/switch_3.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,6 +1,7 @@ -void main(int x) +void main() { + int x; switch (x) { case 1, 2: diff -r e0551773a005 -r 41ccd50e7cbc tests/code/switch_4.d --- a/tests/code/switch_4.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/code/switch_4.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,6 +1,7 @@ -int main(int x) +int main() { + int x; switch (x) { case 1, 2: diff -r e0551773a005 -r 41ccd50e7cbc tests/code/switch_6.d --- a/tests/code/switch_6.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/code/switch_6.d Tue Aug 12 18:21:06 2008 +0200 @@ -7,6 +7,8 @@ return 0; case 2, 3: return 1; + case 1, 3: + return 1; } } diff -r e0551773a005 -r 41ccd50e7cbc tests/lexer/Comments2.d --- a/tests/lexer/Comments2.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/lexer/Comments2.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,4 +1,6 @@ //fail -/+ +/+ + + diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/alias_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/alias_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,21 @@ + +int foo(int x) +{ + return x + 6; +} + +alias foo bar; +alias int* i; +alias int A; +alias int B; + +int main() +{ + int x = bar(5); + i y = &x; + + A a = 5; + B b = a; + + return 11 - *y; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/array_literal_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/array_literal_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,6 @@ + +int main() +{ + int[3] x = [1,2,3]; + return x[0]; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/assign_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/assign_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,13 @@ + + +int main() +{ + int x = 0; + x = 2; + x += 5; + return x; +/* x -= 2; + x *= 3; + x /= 4; + x %= 3; */ +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/class_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/class_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,5 @@ + +class A +{ + int af; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/class_2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/class_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,15 @@ + +class A +{ + int a; +} + +class B : A +{ + int b; +} + +class C : B +{ + int c; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/extern_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/extern_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,12 @@ + +extern (D): + +void foo() +{ +} + +extern (C): + +void boo() +{ +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/extern_2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/extern_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,14 @@ + +extern(C): +int main() +{ + return 0; +} + +extern(D) +int boo() +{ + return 0; +} + +int foo(int); diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/float_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/float_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,8 @@ + + +void main() +{ + float f1 = 4_.5_e+54; + float f2 = 4._5_e+34; + float f3 = 4.__5_e-2; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/for_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/for_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,10 @@ + +int main() +{ + int x = 0; + for(int i = 0; i < 5; i = i + 1) + { + x = x + i; + } + return x; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/for_2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/for_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,9 @@ + +void main() +{ + for( ; ; ) + { + } +} + + diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/function_pointer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/function_pointer.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,15 @@ + +int main() +{ + g = &foo; + f = &g; + return g(2); +} + +int foo(int x) +{ + return x; +} + +int function(int x)* f; +int function(int x) g; diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/int_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/int_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,19 @@ + +int main() +{ + int i1 = 123_456; + int i2 = 1_2_3_4_5_6_; + + int i3 = 43_422_253; + long i4 = 34_322_523_123; + + long i5 = 43_422_253L; + long i6 = 34_322_523_123L; + + uint i7 = 43_422_253u; + ulong i8 = 18_446_744_073_709_551_615U; + + ulong i9 = 0UL; + ulong i10 = 18_446_744_073_709_551_615LU; + +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/interface_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/interface_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,7 @@ +interface A +{ +} + +interface B : A +{ +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/new_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/new_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,2 @@ +class A{this(int y){}int x;}struct B +{}void main(){B b;long x;A a=new A(x);} int x = 5; int foo(){int y = 5; y = y + x * 5; return y;} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/null_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/null_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,7 @@ + +int main() +{ + int* i = null; + + return 0; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/public_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/public_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,29 @@ + +public struct name +{ +static: + public void foo() + { + } +public +{ + private void bar() + { + } +auto: + final int i; +} + +static: + public void food() + { + } + private void bard() + { + } + final int id; +} + +void main() +{ +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/shift_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/shift_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,12 @@ + + +int main() +{ + int x = 4; + int y = 2; + + x = x << y; + x = x >> y; + x = x >>> y; + return x; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/simple_missing_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/simple_missing_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,10 @@ + +int main(int x) +{ + x = 5; + + y = 6 * -x; + return x; +} + +int y; diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/simple_missing_2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/simple_missing_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,11 @@ +//fail + +int main(int x) +{ + x = 5; + + y = 6 * -x; + return x; +} + +int y diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/simple_missing_3.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/simple_missing_3.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,11 @@ +//fail + +int main(int x) +{ + x = 5; + + y = 6 * -x; + return x; +} + +int diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/simple_missing_4.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/simple_missing_4.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,9 @@ +//fail + +int main(int x) +{ + x = 5; + + y = 6 * -x; + return x; + diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/string_1.d --- a/tests/parser/string_1.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/parser/string_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -12,7 +12,6 @@ char[5] s5 = `hello`; char[15] s6 = `c:\root\foo.exe`; char[4] s7 = `ab\n`; - char[4] s9 = `abn\`; char[5] s10 = "hello"; char[15] s11 = "c:\\root\\foo.exe"; @@ -23,5 +22,18 @@ char[1] s14 = x"0A"; char[6] s15 = x"00 FBCD 32FD 0A"; + /* And some custom ones */ + + char[7] s16 = "\x61\u05D0\U000201A4"; + char[2] s17 = "\122\522"; + char[8] s18 = x"61 62 63 64 + 65 66 67 68"; + + char[3] s19 = "\®\&"; + + char[3] s20 = "\®\&"c; + wchar[2] s21 = "\®\&"w; + dchar[2] s22 = "\®\&"d; + return 0; } diff -r e0551773a005 -r 41ccd50e7cbc tests/parser/this_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parser/this_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,8 @@ + +class A +{ + this() + { + } +} + diff -r e0551773a005 -r 41ccd50e7cbc tests/run.d --- a/tests/run.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/run.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,200 +1,171 @@ +// skip module run.d; -import tango.io.Stdout, - tango.core.Array, - 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; +import tango.core.Array, + tango.io.FileConduit, + tango.io.FileScan, + tango.io.Stdout, + tango.sys.Process, + tango.text.Ascii, + tango.text.Regex, + tango.text.Util; +// -- Settings -- +char[] compiler = "./Dang"; +char[] test_folder = "tests"; +char[] valid_filenames = r"^[^.].*"; +bool print_expected = false; +char[][] options; +// the tests can be sorted by one of the following functions +bool nameSort (FilePath a, FilePath b) { return a.name < b.name; } +bool pathSort (FilePath a, FilePath b) { return a.toString < b.toString; } +bool modifiedSort(FilePath a, FilePath b) { return a.modified < b.modified; } +bool createdSort (FilePath a, FilePath b) { return a.created < b.created; } +const sortBy = &pathSort; -enum +// -- end of settings + +enum TestResult { - SuccessSuccess, - SuccessFailure, - FailureSuccess, - FailureFailure, + Skipped, + Expected, + Unexpected } -char[] prog = "./Dang"; - void main(char[][] args) { - auto cPath = FilePath("tests"); + foreach (arg ; args[1..$]) + options ~= arg; - ubyte success_success, success_failure, failure_failure, failure_success; + scope scan = new FileScan; +// scope regex = new Regex(valid_filenames); // DMD FAILS!! ?? + // Return true for files/folders to include + bool filter(FilePath p, bool isDir) + { + if (isDir) + return p.name[0] != '.'; + else + return p.ext == "d" ; //&& regex.test(p.name); + } + scan.sweep(test_folder, &filter, true); + FilePath[] files = scan.files; + int total_tests = files.length; - foreach( path ; cPath.toList((FilePath path, bool isFolder){return isFolder;})) + // Sort the result by the chosen function - default is the full path + sort(files, sortBy); + + int[TestResult.max + 1] results = 0; + foreach (i, ref test; files) { - Stdout(path.name)(":").newline; - auto paths = path.toList( - (FilePath path, bool isFolder) - { - if(path.ext == "d" && path.name[0] != '.') - return true; - return false; - }); - sort(paths, (FilePath a, FilePath b) { return a.name < b.name; }); - foreach (p ; paths) + begin_test(i + 1, total_tests, test.name); + TestResult res = run_test(test); + results[res] += 1; + end_test(); + } + Stdout.format("\r{,80}\r", " "); + Stdout.newline; + int good = TestResult.Expected; + int bad = TestResult.Unexpected; + int tests_run = results[good] + results[bad]; + Stdout.formatln("{}/{} tests failed", results[bad], tests_run); +} + +void begin_test(int number, int total_tests, char[] name) +{ + char[60] progressbar = ' '; + int progress = number*progressbar.length/total_tests; + progressbar[0 .. progress] = '='; + if(progress) + progressbar[progress-1] = '>'; + Stdout.format("\r{}% - [{}]", 1e2 * number / total_tests, progressbar); + Stdout.flush(); + //Thread.sleep(0.05); +} + +void end_test() { } + +enum { + NoFail, + CompiletimeFail, + RuntimeFail +} + +private int min(int a, int b) { return a < b? a : b; } +TestResult run_test(ref FilePath p) +{ + auto file = new FileConduit(p.toString(), FileConduit.ReadExisting); + char[256] content; + int len = file.read(content); + file.close(); + char[] line = content[0 .. min(len, content.find('\n'))]; + + bool compile = true; + int fail = NoFail; + if (line.length >= 2 && line[0 .. 2] == "//") + { + foreach (command; line[2 .. $].delimiters(",;")) { - auto test = new Test(p); - ubyte result = test.run(); - - switch(result) + switch (toLower(substitute(command, " ", ""))) { - case SuccessSuccess: - success_success++; + case "skip", "dontcompile": + compile = false; break; - case SuccessFailure: - success_failure++; + case "fail", "compilefail", + "compiletimefail", "failatcompiletime": + fail = CompiletimeFail; break; - case FailureFailure: - failure_failure++; - break; - case FailureSuccess: - failure_success++; + case "runtime", "runtimefail", "failatruntime": + fail = RuntimeFail; + Stderr("== Compiled tests will not be run! ==").newline; + return TestResult.Skipped; + default: break; } - + break; } } - Stdout().newline.newline() - ("Result:").newline() - (" - Success/Success: ")(success_success).newline() - (" - Success/Failure: ")(success_failure).newline() - (" - Failure/Failure: ")(failure_failure).newline() - (" - Failure/Success: ")(failure_success).newline; + if (compile) + { + auto o = compiler ~ options ~ p.toString; + auto process = new Process(o); + process.execute(); + auto result = process.wait(); + return resultOf(p, result.status, fail); + } + + return TestResult.Skipped; } -class Test +private TestResult resultOf(FilePath p, int result, int expected) { - enum TestValue + char[] good(char[] s) { - Success = 0, - Lexer = 2, - Parser = 3, - Gen = 4, - - Fail = 100 - } - - FilePath target; - - TestValue[int] testValues; - - public this(FilePath target) - { - this.target = target; + version (Posix) + return "\033[1;32m" ~ s ~ "\033[m"; + else + return s; } - public ubyte run() + char[] bad(char[] s) { - auto process = new Process(prog,"--gen-llvm",target.path~target.file); - - auto file = new UnicodeFile!(char)(target.path~target.file, Encoding.UTF_8); - - TestValue mode; - - char[] data = file.read; - char[][] commands = split(splitLines(data)[0], " "); - if(commands[0] == "//fail") - { - mode = TestValue.Fail; - if(commands.length > 1) - { - try - { - int i = Integer.toInt(commands[1]); - if(i in testValues) - mode = testValues[i]; - } - catch{} - } - } -/* if(data.length > 6 && data[0..6] == "//fail") - { - char[] str = data.splitLines()[0][6..$]; - - switch(toLower(trim(str))) - { - case "fail": - case "failure": - mode = 1; - break; - default: - mode = 0; - } - } -*/ - Stdout.format(" {,-25}", target.file); - - process.execute; - auto result = process.wait; - - /* - if(result.status == 0) - { - auto llvm_process = new Process("llvm-as"); - llvm_process.execute; - llvm_process.stdin.copy(process.stdout); - llvm_process.stdin.close(); - result = llvm_process.wait; - } - */ - - return resultOf(result.status, mode); + s = s ~ " - Unexpected"; + version (Posix) + return "\033[1;31m" ~ s ~ "\033[m"; + else + return s; } - private int resultOf(int status, TestValue mode) + bool unexpected = expected == 0 ? result != 0 : result == 0; + auto f = unexpected? &bad : &good; + char[] s = (result == 0)? "SUCCESS" : "FAILURE"; + // always print if unexpeted, otherwise check the settings + if (unexpected || print_expected) { - char[] good(char[] s) - { - version (Posix) - return "\033[1;32m" ~ s ~ "\033[m"; - else - return s; - } - - char[] bad(char[] s) - { - version (Posix) - return "\033[1;31m" ~ s ~ "\033[m"; - else - return s; - } - - if(status == 0) - { - if(mode == TestValue.Success) - { - Stdout(good("SUCCESS")).newline; - return SuccessSuccess; - } - if(mode == TestValue.Fail) - { - Stdout(bad("SUCCESS - Unexpected")).newline; - return FailureSuccess; - } - } - else - { - if(mode == TestValue.Fail) - { - Stdout(good("FAILURE")).newline; - return FailureFailure; - } - if(mode == TestValue.Success) - { - Stdout(bad("FAILURE - Unexpected")).newline; - return SuccessFailure; - } - } + Stdout.format("\r{,80}\r", " "); + Stdout.format(" {,-45}", p); + Stdout(f(s)).newline; } + return unexpected? TestResult.Unexpected : TestResult.Expected; } diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/class_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/class_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,35 @@ + +class A +{ + this() + { + } + + int foo() + { + return 1; + } + + int boo() + { + return 0; + } +} + +class B : A +{ + this() + { + } + + int foo() + { + return 0; + } +} + +int main() +{ + B a = new B(); + return a.foo() + a.boo(); +} diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/deref_2.d --- a/tests/sema/deref_2.d Tue Aug 12 18:19:34 2008 +0200 +++ b/tests/sema/deref_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -1,7 +1,7 @@ int main() { - int *a; - int *b; + int* a; + int* b; a = b; *a = 1; diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/deref_3.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/deref_3.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,10 @@ +int main() +{ + int* a; + int** b; + *a = 1; + *b = a; + + return *a == **b; +} + diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/function_overload_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/function_overload_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,12 @@ + + +void main() +{ + int x = 5; + foo(x); + long y = 12; + foo(y); +} + +int foo(long x); +int foo(int x); diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/public_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/public_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,27 @@ +//fail + +public struct A +{ +//static: + public void foo() + { + bar(); + } + + private void bar() + { + } + final int i; +} + +private void bar() +{ +} + +void main() +{ + A a; + a.foo(); + a.bar(); + bar(); +} diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/scope_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/scope_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,7 @@ +//fail + +void main() +{ + int x; + int x; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/scope_2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/scope_2.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,6 @@ +//fail + +void main() +{ + x = 5; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/shift_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/shift_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,6 @@ + +int main() +{ + int c; + c << 33; +} diff -r e0551773a005 -r 41ccd50e7cbc tests/sema/type_check_1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sema/type_check_1.d Tue Aug 12 18:21:06 2008 +0200 @@ -0,0 +1,7 @@ +//fail +int main() +{ + int function(int s) m; + m = &main; +} +