Fixed string conversion warning in lua_where
Added LoadFromFile unit test
This commit is contained in:
parent
018dbf03b2
commit
1a39372447
|
@ -742,7 +742,7 @@ begin
|
|||
lua_getinfo(L, 'Sl', ar); // get info about it
|
||||
if (ar.currentline > 0) then // is there info?
|
||||
begin
|
||||
msg := Format('%s:%d: ', [ar.short_src, ar.currentline]);
|
||||
msg := AnsiString(Format('%s:%d: ', [ar.short_src, ar.currentline]));
|
||||
lua_pushlstring(L, PAnsiChar(msg), Length(msg));
|
||||
exit
|
||||
end;
|
||||
|
|
|
@ -54,12 +54,15 @@ type
|
|||
|
||||
procedure RegisterObject;
|
||||
procedure RegisterObjectTable;
|
||||
|
||||
procedure LoadFromFile;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
System.Classes;
|
||||
System.Classes,
|
||||
System.IOUtils;
|
||||
|
||||
|
||||
type
|
||||
|
@ -500,6 +503,30 @@ begin
|
|||
end;
|
||||
|
||||
|
||||
procedure TTestWrapper.LoadFromFile;
|
||||
var
|
||||
fileName: string;
|
||||
script: TStringList;
|
||||
|
||||
begin
|
||||
fileName := TPath.GetTempFileName;
|
||||
try
|
||||
script := TStringList.Create;
|
||||
try
|
||||
script.Add('print("Hello world!")');
|
||||
script.SaveToFile(fileName);
|
||||
finally
|
||||
FreeAndNil(script);
|
||||
end;
|
||||
|
||||
Lua.LoadFromFile(fileName);
|
||||
CheckEquals('Hello world!', Printed.ToString);
|
||||
finally
|
||||
TFile.Delete(fileName);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ TTestObject }
|
||||
constructor TTestObject.Create(AOutput: TStringBuilder);
|
||||
begin
|
||||
|
|
Loading…
Reference in New Issue