Skip to content

Commit

Permalink
Fixed keyboard interrupt, generics, and double.
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbetros committed Apr 14, 2016
1 parent 31e5c09 commit ef92828
Show file tree
Hide file tree
Showing 19 changed files with 528 additions and 204 deletions.
36 changes: 36 additions & 0 deletions Tests/Cosmos.Compiler.Tests.MethodTests/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]



Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FE8B9F39-7C96-4866-9A18-386735895CEE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cosmos.Compiler.Tests.MethodTests</RootNamespace>
<AssemblyName>Cosmos.Compiler.Tests.MethodTests</AssemblyName>
<FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Cosmos.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
<Reference Include="Cosmos.HAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
<Reference Include="Cosmos.System, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
<Reference Include="Cosmos.Debug.Kernel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="ReturnTests.cs" />
<Compile Include="Kernel.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj">
<Project>{E6D3B644-C487-472D-A978-C1A82D0C099B}</Project>
<Name>Cosmos.TestRunner.TestController</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0fee977d-ae52-4381-b513-71c5c1982ed4}</ProjectGuid>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<Name>Cosmos.Compiler.Tests.MethodTestsBoot</Name>
<BinFormat>elf</BinFormat>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Profile>Bochs</Profile>
<!-- Looks like this was a mispelled attribute. Replaced by DebugEnabled below.
<DebugEnable>true</DebugEnable>
-->
<DebugEnabled>true</DebugEnabled>
<DebugMode>Source</DebugMode>
<TraceMode>User</TraceMode>
<EnableGDB>False</EnableGDB>
<StartCosmosGDB>false</StartCosmosGDB>
<VMWareEdition>Player</VMWareEdition>
<OutputPath>bin\Debug\</OutputPath>
<Name>Cosmos.Compiler.Tests.MethodTestsBoot</Name>
<Description>Use Bochs emulator to deploy and debug.</Description>
<Deployment>ISO</Deployment>
<Launch>Bochs</Launch>
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
<VMware_Name>Cosmos.Compiler.Tests.MethodTestsBoot</VMware_Name>
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
<VMware_Deployment>ISO</VMware_Deployment>
<VMware_Launch>VMware</VMware_Launch>
<VMware_DebugEnabled>true</VMware_DebugEnabled>
<VMware_DebugMode>Source</VMware_DebugMode>
<VMware_VisualStudioDebugPort>Pipe: Cosmos\Serial</VMware_VisualStudioDebugPort>
<VMware_VMwareEdition>Player</VMware_VMwareEdition>
<VMware_OutputPath>bin\Debug\</VMware_OutputPath>
<VMware_EnableGDB>False</VMware_EnableGDB>
<VMware_StartCosmosGDB>false</VMware_StartCosmosGDB>
<Bochs_Name>Cosmos.Compiler.Tests.MethodTestsBoot</Bochs_Name>
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
<Bochs_Deployment>ISO</Bochs_Deployment>
<Bochs_Launch>Bochs</Bochs_Launch>
<Bochs_DebugEnabled>true</Bochs_DebugEnabled>
<Bochs_DebugMode>Source</Bochs_DebugMode>
<Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
<Bochs_VMwareEdition>Player</Bochs_VMwareEdition>
<Bochs_OutputPath>bin\Debug\</Bochs_OutputPath>
<Bochs_EnableGDB>False</Bochs_EnableGDB>
<Bochs_StartCosmosGDB>false</Bochs_StartCosmosGDB>
<TraceAssemblies>Cosmos</TraceAssemblies>
<Bochs_TraceAssemblies>Cosmos</Bochs_TraceAssemblies>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include=".\Cosmos.Compiler.Tests.MethodTests.csproj">
<Name>Cosmos.Compiler.Tests.MethodTests</Name>
<Project>{fe8b9f39-7c96-4866-9a18-386735895cee}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983" />
<Reference Include="Cosmos.System.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983" />
<Reference Include="Cosmos.Debug.Kernel.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983" />
</ItemGroup>
<!--<ItemGroup>
<Content Include="Cosmos.bxrc">
<SubType>Content</SubType>
</Content>
</ItemGroup>-->
<Import Project="$(MSBuildExtensionsPath)\Cosmos\Cosmos.targets" />
</Project>
30 changes: 30 additions & 0 deletions Tests/Cosmos.Compiler.Tests.MethodTests/Kernel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.TestRunner;
using Sys = Cosmos.System;

namespace Cosmos.Compiler.Tests.MethodTests
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
}

protected override void Run()
{
try
{
ReturnTests.Execute();
TestController.Completed();
}
catch (Exception E)
{
Console.WriteLine("Exception");
Console.WriteLine(E.ToString());
}
}
}
}
144 changes: 144 additions & 0 deletions Tests/Cosmos.Compiler.Tests.MethodTests/ReturnTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Cosmos.TestRunner;

namespace Cosmos.Compiler.Tests.MethodTests
{
public static class ReturnTests
{
public static void Execute()
{
int a = 0x1FFFFFFF;
Assert.IsTrue(a == TestInt(a), "Int return value failed.");
Assert.IsTrue(a == TestRefInt(ref a), "Int& return value failed.");

uint b = 0x1FFFFFFF;
Assert.IsTrue(b == TestUInt(b), "UInt return value failed.");
Assert.IsTrue(b == TestRefUInt(ref b), "UInt& return value failed.");

long c = 0x1FFFFFFF0FFFFFFF;
Assert.IsTrue(c == TestLong(c), "Long return value failed.");
Assert.IsTrue(c == TestRefLong(ref c), "Long& return value failed.");

ulong d = 0x0FFFFFFF1FFFFFFF;
Assert.IsTrue(d == TestULong(d), "ULong return value failed.");
Assert.IsTrue(d == TestRefULong(ref d), "ULong& return value failed.");

float e = 42.42f;
Assert.IsTrue(e == TestSingle(e), "Single return value failed.");
Assert.IsTrue(e == TestRefSingle(ref e), "Single& return value failed.");

double f = 42.42;
Assert.IsTrue(f == TestDouble(f), "Double return value failed.");
Assert.IsTrue(f == TestRefDouble(ref f), "Double& return value failed.");

string h = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Assert.IsTrue(h == TestString(h), "String return value failed.");
Assert.IsTrue(h == TestRefString(ref h), "String& return value failed.");

char i = 'A';
Assert.IsTrue(i == TestChar(i), "Char return value failed.");
Assert.IsTrue(i == TestRefChar(ref i), "Char& return value failed.");
}

private static int TestRefInt(ref int a)
{
int b = a;
return b;
}

private static uint TestRefUInt(ref uint a)
{
uint b = a;
return b;
}

private static long TestRefLong(ref long a)
{
long b = a;
return b;
}

private static ulong TestRefULong(ref ulong a)
{
ulong b = a;
return b;
}

private static float TestRefSingle(ref float a)
{
float b = a;
return b;
}

private static double TestRefDouble(ref double a)
{
double b = a;
return b;
}

private static string TestRefString(ref string a)
{
string b = a;
return b;
}

private static char TestRefChar(ref char a)
{
char b = a;
return b;
}

private static int TestInt(int a)
{
int b = a;
return b;
}

private static uint TestUInt(uint a)
{
uint b = a;
return b;
}

private static long TestLong(long a)
{
long b = a;
return b;
}

private static ulong TestULong(ulong a)
{
ulong b = a;
return b;
}

private static float TestSingle(float a)
{
float b = a;
return b;
}

private static double TestDouble(double a)
{
double b = a;
return b;
}

private static string TestString(string a)
{
string b = a;
return b;
}

private static char TestChar(char a)
{
char b = a;
return b;
}
}
}
4 changes: 4 additions & 0 deletions Tests/Cosmos.TestRunner.Core/Cosmos.TestRunner.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
<Project>{bdc011be-6041-4a58-a6e7-0f592e78cb27}</Project>
<Name>Cosmos.Compiler.Tests.Interfaces.Kernel</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos.Compiler.Tests.MethodTests\Cosmos.Compiler.Tests.MethodTests.csproj">
<Project>{fe8b9f39-7c96-4866-9a18-386735895cee}</Project>
<Name>Cosmos.Compiler.Tests.MethodTests</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos.Compiler.Tests.SimpleWriteLine.Kernel\Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.csproj">
<Project>{57045fe8-b0fe-4fc1-810f-7c3914aef1de}</Project>
<Name>Cosmos.Compiler.Tests.SimpleWriteLine.Kernel</Name>
Expand Down
3 changes: 2 additions & 1 deletion Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void Apply(Engine engine)
//engine.RunIL2CPUInProcess = true;
engine.TraceAssembliesLevel = TraceAssemblies.User;
engine.EnableStackCorruptionChecks = true;
engine.StackCorruptionChecksLevel = StackCorruptionDetectionLevel.MethodFooters;
engine.StackCorruptionChecksLevel = StackCorruptionDetectionLevel.AllInstructions;

//engine.RunWithGDB = true;
//engine.StartBochsDebugGui = true;
Expand All @@ -42,6 +42,7 @@ public static void Apply(Engine engine)
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.Kernel).Assembly.Location);
//engine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location);
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.Exceptions.Kernel).Assembly.Location);
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.MethodTests.Kernel).Assembly.Location);

// Known bugs, therefore disabled for now:
//engine.AddKernel(typeof(BoxingTests.Kernel).Assembly.Location);
Expand Down
1 change: 1 addition & 0 deletions Tests/Cosmos.TestRunner.Core/TestKernelSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static IEnumerable<Type> GetStableKernelTypes()
yield return typeof(SimpleStructsAndArraysTest.Kernel);
yield return typeof(Cosmos.Compiler.Tests.Exceptions.Kernel);
yield return typeof(Cosmos.Compiler.Tests.LinqTests.Kernel);
yield return typeof(Cosmos.Compiler.Tests.MethodTests.Kernel);
}
}
}
Loading

0 comments on commit ef92828

Please sign in to comment.