[fast]の診断を英語化し単独行形式をテスト

このコミットが含まれているのは:
routersys committed 2026-07-05 16:37:10 +09:00
1 親 2bd54674c1
コミット e6165ca5a3
2ファイル変更
+22 -3

検索条件に一致するファイルはありません

+3 -3
ファイルの表示
@@ -3,7 +3,7 @@ namespace LuaScript.Compat.Syntax.Rules
[LuaSyntaxRule(2)]
internal sealed class LuaFastRule : ILuaSyntaxRule
{
private const string Message = "[fast] は obj.fill / obj.convolve / obj.resize にのみ適用できます。";
private const string Message = "[fast]: only obj.fill, obj.convolve and obj.resize can be accelerated.";
public bool TryApply(LuaRewriteContext context)
{
@@ -25,16 +25,16 @@ namespace LuaScript.Compat.Syntax.Rules
if (targetIndex < 0 || context.Input[targetIndex].Kind != LuaSyntaxTokenKind.Name)
return false;
EmitBetween(context, closeIndex + 1, targetIndex);
if (TryResolveTarget(context, targetIndex, out int funcIndex, out string function))
{
EmitBetween(context, closeIndex + 1, targetIndex);
context.Index = funcIndex + 1;
context.EmitRaw("__fast_" + function);
return true;
}
context.AddDiagnostic(Message);
EmitBetween(context, closeIndex + 1, targetIndex);
context.Index = targetIndex;
return true;
}
+19
ファイルの表示
@@ -591,6 +591,25 @@ namespace LuaScript.Tests
Assert.Equal(expected, Rewrite(source));
}
[Theory]
[InlineData("[fast]\nobj.fill(0, 0, 0, 255)", "\n__fast_fill(0, 0, 0, 255)")]
[InlineData("[fast]\nobj.convolve(k, 3)", "\n__fast_convolve(k, 3)")]
[InlineData("[fast]\nobj.resize(64, 64)", "\n__fast_resize(64, 64)")]
[InlineData("obj.x = 1\n[fast]\nobj.resize(64, 64)", "obj.x = 1\n\n__fast_resize(64, 64)")]
public void Fast_MarkerOnOwnLine_RewritesNextStatement(string source, string expected)
{
Assert.Equal(expected, Rewrite(source));
}
[Fact]
public void Fast_MarkerOnOwnLine_ReportsDiagnosticOnMarkerLine()
{
var (code, _, diagnostics) = LuaSyntaxExtensions.RewriteWithMap("obj.x = 1\n[fast]\nobj.draw(0)");
Assert.Equal("obj.x = 1\n\nobj.draw(0)", code);
var diagnostic = Assert.Single(diagnostics);
Assert.Equal(2, diagnostic.Line);
}
[Fact]
public void Fast_RewritesInsideBlock()
{