mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 17:07:22 +00:00
Fixed mixed line breaks in saved code files and tests failing on Windows (#1149)
This commit is contained in:
1 parent
770c16e20a
commit
f864359290
4 files changed
+39
-4
No files matched your search
@@ -251,6 +251,35 @@ public sealed class IContentExtensionsTests
|
||||
Assert.That(TextWith(string.Empty).ToExportContent(file), Is.EqualTo("print(42)\n"));
|
||||
}
|
||||
|
||||
[TestCase("import sys\r\nprint(sys.argv)")]
|
||||
[TestCase("import sys\r\nprint(sys.argv)\r\n")]
|
||||
[TestCase("import sys\rprint(sys.argv)")]
|
||||
public void CodeNeverMixesLineEndings(string code)
|
||||
{
|
||||
var file = new MessageFile(1, Position: 0, string.Empty, FileExportFormat.SOURCE_CODE, SourceCodeLanguages.FromCodeFenceLanguage("python"), code);
|
||||
|
||||
Assert.That(TextWith(string.Empty).ToExportContent(file), Is.EqualTo("import sys\nprint(sys.argv)\n"), "Every line ends with LF, whatever line breaks the code came with.");
|
||||
}
|
||||
|
||||
[TestCase("@echo off\necho done")]
|
||||
[TestCase("@echo off\r\necho done\r\n")]
|
||||
[TestCase("@echo off\recho done")]
|
||||
public void ABatchFileNeverMixesLineEndings(string code)
|
||||
{
|
||||
var file = new MessageFile(1, Position: 0, string.Empty, FileExportFormat.SOURCE_CODE, SourceCodeLanguages.FromCodeFenceLanguage("bat"), code);
|
||||
|
||||
Assert.That(TextWith(string.Empty).ToExportContent(file), Is.EqualTo("@echo off\r\necho done\r\n"), "Every line ends with CR LF, whatever line breaks the code came with.");
|
||||
}
|
||||
|
||||
[TestCase("python", "print('a\fb\u2028c')", "print('a\fb\u2028c')\n")]
|
||||
[TestCase("bat", "echo a\fb\u2028c", "echo a\fb\u2028c\r\n")]
|
||||
public void AFormFeedOrALineSeparatorStaysInItsLine(string language, string code, string expected)
|
||||
{
|
||||
var file = new MessageFile(1, Position: 0, string.Empty, FileExportFormat.SOURCE_CODE, SourceCodeLanguages.FromCodeFenceLanguage(language), code);
|
||||
|
||||
Assert.That(TextWith(string.Empty).ToExportContent(file), Is.EqualTo(expected), "Markdown breaks lines only at LF and CR, and so does the file.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ABatchFileEndsItsLinesTheWindowsWay()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user