Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/CosmosOS/Cosmos
Browse files Browse the repository at this point in the history
# Conflicts:
#	Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs
  • Loading branch information
fanoI committed Jan 3, 2018
2 parents b337241 + 5ab50bf commit d19e3f8
Show file tree
Hide file tree
Showing 32 changed files with 1,301 additions and 391 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 @@ -153,6 +156,79 @@ Filename: "{app}\Build\Tools\nuget.exe"; Parameters: "sources Remove -Name ""Cos
Filename: "{app}\Build\Tools\VSIXBootstrapper.exe"; Parameters: "/q /u:Cosmos.VS.ProjectSystem"; StatusMsg: "Removing Visual Studio Extension: Cosmos Project System"

[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
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
}
}
}
122 changes: 121 additions & 1 deletion Tests/Cosmos.Compiler.Tests.Bcl/System/MathTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Cosmos.Compiler.Tests.Bcl.System
{
class MathTest
internal class MathTest
{
public static void Execute()
{
Expand Down Expand Up @@ -35,6 +35,126 @@ public static void Execute()
// Test with positive infinity
result = Math.Sqrt(double.PositiveInfinity);
Assert.IsTrue(double.IsPositiveInfinity(result), "Sqrt of PositiveInfinity must return PositiveInfinity");

#region Math.Exp

//Test with integer
result = Math.Exp(2);
Assert.IsTrue((result == 7.38905609893065), "e^2 is equal to 7.38905609893065");

//Test with double exponent
result = Math.Exp(1.5);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 4.48168907033806), "e^1.5 returns correct result");

result = Math.Exp(0);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 1), "e^0 gives correct result");

result = Math.Exp(1);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, Math.E), "e^1 gives correct result");

result = Math.Exp(double.PositiveInfinity);
Assert.IsTrue(result == double.PositiveInfinity, "e^Infinity gives correct result");

result = Math.Exp(double.NegativeInfinity);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "e^-Infinity gives correct result");

result = Math.Exp(double.NaN);
Assert.IsTrue(double.IsNaN(result), "e^NaN gives correct result");

result = Math.Exp(double.MaxValue);
Assert.IsTrue(double.IsPositiveInfinity(result), "e^0 gives correct result");

result = Math.Exp(double.MinValue);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "e^0 gives correct result");

#endregion Math.Exp

#region Math.Pow

//Test with integer power
result = Math.Pow(2, 2);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 4), "2^2 gives accurate result");

//Test with decimal power
result = Math.Pow(9, 0.5);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, Math.Sqrt(9)), "9^0.5 gives same answer as sqrt(9)");

//Test with negative base
result = Math.Pow(-2, 2);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 4), "Math.Pow gives correct result when raising negative number to even power");

result = Math.Pow(-2, 3);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, -8), "Math.Pow gives correct result when raising negative number to odd power");

//Test with negative power
result = Math.Pow(2, -1);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0.5), "Pow gives correct results when handling negative powers");

//Have double as base
result = Math.Pow(0.5, 2);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0.25), "Pow gives correct solution with double base");

//x = Nan
result = Math.Pow(double.NaN, 2);
Assert.IsTrue(double.IsNaN(result), "Pow gives correct solution when x is NaN");
//Y = Nan
result = Math.Pow(10, double.NaN);
Assert.IsTrue(double.IsNaN(result), "Pow gives correct solution when y is NaN");
//y = 0
result = Math.Pow(10, 0);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 1), "Pow gives correct solution when y is 0");
//x = -Inf y < 0 == 0
result = Math.Pow(double.NegativeInfinity, -2);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "Pow gives correct solution when X is -INF and y is negative");
//x = -Inf y > 0 && y is even == Inf
result = Math.Pow(double.NegativeInfinity, 2);
Assert.IsTrue(double.IsPositiveInfinity(result), "Pow gives correct solution when x is -INF and y is even");
//x is -INF and y is positive odd == -INF
result = Math.Pow(double.NegativeInfinity, 3);
Assert.IsTrue(double.IsNegativeInfinity(result), "Pow gives correct solution when x is -INF and y is odd");
//x < 0 && y is not integer or special case
result = Math.Pow(-3, 0.25);
Assert.IsTrue(double.IsNaN(result), "Pow gives correct solution when x is negative and y is non integer");
//x = -1 && y is Inf == Nan
result = Math.Pow(-1, double.PositiveInfinity);
Assert.IsTrue(double.IsNaN(result), "Pow gives correct solution when x is -1 and y is INF");
//x = -1 && y is -Inf == Nan
result = Math.Pow(-1, double.NegativeInfinity);
Assert.IsTrue(double.IsNaN(result), "Pow gives correct solution when x is -1 and y is -INF");
//-1 < x < 1 + y = -Inf
result = Math.Pow(-0.25, double.NegativeInfinity);
Assert.IsTrue(double.IsPositiveInfinity(result), "Pow gives correct solution when -1 < x < 0 and y = -INF");
result = Math.Pow(0.25, double.NegativeInfinity);
Assert.IsTrue(double.IsPositiveInfinity(result), "Pow gives correct solution when 0 < x < 1 and y = -INF");
//-1 < x < 1 + y = Inf
result = Math.Pow(-0.25, double.PositiveInfinity);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "Pow gives correct solution when -1 < x < 0 and y is INF");
result = Math.Pow(0.25, double.PositiveInfinity);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "Pow gives correct solution when 0 < x < 1 and y is INF");
//-1 > x || x > 1 + y = -Inf
result = Math.Pow(-1.5, double.NegativeInfinity);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "Pow gives correct solution when x < -1 and y is -INF");
result = Math.Pow(1.5, double.NegativeInfinity);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "Pow gives correct solution when x > 1 and y is -INF");
//-1 > x || x > 1 + y = Inf
result = Math.Pow(-1.25, double.PositiveInfinity);
Assert.IsTrue(double.IsPositiveInfinity(result), "Pow gives correct solution when -1 > x and y = INF");
result = Math.Pow(1.25, double.PositiveInfinity);
Assert.IsTrue(double.IsPositiveInfinity(result), "Pow gives correct solution when x > 1 and y = INF");
//x = 0 y > 0
result = Math.Pow(0, 2);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "Pow gives correct solution when x = 0 any y > 0 ");
//x = 0 y < 0
result = Math.Pow(0, -3);
Assert.IsTrue(double.IsPositiveInfinity(result), "Pow gives correct solution when x is 0 and y < 0 ");
//x = inf y < 0
result = Math.Pow(double.PositiveInfinity, -5);
Assert.IsTrue(EqualityHelper.DoublesAreEqual(result, 0), "Pow gives correct solution when x is INF and y < 0 ");
//x = inf y > 0
result = Math.Pow(double.PositiveInfinity, 5);
Assert.IsTrue(double.IsPositiveInfinity(result), "Pow gives correct solution when x is INF and y > 0 ");

#endregion Math.Pow
}
}
}
37 changes: 33 additions & 4 deletions Tests/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Cosmos.Compiler.Tests.Bcl.Helper;
using Cosmos.TestRunner;

namespace Cosmos.Compiler.Tests.Bcl.System
{
class SingleTest
internal class SingleTest
{
/* The single== equality operator is so imprecise to not be really ever useful we should be happy if the two values are "similar" */

private static bool SinglesAreEqual(Single left, Single right)
{
// Define the tolerance for variation in their values
Single difference = (Single) Math.Abs(left * .00001);
Single difference = (Single)Math.Abs(left * .00001);

if (Math.Abs(left - right) <= difference)
return true;
Expand Down Expand Up @@ -62,7 +64,7 @@ public static void Execute()
expectedResult = "-42.42";

Assert.IsTrue((result == expectedResult), "Single.ToString of negative number doesn't work");

/* A big value (to be correct toString should convert it in scientific notation) */
value = 9223372036854775808f;

Expand All @@ -73,7 +75,7 @@ public static void Execute()

/* OK now a normal value */
value = 42.42F; // It exists Single.MaxValue but it is a too big value an can be represented only on Scientific notation but then how to confront with a String?

result = value.ToString();
expectedResult = "42.42";

Expand Down Expand Up @@ -206,6 +208,33 @@ public static void Execute()
value = 42.0f;
valueNegated = -value;
Assert.IsTrue((SinglesAreEqual(valueNegated, -42.0f)), "(float) negation of positive float doesn't work");

#region Parsing

value = float.Parse("0.4");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 0.4), "simple parsing of float works");

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

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

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

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

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

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

Assert.IsTrue(float.TryParse("2.3", out value), " float TryParse returns true when it works");
Assert.IsTrue(EqualityHelper.DoublesAreEqual(value, 2.3), "float TryParse returns correct result when it works");

#endregion Parsing
}
}
}
Loading

0 comments on commit d19e3f8

Please sign in to comment.