diff --git a/Tests/Cosmos.Compiler.Tests.Exceptions/AssemblyInfo.cs b/Tests/Cosmos.Compiler.Tests.Exceptions/AssemblyInfo.cs new file mode 100644 index 000000000..6848b03ad --- /dev/null +++ b/Tests/Cosmos.Compiler.Tests.Exceptions/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System; +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Package Name")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Company")] +[assembly: AssemblyProduct("Package Name")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: NeutralResourcesLanguage("en-US")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + + + diff --git a/Tests/Cosmos.Compiler.Tests.Exceptions/Cosmos.Compiler.Tests.Exceptions.csproj b/Tests/Cosmos.Compiler.Tests.Exceptions/Cosmos.Compiler.Tests.Exceptions.csproj new file mode 100644 index 000000000..a69558c26 --- /dev/null +++ b/Tests/Cosmos.Compiler.Tests.Exceptions/Cosmos.Compiler.Tests.Exceptions.csproj @@ -0,0 +1,59 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {9DF5C0A9-B91C-4647-B939-E47513743A0C} + Library + Properties + Cosmos.Compiler.Tests.Exceptions + Cosmos.Compiler.Tests.Exceptions + 512 + v4.5 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + {E6D3B644-C487-472D-A978-C1A82D0C099B} + Cosmos.TestRunner.TestController + + + + + \ No newline at end of file diff --git a/Tests/Cosmos.Compiler.Tests.Exceptions/Cosmos.Compiler.Tests.ExceptionsBoot.Cosmos b/Tests/Cosmos.Compiler.Tests.Exceptions/Cosmos.Compiler.Tests.ExceptionsBoot.Cosmos new file mode 100644 index 000000000..b135511d3 --- /dev/null +++ b/Tests/Cosmos.Compiler.Tests.Exceptions/Cosmos.Compiler.Tests.ExceptionsBoot.Cosmos @@ -0,0 +1,47 @@ + + + + Debug + 2.0 + {85e13410-c85a-4b0c-bee5-f9a120ecc94e} + false + Cosmos.Compiler.Tests.ExceptionsBoot + elf + v4.5 + + + VMware + + true + Source + User + False + false + Player + bin\Debug\ + Cosmos.Compiler.Tests.ExceptionsBoot + Use VMware Player or Workstation to deploy and debug. + ISO + VMware + Pipe: Cosmos\Serial + + + + Cosmos.Compiler.Tests.Exceptions + {9df5c0a9-b91c-4647-b939-e47513743a0c} + + + + + + + + + + \ No newline at end of file diff --git a/Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs b/Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs new file mode 100644 index 000000000..5fc61e2ea --- /dev/null +++ b/Tests/Cosmos.Compiler.Tests.Exceptions/Kernel.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Sys = Cosmos.System; + +namespace Cosmos.Compiler.Tests.Exceptions +{ + using Cosmos.TestRunner; + + public class Kernel : Sys.Kernel + { + private global::Cosmos.Debug.Kernel.Debugger mDebugger = new global::Cosmos.Debug.Kernel.Debugger("User", "Test"); + + protected override void BeforeRun() + { + Console.WriteLine("Cosmos booted successfully, now start testing"); + } + + protected override void Run() + { + mDebugger.Send("Run"); + + TestSimpleException(); + + mDebugger.Send("START: Test throw Exception() in method and catch in caller."); + try + { + TestReturnSimpleException(); + } + catch (Exception ex) + { + Console.WriteLine("Caught exception."); + mDebugger.Send("EXCEPTION: " + ex.Message); + } + finally + { + Console.WriteLine("Finally"); + mDebugger.Send("EXCEPTION: Finally"); + } + mDebugger.Send("END:"); + + mDebugger.Send("START: Test throw nested Exception() in method and catch in caller."); + try + { + TestThrowNestedException(); + } + catch (Exception ex) + { + Console.WriteLine("Caught exception."); + mDebugger.Send("EXCEPTION: " + ex.Message); + } + finally + { + Console.WriteLine("Finally"); + mDebugger.Send("EXCEPTION: Finally"); + } + mDebugger.Send("END:"); + + TestController.Completed(); + } + + private void TestSimpleException() + { + mDebugger.Send("START: Test throw Exception() in method and catch in callee."); + try + { + throw new Exception("throw new Exception()"); + } + catch (Exception ex) + { + Console.WriteLine("Caught exception."); + mDebugger.Send("EXCEPTION: " + ex.Message); + } + mDebugger.Send("END:"); + } + + private void TestReturnSimpleException() + { + throw new Exception("throw new Exception()"); + } + + private void TestThrowNestedException() + { + try + { + try + { + TestArgumentNullException(null); + } + catch (ArgumentNullException ex) + { + Console.WriteLine("Caught nested exception."); + mDebugger.Send("EXCEPTION: " + ex.Message); + } + TestReturnSimpleException(); + } + catch (Exception ex) + { + Console.WriteLine("Caught exception."); + mDebugger.Send("EXCEPTION: " + ex.Message); + } + } + + private void TestArgumentNullException(string arg) + { + if (arg == null) + { + throw new ArgumentNullException(arg, "arg can not be null."); + } + } + } +}