Skip to content

Commit

Permalink
Behaviour tests (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
HPT-I authored Apr 25, 2024
1 parent b1023e7 commit d775f03
Show file tree
Hide file tree
Showing 32 changed files with 2,306 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public override void ExitArgs_def([NotNull] SctParser.Args_defContext context)
var @params = context.ID().Select(id => TranslatorUtils.GetMangledName(id.GetText()))
.Zip(context.type(), (id, type) =>
SyntaxFactory.Parameter(id) // set name
.WithType(SyntaxFactory.ParseTypeName(type.GetText())) // set type
.WithType(TypeTable.GetTypeNode(type.GetText())) // set type
);

// add to parameter list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,6 @@ private static BracketedArgumentListSyntax CreateBracketedArgumentList(string na
/// </summary>
/// <param name="expression">Expression to be compared</param>
/// <returns>expression != 0</returns>
public static BinaryExpressionSyntax IntToBool(ExpressionSyntax expression) => SyntaxFactory.BinaryExpression(SyntaxKind.NotEqualsExpression, expression, SctFalse);
public static BinaryExpressionSyntax IntToBool(ExpressionSyntax expression) => SyntaxFactory.BinaryExpression(SyntaxKind.NotEqualsExpression, SyntaxFactory.ParenthesizedExpression(expression), SctFalse);
}
}
2 changes: 1 addition & 1 deletion SocietalConstructionTool/Compiler/TypeTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class TypeTable
public static SctType Ok => Types["ok"];
private static readonly Dictionary<string, SctType> Types = new()
{
{ "int", new SctType(typeof(int), "int") },
{ "int", new SctType(typeof(long), "int") },
{ "float", new SctType(typeof(double), "float") },
{ "void", new SctType(typeof(void), "void")},
{ "Predicate", new SctType(typeof(QueryPredicate), "Predicate") },
Expand Down
6 changes: 2 additions & 4 deletions SocietalConstructionToolTests/BehaviourTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ public async Task RunFile(string file)
JsonStringLogger logger = new();

var errors = SctRunner.CompileAndRun([file], logger);
if (errors.Any())
{
throw new InvalidOperationException("Tried to run code with errors" + string.Join('\n', errors));
}

Assert.IsFalse(errors.Any(), "Tried to run code with errors" + string.Join('\n', errors));

_ = await Verify(logger.Output)
.UseFileName(Path.GetFileNameWithoutExtension(file));
Expand Down
Loading

0 comments on commit d775f03

Please sign in to comment.