mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-08 23:43:18 +02:00
Add tests for loop exit, local/global scope, concurrency, and string escapes
This commit is contained in:
@@ -58,6 +58,48 @@ public class StringLiteralStatementsTests
|
||||
YesNtAssert.IsLastLineEqual(lines, "hello world");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EmptyStringLiteralHasLengthZeroTest()
|
||||
{
|
||||
List<string> lines =
|
||||
[
|
||||
"var x = \"\"",
|
||||
"length ${x}",
|
||||
"var len = %out",
|
||||
"${len}"
|
||||
];
|
||||
|
||||
YesNtAssert.IsLastLineEqual(lines, "0");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EscapedBackslashProducesLiteralBackslashTest()
|
||||
{
|
||||
List<string> lines =
|
||||
[
|
||||
"var msg = \"\\\\n\"", // YesNt source: "\\n" → \n (backslash + n, 2 chars)
|
||||
"length ${msg}",
|
||||
"var len = %out",
|
||||
"${len}"
|
||||
];
|
||||
|
||||
YesNtAssert.IsLastLineEqual(lines, "2");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnknownEscapeSequenceBecomesCharTest()
|
||||
{
|
||||
List<string> lines =
|
||||
[
|
||||
"var msg = \"\\q\"", // YesNt source: "\q" → q (1 char)
|
||||
"length ${msg}",
|
||||
"var len = %out",
|
||||
"${len}"
|
||||
];
|
||||
|
||||
YesNtAssert.IsLastLineEqual(lines, "1");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnterminatedStringLiteralFailsTest()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user