add utils functions
This commit is contained in:
@@ -3,7 +3,7 @@ unit AG.PascalTokenizer;
|
||||
interface
|
||||
|
||||
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}
|
||||
{$mode Delphi}
|
||||
@@ -85,7 +85,7 @@ var
|
||||
|
||||
function is_comment(s: string): boolean;
|
||||
begin
|
||||
// TODO
|
||||
Result:=(s.startswith('{') or s.startswith('(*') or s.startswith('//'));
|
||||
end;
|
||||
|
||||
function is_name(s: string): boolean;
|
||||
@@ -107,7 +107,7 @@ end;
|
||||
|
||||
function is_string(s: string): boolean;
|
||||
begin
|
||||
// TODO
|
||||
Result:=s.StartsWith(#39);
|
||||
end;
|
||||
|
||||
function TPasTokenizer._do_readable(): boolean;
|
||||
|
||||
@@ -5,6 +5,7 @@ uses
|
||||
DUnitX.TestFramework,
|
||||
System.Classes,
|
||||
WinAPI.Windows,
|
||||
SysUtils,
|
||||
AG.PascalTokenizer;
|
||||
|
||||
type
|
||||
@@ -15,6 +16,10 @@ type
|
||||
// Simple single Test
|
||||
[Test]
|
||||
procedure Test1;
|
||||
[Test]
|
||||
procedure Test2;
|
||||
[Test]
|
||||
procedure Test3;
|
||||
// Test with TestCase Atribute to supply parameters.
|
||||
end;
|
||||
|
||||
@@ -38,6 +43,33 @@ begin
|
||||
//sleep(10000);
|
||||
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
|
||||
TDUnitX.RegisterTestFixture(TMyTestObject);
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user