Skip to content

Commit

Permalink
Added the concept of Encoding to the Console for now ASCII (default) …
Browse files Browse the repository at this point in the history
…and CP437 are supported (for others as CP858 I think it is needed to change font too)

- moved EncodingTest on Text subdir
- added ConsoleTest (not enabled by default)
- removed ASCIIEncodingImpl (it was not needed)
- Made plugs of Console better and added plugs for formatted versions
- Removed code to test Hashtable, Hashtable it will be a separate PR
  • Loading branch information
fanoI committed Jan 27, 2018
1 parent c50b581 commit 4a990ac
Show file tree
Hide file tree
Showing 23 changed files with 562 additions and 1,253 deletions.
11 changes: 11 additions & 0 deletions Test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Compiler.Tests.TypeS
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
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTest", "Tests\ConsoleTest\ConsoleTest.csproj", "{7A06CD95-A1D3-4989-A9F2-4088C27F8752}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -609,6 +611,14 @@ Global
{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
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Debug|x86.ActiveCfg = Debug|Any CPU
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Debug|x86.Build.0 = Debug|Any CPU
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Release|Any CPU.Build.0 = Release|Any CPU
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Release|x86.ActiveCfg = Release|Any CPU
{7A06CD95-A1D3-4989-A9F2-4088C27F8752}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -685,6 +695,7 @@ Global
{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}
{7A06CD95-A1D3-4989-A9F2-4088C27F8752} = {ECEA7778-E786-4317-90B9-A2D4427CB91C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4418C803-277E-448F-A0A0-52788FA215AD}
Expand Down
60 changes: 60 additions & 0 deletions Tests/ConsoleTest/ConsoleTest.Cosmos
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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>{9246ba1f-fbdb-4b09-806a-7968bf4d3eb9}</ProjectGuid>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<Name>ConsoleTestBoot</Name>
<BinFormat>elf</BinFormat>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Profile>VMware</Profile>
<DebugEnabled>true</DebugEnabled>
<DebugMode>Source</DebugMode>
<TraceMode>User</TraceMode>
<EnableGDB>False</EnableGDB>
<StartCosmosGDB>false</StartCosmosGDB>
<VMWareEdition>Player</VMWareEdition>
<OutputPath>bin\Debug\</OutputPath>
<Name>ConsoleTestBoot</Name>
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
<Deployment>ISO</Deployment>
<Launch>VMware</Launch>
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\source\Cosmos.HAL\Cosmos.HAL.csproj">
<Name>Cosmos.HAL</Name>
<Project>{6a991d03-1435-4005-9809-b8bacdf3b021}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\..\source\Cosmos.System\Cosmos.System.csproj">
<Name>Cosmos.System</Name>
<Project>{3def0461-08ab-471a-8f03-a9c556652a0f}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Cosmos.TestRunner.Core\Cosmos.TestRunner.Core.csproj">
<Name>Cosmos.TestRunner.Core</Name>
<Project>{758faf24-9974-4db8-82ef-1b64daf2f0bc}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include=".\ConsoleTest.csproj">
<Name>ConsoleTest</Name>
<Project>{fb23bd72-aec3-485e-b86c-8e7db0b3bb9b}</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>
17 changes: 17 additions & 0 deletions Tests/ConsoleTest/ConsoleTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<None Remove="ConsoleTestBoot.Cosmos" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\source\Cosmos.Debug.Kernel\Cosmos.Debug.Kernel.csproj" />
<ProjectReference Include="..\..\source\Cosmos.System2\Cosmos.System2.csproj" />
<ProjectReference Include="..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj" />
</ItemGroup>

</Project>
131 changes: 131 additions & 0 deletions Tests/ConsoleTest/Kernel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using System;
using Sys = Cosmos.System;
using Cosmos.TestRunner;
using Cosmos.System.Graphics;
using System.Text;
using Cosmos.System.ExtendedASCII;
using Cosmos.System.ScanMaps;

/*
* Please note this is an atypical TestRunner:
* - no Assertion can be done
* - it cannot be executed automatically
*
* it exists to make easier tests while changing low level stuff (it would be better and faster to use the Demo kernel but
* sometimes it is a problem to make it see modifications done at low level)
*
* Remember to comment this test again on TestKernelSets.cs when you are ready to merge your modifications!
*/
namespace ConsoleTest
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Let's Test Console!");

/* This is needed to enable the Codepage based Encodings */
Encoding.RegisterProvider(CosmosEncodingProvider.Instance);
}

protected override void Run()
{
try
{
Console.Clear();

Console.WriteLine("Testing Console Enconding");

Console.WriteLine($"ConsoleInputEncoding {Console.InputEncoding.BodyName}");

Console.WriteLine($"ConsoleOutputEncoding {Console.OutputEncoding.BodyName}");

/* Let's change it in the legacy IBM437 encoding */
Console.InputEncoding = Encoding.GetEncoding(437);
Console.OutputEncoding = Encoding.GetEncoding(437);

Console.WriteLine($"ConsoleInputEncoding in now {Console.InputEncoding.BodyName}");
Console.WriteLine($"ConsoleOutputEncoding in now {Console.OutputEncoding.BodyName}");

Console.WriteLine("Let's write some accented characters: èòàùì");
Console.WriteLine("Let's print all the CP437 codepage");

Sys.Global.mDebugger.SendInternal("");

Console.Write("Ç ü é â ä à å ç ê ë è ï î ì Ä Å\n" +
"É æ Æ ô ö ò û ù ÿ Ö Ü ¢ £ ¥ ₧ ƒ\n" +
"á í ó ú ñ Ñ ª º ¿ ⌐ ¬ ½ ¼ ¡ « »\n" +
"░ ▒ ▓ │ ┤ ╡ ╢ ╖ ╕ ╣ ║ ╗ ╝ ╜ ╛ ┐\n" +
"└ ┴ ┬ ├ ─ ┼ ╞ ╟ ╚ ╔ ╩ ╦ ╠ ═ ╬ ╧\n" +
"╨ ╤ ╥ ╙ ╘ ╒ ╓ ╫ ╪ ┘ ┌ █ ▄ ▌ ▐ ▀\n" +
"α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩\n" +
"≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■ \u00A0\n");
//Console.WriteLine();

Console.WriteLine("The following line should appear as a continuos line of '─'");
Console.WriteLine("──────────────────────────────────────────────────────────");

Console.ReadKey();
Console.WriteLine("The next line should be empty");
Console.WriteLine();
Console.WriteLine("True follows...");
Console.WriteLine(true);
Console.WriteLine("The letter 'A'");
Console.WriteLine('A');
char[] charBuffer = new char[] { 'A', 'B', 'C' };
Console.WriteLine("Then ABC");
Console.WriteLine(charBuffer);
Console.WriteLine("...42.42");
Console.WriteLine(42.42);
Console.WriteLine("...42.42 (float)");
Console.WriteLine(42.42f);
Console.WriteLine("...42");
Console.WriteLine(42);
Console.WriteLine("...42 (long)");
Console.WriteLine(42L);
Console.ReadKey();
object test = "Test";
Console.WriteLine("...Test (as object)");
Console.WriteLine(test);
Console.WriteLine("The next line should be empty (null object)");
object s = null;
Console.WriteLine(s);
Console.WriteLine("...42 (uint)");
Console.WriteLine(42U);
Console.WriteLine("...42 (ulong)");
Console.WriteLine(42UL);
Console.WriteLine("...BC");
Console.WriteLine(charBuffer, 1, 2);

Console.WriteLine("Test Format arg0 {0}", "test");
Console.WriteLine("Test Format arg0 {0} arg1 {1}", "test", 42);
Console.WriteLine("Test Format arg0 {0} arg1 {1} arg2 {2}", "test", 42, 69.69);
Console.WriteLine("Test Format arg0 {0} arg1 {1} arg2 {2} arg3 {3}", "test", 42, 69.69, 25000L);
/* String.Format does not support x or X and probably neither the rest of "special" formatting */
//Console.WriteLine("Test Format (hex) {0:x}", 42);

Console.WriteLine("Layout switched to DE...");
SetKeyboardScanMap(new DE_Standard());
Console.WriteLine("Write in germanic now I'll read it with Console.ReadLine()...");

var str = Console.ReadLine();
Console.WriteLine($"You have written: {str}");

Console.WriteLine("Write in germanic now I'll read it with Console.ReadKey()...");
var character = Console.ReadKey();
Console.WriteLine($"You have written: {character.KeyChar}");

Console.WriteLine("Press any key to terminate this test...");

Console.ReadKey();
TestController.Completed();
}
catch (Exception e)
{
mDebugger.Send("Exception occurred: " + e.Message);
mDebugger.Send(e.Message);
TestController.Failed();
}
}
}
}
2 changes: 0 additions & 2 deletions Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Sys = Cosmos.System;
using Cosmos.Compiler.Tests.Bcl.System;
using Cosmos.Compiler.Tests.Bcl.System.Collections.Generic;
using Cosmos.Compiler.Tests.Bcl.System.Collections.Not_Generic;

namespace Cosmos.Compiler.Tests.Bcl
{
Expand Down Expand Up @@ -51,7 +50,6 @@ protected override void Run()
ListTest.Execute();
QueueTest.Execute();
//DictionaryTest.Execute();
HashtableTest.Execute();

TestController.Completed();
}
Expand Down

This file was deleted.

Loading

0 comments on commit 4a990ac

Please sign in to comment.