add utils functions
This commit is contained in:
@@ -3,7 +3,7 @@ unit AG.PascalTokenizer;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF FPC}fgl,{$ELSE}System.Generics.Collections,System.{$ENDIF}SysUtils,{$IFNDEF FPC}System.{$ENDIF}Classes;
|
{$IFDEF FPC}fgl,SysUtils,Classes{$ELSE}System.Generics.Collections,System.SysUtils,System.Classes{$ENDIF};
|
||||||
|
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
{$mode Delphi}
|
{$mode Delphi}
|
||||||
@@ -85,7 +85,7 @@ var
|
|||||||
|
|
||||||
function is_comment(s: string): boolean;
|
function is_comment(s: string): boolean;
|
||||||
begin
|
begin
|
||||||
// TODO
|
Result:=(s.startswith('{') or s.startswith('(*') or s.startswith('//'));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function is_name(s: string): boolean;
|
function is_name(s: string): boolean;
|
||||||
@@ -107,7 +107,7 @@ end;
|
|||||||
|
|
||||||
function is_string(s: string): boolean;
|
function is_string(s: string): boolean;
|
||||||
begin
|
begin
|
||||||
// TODO
|
Result:=s.StartsWith(#39);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPasTokenizer._do_readable(): boolean;
|
function TPasTokenizer._do_readable(): boolean;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ uses
|
|||||||
DUnitX.TestFramework,
|
DUnitX.TestFramework,
|
||||||
System.Classes,
|
System.Classes,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
|
SysUtils,
|
||||||
AG.PascalTokenizer;
|
AG.PascalTokenizer;
|
||||||
|
|
||||||
type
|
type
|
||||||
@@ -15,6 +16,10 @@ type
|
|||||||
// Simple single Test
|
// Simple single Test
|
||||||
[Test]
|
[Test]
|
||||||
procedure Test1;
|
procedure Test1;
|
||||||
|
[Test]
|
||||||
|
procedure Test2;
|
||||||
|
[Test]
|
||||||
|
procedure Test3;
|
||||||
// Test with TestCase Atribute to supply parameters.
|
// Test with TestCase Atribute to supply parameters.
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -38,6 +43,33 @@ begin
|
|||||||
//sleep(10000);
|
//sleep(10000);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMyTestObject.Test2;
|
||||||
|
var
|
||||||
|
s:string;
|
||||||
|
begin
|
||||||
|
s:=#39'kek'#39;
|
||||||
|
if not is_string(s) then
|
||||||
|
raise Exception.Create('Is string error 1');
|
||||||
|
s:='s:=12334;';
|
||||||
|
if is_string(s) then
|
||||||
|
raise Exception.Create('Is string error 2');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMyTestObject.Test3;
|
||||||
|
var
|
||||||
|
s:string;
|
||||||
|
begin
|
||||||
|
s:='{ asdasdasd }';
|
||||||
|
if not is_comment(s) then
|
||||||
|
raise Exception.Create('Is comment error 1');
|
||||||
|
s:='(* s:=12334;*)';
|
||||||
|
if not is_comment(s) then
|
||||||
|
raise Exception.Create('Is comment error 2');
|
||||||
|
s:='// s:=12334;*)';
|
||||||
|
if not is_comment(s) then
|
||||||
|
raise Exception.Create('Is comment error 3');
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
TDUnitX.RegisterTestFixture(TMyTestObject);
|
TDUnitX.RegisterTestFixture(TMyTestObject);
|
||||||
end.
|
end.
|
||||||
|
|||||||
Reference in New Issue
Block a user