Skip to content

Commit ddbd382

Browse files
authored
.test_code improvements (#14)
* * syncing track test framework * * improving test_code
1 parent dfe5491 commit ddbd382

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2000
-875
lines changed

assets/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL = /bin/bash
22
MAKEFLAGS += --no-print-directory
33
DESTDIR = build
44
EXECUTABLE = $(DESTDIR)/test
5-
COMMAND = fpc -l- -v0 -g -gl -Sehnw -Fu./lib test.pas -FE"./$(DESTDIR)"
5+
COMMAND = fpc -l- -v0 -g -gl -Sa -Cr -Sehnw -Fu./lib test.pas -FE"./$(DESTDIR)"
66

77
.ONESHELL:
88

assets/lib/FPCUnitTAPReporter.pas

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ destructor TCustomResultWriter.Destroy;
4343

4444
procedure TCustomResultWriter.AddFailure(ATest: TTest; AFailure: TTestFailure);
4545
var
46-
JData : TJSONData;
47-
LMessage, LGot, LExpected : string;
46+
JData : TJSONData;
47+
LMessage, LGot, LExpect : string;
4848
begin
4949

5050
FTestPassed := false;
@@ -54,16 +54,22 @@ procedure TCustomResultWriter.AddFailure(ATest: TTest; AFailure: TTestFailure);
5454
try
5555
JData := GetJSON(AFailure.ExceptionMessage);
5656
LMessage := JData.FindPath('message').AsString;
57-
if GetEnumName(
58-
TypeInfo(TJSONtype), ord(JData.FindPath('expected').JSONType)
59-
) = 'jtArray' then
60-
LExpected := JData.FindPath('expected').FormatJSON
61-
else LExpected := JData.FindPath('expected').AsString;
62-
if GetEnumName(
57+
case
58+
GetEnumName(
59+
TypeInfo(TJSONtype), ord(JData.FindPath('expect').JSONType)
60+
) of
61+
'jtArray', 'jtObject' :
62+
LExpect := JData.FindPath('expect').FormatJSON;
63+
otherwise LExpect := JData.FindPath('expect').AsString;
64+
end;
65+
case
66+
GetEnumName(
6367
TypeInfo(TJSONtype), ord(JData.FindPath('actual').JSONType)
64-
) = 'jtArray' then
65-
LGot := JData.FindPath('actual').FormatJSON
66-
else LGot := JData.FindPath('actual').AsString;
68+
) of
69+
'jtArray', 'jtObject' :
70+
LGot := JData.FindPath('actual').FormatJSON
71+
otherwise LGot := JData.FindPath('actual').AsString;
72+
end;
6773
finally
6874
JData.Free;
6975
end
@@ -93,12 +99,12 @@ procedure TCustomResultWriter.AddFailure(ATest: TTest; AFailure: TTestFailure);
9399
else
94100
writeln(' got: ', LGot);
95101

96-
if pos(#10, LExpected) > 0 then
102+
if pos(#10, LExpect) > 0 then
97103
begin
98-
writeln(' expected: |');
99-
writeln(' ' + ReplaceStr(LExpected, #10, #10 + ' '));
104+
writeln(' expect: |');
105+
writeln(' ' + ReplaceStr(LExpect, #10, #10 + ' '));
100106
end
101-
else writeln(' expect: ', LExpected);
107+
else writeln(' expect: ', LExpect);
102108

103109
writeln(' ...');
104110
end;

0 commit comments

Comments
 (0)