Add new tests for console, function, system, variable, and code flow statements

This commit is contained in:
Stone_Red
2026-03-04 14:49:54 +01:00
parent 36d8735fbb
commit a5f521912e
9 changed files with 899 additions and 56 deletions
@@ -0,0 +1,80 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
namespace YesNt.Interpreter.Tests;
[TestClass]
public class CodeFlowStatementsTests
{
[TestMethod]
public void ExitStopsExecutionTest()
{
List<string> lines =
[
"let result = before",
"exit",
"let result = after",
"${result}"
];
YesNtAssert.ContainsTerminationMessage(lines, "Planned termination by code");
}
[TestMethod]
public void AbortAllStopsExecutionTest()
{
List<string> lines =
[
"abort_all",
"let result = after",
"${result}"
];
YesNtAssert.ContainsTerminationMessage(lines, "Canceling all tasks");
}
[TestMethod]
public void ThrowTerminatesWithErrorFlagTest()
{
List<string> lines =
[
"throw bad"
];
YesNtAssert.ContainsTerminationMessage(lines, "with the message: bad");
}
[TestMethod]
public void ErrorTerminatesWithMessageTest()
{
List<string> lines =
[
"error soft"
];
YesNtAssert.ContainsTerminationMessage(lines, "with the message: soft");
}
[TestMethod]
public void MissingLabelFailsTest()
{
List<string> lines =
[
"goto nowhere"
];
YesNtAssert.ContainsTerminationMessage(lines, "Label \"nowhere\" not found");
}
[TestMethod]
public void MissingFunctionFailsTest()
{
List<string> lines =
[
"call nowhere"
];
YesNtAssert.ContainsTerminationMessage(lines, "Function \"nowhere\" not found");
}
}