Forum Discussion

mikakoistinen's avatar
mikakoistinen
Contributor
6 years ago

Evaluate and unit reference

Hi, 

I have general purpose CSV FIle compare function in one  unit (lets call it general)

I'd like to call it from actual test unit.  (lets call it actualtest)

Problem is that I need to ignore / modify some fields before compare.

I tought that i could pass procedure name as parameter and call it from that compere function, but I get Unknown identifier  actualtest

 

for example

in general.sd

 

procedure compare_csvfile (file1, file2, comparemethodname);
begin
  ...  
  parameters := '( something )';
  evaluate(comparemethodname+parameters);
end;

in actualtest.sd

 

uses general;
procedure normalizedata(a,b,c); begin
// do something end; procedure doactualtest; begin
... generate test data .. compare_csvfile( file1, file2, 'actualtest.normalizedata'); end;

should this be possible?

 

5 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    While you already found the approach that works, you may also consider the Runner.CallMethod() method. It accepts tha name of the method to execute exactly in the "unitName.MethodName" format and might appear to be usable for your case as well.

     

  • It seems that circural unit references are allowed in Delphi Script.

    So I this solved my problem this time, but not actually very nice solution.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      That's precisely what you need to do.  The "general" unit needs a uses statement to indicate to include methods from the "actualtest" unit.  Otherwise, it doesn't know what "actualtest" is.  Standard Delphi development, not just script code.  You'd run into the same problem in the Delphi IDE.

      • mikakoistinen's avatar
        mikakoistinen
        Contributor

        actually, in Delphi i could write an anonymous method .. but this is enough for me .