Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/CosmosOS/Cosmos into proj…
Browse files Browse the repository at this point in the history
…ect-system
  • Loading branch information
jp2masa committed Jan 7, 2018
2 parents 8a6aa9f + eafd38e commit 280defa
Show file tree
Hide file tree
Showing 80 changed files with 5,932 additions and 1,679 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CosmosOS is a volunteer effort. We encourage you to pitch in. Join the team!
- Please be sure to install the [EditorConfig](https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328). This ensures your pull requests meet the required formatting and conventions. [See here](https://github.com/CosmosOS/Cosmos/wiki/FAQ#what-is-this-editorconfig-file-and-how-do-i-use-it) for more info.

Want to get started contributing to Cosmos? Check out the open issues page:
- [High priority](https://github.com/CosmosOS/Cosmos/issues?q=is%3Aopen+is%3Aissue+label%3Apriority_high)
- [Medium priority](https://github.com/CosmosOS/Cosmos/labels/priority_medium)
- [High priority](https://github.com/CosmosOS/Cosmos/labels/Priority%3A%20High)
- [Medium priority](https://github.com/CosmosOS/Cosmos/labels/Priority%3A%20Medium)


Thanks!
Expand Down
78 changes: 77 additions & 1 deletion Setup/Cosmos.iss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ FlatComponentsList=False
AlwaysShowComponentsList=False
ShowComponentSizes=False
LicenseFile=LICENSE.txt
DisableDirPage=yes
DisableDirPage=no

[Messages]
SelectDirDesc=If the user installing the Cosmos User Kit is not the admin. Please choose the corresponding AppData/Roaming directory.

[Dirs]
Name: {app}; Flags: uninsalwaysuninstall
Expand Down Expand Up @@ -157,6 +160,79 @@ Filename: "{app}\Build\Tools\VSIXBootstrapper.exe"; Parameters: "/q /u:Cosmos.VS
Filename: "{app}\Build\Tools\VSIXBootstrapper.exe"; Parameters: "/q /u:Cosmos.VS.DebugEngine"; StatusMsg: "Removing Visual Studio Extension: Cosmos Debug Engine"

[Code]
function IsAppRunning(const FileName: string): Boolean;
var
FWMIService: Variant;
FSWbemLocator: Variant;
FWbemObjectSet: Variant;
begin
Result := false;
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
Result := (FWbemObjectSet.Count > 0);
FWbemObjectSet := Unassigned;
FWMIService := Unassigned;
FSWbemLocator := Unassigned;
end;
function IsAppRunningWithResponse(const FileName: string): Boolean;
var
Retry: Integer;
begin
Result := IsAppRunning(FileName);
if Result then
MsgBox(FileName + ' is running. Please close the application before running the installer.', mbError, MB_OK);
end;
function InitializeSetup: boolean;
var
Retry: Integer;
begin
for Retry := 0 to 2 do
begin
Result := not IsAppRunningWithResponse('devenv.exe');
if not Result then
begin
continue;
end;
Result := not IsAppRunningWithResponse('VSIXInstaller.exe');
if not Result then
begin
continue;
end;
Result := not IsAppRunningWithResponse('ServiceHub.IdentityHost.exe');
if not Result then
begin
continue;
end;
Result := not IsAppRunningWithResponse('ServiceHub.VSDetouredHost.exe');
if not Result then
begin
continue;
end;
Result := not IsAppRunningWithResponse('ServiceHub.Host.Node.x86.exe');
if not Result then
begin
continue;
end;
Result := not IsAppRunningWithResponse('ServiceHub.SettingsHost.exe');
if not Result then
begin
continue;
end;
Result := not IsAppRunningWithResponse('ServiceHub.Host.CLR.x86.exe');
if not Result then
begin
continue;
end
else
begin
break;
end;
end;
end;
function ExecWithResult(const Filename, Params, WorkingDir: String; const ShowCmd: Integer;
const Wait: TExecWait; var ResultCode: Integer; var ResultString: AnsiString): Boolean;
var
Expand Down
11 changes: 11 additions & 0 deletions Test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\sou
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Compiler.Tests.TypeSystem", "Tests\Cosmos.Compiler.Tests.TypeSystem\Cosmos.Compiler.Tests.TypeSystem.csproj", "{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Kernel.Tests.Fat2", "Tests\Cosmos.Kernel.Tests.Fat2\Cosmos.Kernel.Tests.Fat2.csproj", "{D4B1618A-3653-43CD-B617-20482B12712B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -589,6 +591,14 @@ Global
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Release|Any CPU.Build.0 = Release|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Release|x86.ActiveCfg = Release|Any CPU
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Release|x86.Build.0 = Release|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Debug|x86.ActiveCfg = Debug|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Debug|x86.Build.0 = Debug|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Release|Any CPU.Build.0 = Release|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Release|x86.ActiveCfg = Release|Any CPU
{D4B1618A-3653-43CD-B617-20482B12712B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -663,6 +673,7 @@ Global
{FF46829E-B612-4D36-80BE-ED04521AD91A} = {E9CD521E-C386-466D-B5F7-A5EB19A61625}
{D0EABA08-88C9-4F7C-BCA9-361B58B20D67} = {E9CD521E-C386-466D-B5F7-A5EB19A61625}
{D21A7C6C-A696-4EC3-84EB-70700C1E3B34} = {ECEA7778-E786-4317-90B9-A2D4427CB91C}
{D4B1618A-3653-43CD-B617-20482B12712B} = {29EEC029-6A2B-478A-B6E5-D63A91388ABA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4418C803-277E-448F-A0A0-52788FA215AD}
Expand Down
38 changes: 38 additions & 0 deletions Tests/Cosmos.Compiler.Tests.Bcl/Helper/EqualityHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,43 @@ public static bool DoublesAreEqual(double left, double right)
else
return false;
}

/// <summary>
/// Utility method to test Byte[] equality.
/// </summary>
/// <param name="a1">Byte array.</param>
/// <param name="a2">Byte array.</param>
/// <returns>True if the elements in the arrays are equal otherwise false.</returns>
public static bool ByteArrayAreEquals(byte[] a1, byte[] a2)
{
if (ReferenceEquals(a1, a2))
{
//mDebugger.Send("a1 and a2 are the same Object");
return true;
}

if (a1 == null || a2 == null)
{
//mDebugger.Send("a1 or a2 is null so are different");
return false;
}

if (a1.Length != a2.Length)
{
//mDebugger.Send("a1.Length != a2.Length so are different");
return false;
}

for (int i = 0; i < a1.Length; i++)
{
if (a1[i] != a2[i])
{
//mDebugger.Send("In position " + i + " a byte is different");
return false;
}
}

return true;
}
}
}
1 change: 1 addition & 0 deletions Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected override void Run()
BitConverterTest.Execute();
UnsafeCodeTest.Execute();
DelegatesTest.Execute();
EncodingTest.Execute();
RandomTests.Execute();

System.Collections.Generic.ListTest.Execute();
Expand Down
25 changes: 25 additions & 0 deletions Tests/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,31 @@ public static void Execute()
value = 42.0;
valueNegated = -value;
Assert.IsTrue((EqualityHelper.DoublesAreEqual(valueNegated, -42.0f)), "(double) negation of positive double doesn't work");

#region Parsing
value = double.Parse("0.4");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 0.4), "simple parsing of double works");

value = double.Parse("+0.3");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 0.3), "parsing of double with positive sign works!");

value = double.Parse("-0.4");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, -0.4), "parsing of negative double works!");

value = double.Parse(" 0.7 ");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 0.7), "double parsing ignores leading and trailing whitespaces");

value = double.Parse("0.4E1");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 4), "double parsing takes in account E");

value = double.Parse("0.4E-1");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 0.04), "double parsing works with negative E");

Assert.IsFalse(double.TryParse("asd4", out value), "double TryParse returns false when it fails");

Assert.IsTrue(double.TryParse("2.3", out value), "double TryParse returns true when it works");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 2.3), "double TryParse returns correct result when it works");
#endregion
}
}
}
115 changes: 115 additions & 0 deletions Tests/Cosmos.Compiler.Tests.Bcl/System/EncodingTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.TestRunner;
using Cosmos.Compiler.Tests.Bcl.Helper;

namespace Cosmos.Compiler.Tests.Bcl.System
{
class EncodingTest
{
static byte[] UTF8EnglishText = new byte[] { 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x73, 0x20, 0x69, 0x73, 0x20,
0x77, 0x6F, 0x6E, 0x64, 0x65, 0x72, 0x66, 0x75, 0x6C, 0x21 };
static byte[] UTF8ItalianText = new byte[] { 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x73, 0x20, 0xC3, 0xA8, 0x20,
0x66, 0x61, 0x6E, 0x74, 0x61, 0x73, 0x74, 0x69, 0x63, 0x6F,
0x21 };
static byte[] UTF8SpanishText = new byte[] { 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x73, 0x20, 0x65, 0x73, 0x20,
0x67, 0x65, 0x6E, 0x69, 0x61, 0x6C, 0x21 };
static byte[] UTF8GermanicText = new byte[] { 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x73, 0x20, 0x69, 0x73, 0x74,
0x20, 0x67, 0x72, 0x6F, 0xC3, 0x9F, 0x61, 0x72, 0x74, 0x69,
0x67, 0x21 };
static byte[] UTF8GreekText = new byte[] { 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x73, 0x20, 0xCE, 0xB5, 0xCE,
0xAF, 0xCE, 0xBD, 0xCE, 0xB1, 0xCE, 0xB9, 0x20, 0xCF, 0x85,
0xCF, 0x80, 0xCE, 0xAD, 0xCF, 0x81, 0xCE, 0xBF, 0xCF, 0x87,
0xCE, 0xBF, 0xCF, 0x82, 0x21 };
static byte[] UTF8JapanaseText = new byte[] { 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x73, 0x20, 0xE7, 0xB4, 0xA0,
0xE6, 0x99, 0xB4, 0xE3, 0x82, 0x89, 0xE3, 0x81, 0x97, 0xE3,
0x81, 0x84, 0xE3, 0x81, 0xA7, 0xE3, 0x81, 0x99, 0x21 };
static byte[] UTF8GothicText = new byte[] { 0xF0, 0x90, 0x8D, 0x88 };

public static void Execute()
{
//CosmosUTF8Encoding Encoder = new CosmosUTF8Encoding();
//Encoder Encoder = new UTF8Encoding().GetEncoder();
Encoding Encoder = new UTF8Encoding();
string text;
byte[] result;
byte[] expectedResult;

text = "Cosmos is wonderful!";
result = Encoder.GetBytes(text);
expectedResult = UTF8EnglishText;
Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "UTF8 Encoding of English text failed byte arrays different");

text = "Cosmos è fantastico!";
result = Encoder.GetBytes(text);
expectedResult = UTF8ItalianText;
Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "UTF8 Encoding of Italian text failed byte arrays different");

text = "Cosmos es genial!";
result = Encoder.GetBytes(text);
expectedResult = UTF8SpanishText;
Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "UTF8 Encoding of Spanish text failed byte arrays different");

text = "Cosmos ist großartig!";
result = Encoder.GetBytes(text);
expectedResult = UTF8GermanicText;
Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "UTF8 Encoding of Germanic text failed byte arrays different");

text = "Cosmos είναι υπέροχος!";
result = Encoder.GetBytes(text);
expectedResult = UTF8GreekText;
Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "UTF8 Encoding of Greek text failed byte arrays different");

text = "Cosmos 素晴らしいです!";
result = Encoder.GetBytes(text);
expectedResult = UTF8JapanaseText;
Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "UTF8 Encoding of Japanese text failed byte arrays different");

/* This the only case on which UFT-16 must use a surrugate pairs... it is a Gothic letter go figure! */
text = "𐍈";
result = Encoder.GetBytes(text);
expectedResult = UTF8GothicText;
Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "UTF8 Encoding of Gothic text failed byte arrays different");

/* Now we do the other way: we have a UFT8 byte array and try to convert it in a UFT16 String */
string expectedText;

text = Encoder.GetString(UTF8EnglishText);
expectedText = "Cosmos is wonderful!";
Assert.IsTrue((text == expectedText), "UTF8 Decoding of English text failed strings different");

text = Encoder.GetString(UTF8ItalianText);
expectedText = "Cosmos è fantastico!";
Assert.IsTrue((text == expectedText), "UTF8 Decoding of Italian text failed strings different");

text = Encoder.GetString(UTF8SpanishText);
expectedText = "Cosmos es genial!";
Assert.IsTrue((text == expectedText), "UTF8 Decoding of Spanish text failed strings different");

text = Encoder.GetString(UTF8GermanicText);
expectedText = "Cosmos ist großartig!";
Assert.IsTrue((text == expectedText), "UTF8 Decoding of Germanic text failed strings different");

text = Encoder.GetString(UTF8GreekText);
expectedText = "Cosmos είναι υπέροχος!";
Assert.IsTrue((text == expectedText), "UTF8 Decoding of Greek text failed strings different");

text = Encoder.GetString(UTF8JapanaseText);
expectedText = "Cosmos 素晴らしいです!";
Assert.IsTrue((text == expectedText), "UTF8 Decoding of Japanese text failed strings different");

text = Encoder.GetString(UTF8GothicText);
expectedText = "𐍈";
Assert.IsTrue((text == expectedText), "UTF8 Decoding of Gothic text failed strings different");

/* But this not work is searching '437' in some native Windows tables, we need plugs for this sadly! */
//Encoder = Encoding.GetEncoding(437);
//text = "àèìòù";
//result = Encoder.GetBytes(text);
//expectedResult = new byte[] { 0x85, 0x8A, 0x8D, 0x95, 0x97 };
//Assert.IsTrue(EqualityHelper.ByteArrayAreEquals(result, expectedResult), "CP437 Encoding of accents text failed byte arrays different");

}
}
}
Loading

0 comments on commit 280defa

Please sign in to comment.