-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Still working on the file system and the file system tests
- Loading branch information
Showing
31 changed files
with
756 additions
and
257 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
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
File renamed without changes.
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Project; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace ApplicationTests.InMemoryTests | ||
{ | ||
public class BasicInMemoryTest | ||
{ | ||
[Fact] | ||
public async Task CreateInMemoryProject() | ||
|
||
{ | ||
IProject project = ProjectContext.InitInMemory(); | ||
IModule module = await project.CreateModule("Test", ""); | ||
Assert.NotNull(module); | ||
IModule test = project.FindModule("Test"); | ||
Assert.NotNull(test); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateALotOfModules() | ||
|
||
{ | ||
IProject project = ProjectContext.InitInMemory(); | ||
IModule test = await project.CreateModule("Test", ""); | ||
IModule other = await project.CreateModule("Other", ""); | ||
IModule something = await project.CreateModule("Something", ""); | ||
IModule foo = await project.CreateModule("Foo", ""); | ||
IModule bar = await project.CreateModule("Bar", ""); | ||
|
||
var instance = Project.FileSystems.MemorySystem.Instance; | ||
|
||
Assert.NotNull(test); | ||
|
||
|
||
} | ||
} | ||
} |
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,81 @@ | ||
using Compiler; | ||
using Compiler.AST; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace ApplicationTests.MappingTest | ||
{ | ||
public class SimpleMapping | ||
{ | ||
[Fact] | ||
public void NameMapper() | ||
{ | ||
var code = @" | ||
type Person = | ||
FirstName: Name; | ||
alias Name = String; | ||
"; | ||
|
||
var g = new ASTGenerator(code); | ||
var nameMapper = new NameMapper(); | ||
var names = nameMapper.Map(new NameVisitor(g)); | ||
var result = nameMapper.Process(); | ||
|
||
Assert.NotNull(result); | ||
Assert.Equal(@"Person | ||
FirstName | ||
Name", result); | ||
} | ||
} | ||
|
||
public class NameMapper : IMapper<string> | ||
{ | ||
public IEnumerable<string> Result { get; private set; } | ||
|
||
public IEnumerable<string> Map<U>(VisitorBase<U> visitor) where U : IEnumerable<string> | ||
{ | ||
this.Result = visitor.Start().SelectMany(i => i); | ||
return this.Result; | ||
} | ||
|
||
public string Process() | ||
{ | ||
|
||
return String.Join(Environment.NewLine, Result); | ||
} | ||
} | ||
|
||
public class NameVisitor : VisitorDefault<IEnumerable<string>> | ||
{ | ||
public NameVisitor(ASTGenerator generator) : base(generator) { } | ||
|
||
public override IEnumerable<string> VisitASTTypeField(ASTTypeField astTypeField) | ||
{ | ||
yield return astTypeField.Name; | ||
} | ||
|
||
public override IEnumerable<string> VisitASTType(ASTType astType) | ||
{ | ||
yield return astType.Name; | ||
foreach (var field in astType.Fields) | ||
{ | ||
yield return Visit(field).First(); | ||
} | ||
} | ||
|
||
public override IEnumerable<string> VisitASTAlias(ASTAlias astAlias) | ||
{ | ||
yield return astAlias.Name; | ||
} | ||
} | ||
|
||
public interface IMapper<T> | ||
{ | ||
IEnumerable<T> Result { get; } | ||
IEnumerable<T> Map<U>(VisitorBase<U> visitor) where U: IEnumerable<T>; | ||
string Process(); | ||
} | ||
} |
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; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace CLI | ||
{ | ||
internal static class AssetHelpers | ||
{ | ||
internal static string ReadAsset(string name) | ||
{ | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
var resourceName = "CLI.Assets." + name; | ||
|
||
using (var stream = assembly.GetManifestResourceStream(resourceName)) | ||
{ | ||
if (!(stream is null)) | ||
{ | ||
using (var reader = new StreamReader(stream)) | ||
{ | ||
var result = reader.ReadToEnd(); | ||
reader.Close(); | ||
reader.Dispose(); | ||
return result; | ||
} | ||
} | ||
else | ||
{ | ||
return ""; | ||
} | ||
} | ||
} | ||
|
||
internal static void WriteAsset(string path, string content) | ||
{ | ||
File.WriteAllText(path, content); | ||
} | ||
|
||
internal static void ReadAndWriteAsset(string assetName, string outPath) | ||
{ | ||
var outName = System.IO.Path.GetFullPath(assetName, outPath); | ||
AssetHelpers.WriteAsset(outName, AssetHelpers.ReadAsset(assetName)); | ||
} | ||
} | ||
} |
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
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.