forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some globalization and culture plugs. Also added string and str…
…uct tests.
- Loading branch information
1 parent
d790a6a
commit 815f2f7
Showing
13 changed files
with
262 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
using Cosmos.Debug.Kernel; | ||
using Cosmos.TestRunner; | ||
|
||
namespace Cosmos.Compiler.Tests.Bcl.System | ||
{ | ||
public static class StringTest | ||
{ | ||
static Debugger mDebugger = new Debugger("Tests", "String Tests"); | ||
|
||
public static void Execute() | ||
{ | ||
Assert.IsTrue(("a" + "b") == "ab", "concatting 2 string using + doesn't work"); | ||
Assert.IsTrue(("a" + 'b') == "ab", "concatting 1 string and 1 character doesn't work"); | ||
Assert.IsTrue(string.Empty == "", "string.Empty == \"\""); | ||
int xResult = string.Compare("a", "a"); | ||
mDebugger.Send(xResult.ToString()); | ||
Assert.IsTrue(xResult == 0, "string.Compare(\"a\", \"a\") == 0"); | ||
|
||
Assert.IsTrue( | ||
string.Compare("abc", "abc") == 0, "string.Compare(\"abc\", \"abc\") == 0"); | ||
Assert.IsTrue(("a" + "b") == "ab", "(\"a\" + \"b\") == \"ab\""); | ||
Assert.IsTrue(("a" + 'b') == "ab", "concatting 1 string and 1 character doesn\"t work"); | ||
Assert.IsTrue(string.Concat("a", "b") == "ab", "string.Concat(\"a\", \"b\") == \"ab\""); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
source/Cosmos.Core.Plugs/System/Globalization/CompareInfoImpl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#define COSMOSDEBUG | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Cosmos.Common; | ||
using Cosmos.Debug.Kernel; | ||
using Cosmos.IL2CPU.Plugs; | ||
|
||
namespace Cosmos.Core.Plugs.System.Globalization | ||
{ | ||
[Plug(Target = typeof(CompareInfo))] | ||
public static class CompareInfoImpl | ||
{ | ||
static Debugger mDebugger = new Debugger("Core", "Compare Info Plug"); | ||
|
||
public static void Ctor(CompareInfo aThis, CultureInfo culture) | ||
{ | ||
mDebugger.SendInternal("CompareInfo::Ctor"); | ||
} | ||
|
||
public static int Compare(CompareInfo aThis, string aString1, string aString2, CompareOptions aOptions) | ||
{ | ||
#warning TODO: Implement CompareOptions | ||
mDebugger.SendInternal("CompareInfo.Compare"); | ||
return StringHelper.Compare(aString1, 0, aString2, 0, aString1.Length, aString2.Length); | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
source/Cosmos.Core.Plugs/System/Globalization/CultureInfoImpl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Globalization; | ||
|
||
using Cosmos.Debug.Kernel; | ||
using Cosmos.IL2CPU.Plugs; | ||
|
||
namespace Cosmos.Core.Plugs.System.Globalization | ||
{ | ||
[Plug(Target = typeof(CultureInfo))] | ||
public static class CultureInfoImpl | ||
{ | ||
static Debugger mDebugger = new Debugger("Core", "Compare Info Plug"); | ||
|
||
public static void Ctor(CultureInfo aThis, string name, bool useUserOverride) | ||
{ | ||
} | ||
|
||
public static bool get_UseUserOverride(CultureInfo aThis) | ||
{ | ||
return false; | ||
} | ||
|
||
public static CultureInfo get_CurrentCulture() | ||
{ | ||
return new CultureInfo("en-us"); | ||
} | ||
|
||
public static CultureInfo get_InvariantCulture() | ||
{ | ||
return null; | ||
} | ||
|
||
public static void CCtor() | ||
{ | ||
} | ||
|
||
public static CultureInfo GetCultureInfo(string aName) | ||
{ | ||
return null; | ||
} | ||
|
||
public static bool Equals(CultureInfo aThis, object aThat) | ||
{ | ||
return ReferenceEquals(aThis, aThat); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
source/Cosmos.Core.Plugs/System/Globalization/NumberFormatInfoImpl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Globalization; | ||
|
||
using Cosmos.IL2CPU.Plugs; | ||
|
||
namespace Cosmos.Core.Plugs.System.Globalization | ||
{ | ||
[Plug(Target = typeof(NumberFormatInfo))] | ||
public static class NumberFormatInfoImpl | ||
{ | ||
public static NumberFormatInfo GetInstance(IFormatProvider aProvider) | ||
{ | ||
return null; | ||
} | ||
|
||
|
||
public static NumberFormatInfo get_CurrentInfo() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
source/Cosmos.Core.Plugs/System/Globalization/TextInfoImpl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Cosmos.Common; | ||
using Cosmos.Debug.Kernel; | ||
using Cosmos.IL2CPU.Plugs; | ||
|
||
namespace Cosmos.Core.Plugs.System.Globalization | ||
{ | ||
[Plug(Target = typeof(TextInfo))] | ||
public static class TextInfoImpl | ||
{ | ||
static Debugger mDebugger = new Debugger("Core", "Compare Info Plug"); | ||
|
||
public static void Ctor(TextInfo aThis, object cultureData) | ||
{ | ||
} | ||
|
||
public static int InternalCompareStringOrdinalIgnoreCase(string aString1, int aIndex1, string aString2, int aIndex2, int aLength1, int aLength2) | ||
{ | ||
mDebugger.SendInternal("InternalCompareStringOrdinalIgnoreCase"); | ||
mDebugger.SendInternal(aString1); | ||
mDebugger.SendInternal(aString2); | ||
|
||
string xString1 = aString1.ToLower(); | ||
string xString2 = aString2.ToLower(); | ||
return StringHelper.Compare(xString1, aIndex1, xString2, aIndex2, aLength1, aLength2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.