-
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.
- Loading branch information
Showing
8 changed files
with
262 additions
and
42 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
59 changes: 59 additions & 0 deletions
59
SocietalConstructionToolTests/Snapshots/SplitFileTests/MultiFileOne.verified.txt
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,59 @@ | ||
namespace SctGenerated | ||
{ | ||
using Sct.Runtime; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public class GlobalClass | ||
{ | ||
public class __sct_Town : BaseAgent | ||
{ | ||
private int __sct_id { get => Fields["__sct_id"]; set => Fields["__sct_id"] = value; } | ||
private int __sct_space { get => Fields["__sct_space"]; set => Fields["__sct_space"] = value; } | ||
|
||
public __sct_Town(String state, IDictionary<String, dynamic> fields) : base(state, fields) | ||
{ | ||
} | ||
|
||
private bool __sct_Growing(IRuntimeContext ctx) | ||
{ | ||
if (1 != 0) | ||
{ | ||
Enter(ctx, "__sct_End"); | ||
return true; | ||
} | ||
|
||
Enter(ctx, "__sct_Growing"); | ||
return true; | ||
return false; | ||
} | ||
|
||
private bool __sct_End(IRuntimeContext ctx) | ||
{ | ||
ctx.ExitRuntime(); | ||
return true; | ||
return false; | ||
} | ||
|
||
public override void Update(IRuntimeContext ctx) | ||
{ | ||
_ = State switch | ||
{ | ||
"__sct_Growing" => __sct_Growing(ctx), | ||
"__sct_End" => __sct_End(ctx)}; | ||
} | ||
} | ||
|
||
public static void __sct_Setup(IRuntimeContext ctx) | ||
{ | ||
ctx.AgentHandler.CreateAgent(new __sct_Town("__sct_Growing", new Dictionary<String, dynamic>(new KeyValuePair<String, dynamic>[] { new KeyValuePair<String, dynamic>("__sct_id", 1), new KeyValuePair<String, dynamic>("__sct_space", 50) }))); | ||
} | ||
|
||
public static void RunSimulation(IRuntimeContext ctx) | ||
{ | ||
Runtime runtime = new Runtime(); | ||
__sct_Setup(ctx); | ||
runtime.Run(ctx); | ||
} | ||
} | ||
} |
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,37 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
using Sct; | ||
|
||
namespace SocietalConstructionToolTests | ||
{ | ||
[TestClass] | ||
public class SplitFileTests : AbstractSnapshotTests | ||
{ | ||
private static new IEnumerable<string[]> Files => | ||
Directory.GetFiles(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "TestFiles", "SplitFileTests")) | ||
.Select(f => new[] { f }); | ||
|
||
|
||
[DataTestMethod] | ||
public async Task RunFiles() | ||
{ | ||
UseProjectRelativeDirectory("Snapshots/SplitFileTests"); // save snapshots here | ||
|
||
var files = GetFiles(); | ||
|
||
var (outputText, errors) = SctRunner.CompileSct(files); | ||
|
||
Assert.IsTrue(errors.Count() == 0, string.Join("\n", errors)); | ||
Assert.IsNotNull(outputText); | ||
_ = await Verify(outputText) | ||
.UseFileName(Path.GetFileNameWithoutExtension(files[0])); | ||
} | ||
|
||
// RunFiles is run for each file, and passing files to CompileSct only passes the file that triggered the test. | ||
// This method is used to get all files to pass to CompileSct. | ||
private static string[] GetFiles() | ||
{ | ||
return Files.SelectMany(f => f).ToArray(); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
SocietalConstructionToolTests/TestFiles/SplitFileTests/MultiFileOne.sct
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,5 @@ | ||
function Setup() -> void { | ||
// Create a town in the state growing with the id of 1 and space for 50 people | ||
create Town::Growing(id: 1, space: 50); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
SocietalConstructionToolTests/TestFiles/SplitFileTests/MultiFileTwo.sct
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,11 @@ | ||
class Town(int id, int space) { | ||
state Growing { | ||
if (1) { | ||
enter End; | ||
} | ||
enter Growing; | ||
} | ||
state End { | ||
exit; | ||
} | ||
} |
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