@@ -16,6 +16,7 @@ Method TestCodeUnitCreation()
16
16
#dim tCodeUnit As TestCoverage.Data.CodeUnit
17
17
Set tClsName = $classname ()_" .CLS"
18
18
Set tIntName = $classname ()_" .1.INT"
19
+ Set tPyName = $classname ()_" .PY"
19
20
Set tSC = ##class (TestCoverage.Data.CodeUnit ).GetCurrentByName (tIntName ,$Namespace ,.tIntCodeUnit )
20
21
Do $$$AssertStatusOK(tSC ," Found test coverage data for " _tIntName )
21
22
Do $$$AssertEquals(tIntCodeUnit .Name ,$classname ()_" .1" )
@@ -27,28 +28,40 @@ Method TestCodeUnitCreation()
27
28
Do $$$AssertEquals(tGenCodeUnit .Name ,$classname ()_" .G1" )
28
29
Do $$$AssertEquals(tGenCodeUnit .Type ," INT" )
29
30
31
+
30
32
Set tSC = ##class (TestCoverage.Data.CodeUnit ).GetCurrentByName (tClsName ,$Namespace ,.tClsCodeUnit )
31
33
Do $$$AssertStatusOK(tSC ," Found test coverage data for " _tClsName )
32
34
Do $$$AssertEquals(tClsCodeUnit .Name ,$classname ())
33
35
Do $$$AssertEquals(tClsCodeUnit .Type ," CLS" )
34
36
37
+ Set tSC = ##class (TestCoverage.Data.CodeUnit ).GetCurrentByName (tPyName ,$Namespace ,.tPyCodeUnit )
38
+ Do $$$AssertStatusOK(tSC ," Found test coverage data for " _tPyName )
39
+ Do $$$AssertEquals(tPyCodeUnit .Name ,$classname ())
40
+ Do $$$AssertEquals(tPyCodeUnit .Type ," PY" )
41
+
42
+ Set tSC = tClsCodeUnit .UpdatePyExecutableLines ($classname (),.tPyCodeUnit )
43
+ Do $$$AssertStatusOK(tSC ," Found updated executable line data for " _tClsName )
44
+
35
45
Set tConstantReturnValueLine = tClsCodeUnit .MethodMap .GetAt (" SampleConstantReturnValue" )
36
46
Set tCodeGeneratorLine = tClsCodeUnit .MethodMap .GetAt (" SampleCodeGenerator" )
37
47
Set tNormalMethodLine = tClsCodeUnit .MethodMap .GetAt (" SampleNormalMethod" )
48
+ Set tPythonMethodLine = tClsCodeUnit .MethodMap .GetAt (" SamplePythonMethod" )
38
49
39
50
Do $$$AssertNotEquals(tConstantReturnValueLine ," " )
40
51
Do $$$AssertNotEquals(tCodeGeneratorLine ," " )
41
52
Do $$$AssertNotEquals(tNormalMethodLine ," " )
53
+ Do $$$AssertNotEquals(tPythonMethodLine ," " )
42
54
43
55
// tTestLines(line number) = $ListBuild(description, executable (default 1), mapped (default 1), mapped from hash (if relevant), mapped from line (if relevant))
44
56
Set tTestLines (tConstantReturnValueLine +2 ) = $ListBuild (" SampleConstantReturnValue+1" ,0 ,0 )
45
- Set tTestLines (tCodeGeneratorLine +2 ) = $ListBuild (" SampleCodeGenerator+1" ,,,tGenCodeUnit .Hash ,tGenCodeUnit .MethodMap .GetAt (" SampleCodeGenerator" )+1 )
46
- Set tTestLines (tCodeGeneratorLine +3 ) = $ListBuild (" SampleCodeGenerator+2" ,,,tGenCodeUnit .Hash ,tGenCodeUnit .MethodMap .GetAt (" SampleCodeGenerator" )+2 )
47
- Set tTestLines (tCodeGeneratorLine +4 ) = $ListBuild (" SampleCodeGenerator+3" ,,,tGenCodeUnit .Hash ,tGenCodeUnit .MethodMap .GetAt (" SampleCodeGenerator" )+3 )
57
+ Set tTestLines (tCodeGeneratorLine +2 ) = $ListBuild (" SampleCodeGenerator+1" ,,,tGenCodeUnit .Hash ,tGenCodeUnit .MethodMap .GetAt (" SampleCodeGenerator" )+1 , " INT " )
58
+ Set tTestLines (tCodeGeneratorLine +3 ) = $ListBuild (" SampleCodeGenerator+2" ,,,tGenCodeUnit .Hash ,tGenCodeUnit .MethodMap .GetAt (" SampleCodeGenerator" )+2 , " INT " )
59
+ Set tTestLines (tCodeGeneratorLine +4 ) = $ListBuild (" SampleCodeGenerator+3" ,,,tGenCodeUnit .Hash ,tGenCodeUnit .MethodMap .GetAt (" SampleCodeGenerator" )+3 , " INT " )
48
60
Set methodLabel = $Select ($System .Version .GetMajor ()<2023 :" z" ,1 :" " )_" SampleNormalMethod"
49
- Set tTestLines (tNormalMethodLine +2 ) = $ListBuild (" SampleNormalMethod+1" ,,,tIntCodeUnit .Hash ,tIntCodeUnit .MethodMap .GetAt (methodLabel )+1 )
50
- Set tTestLines (tNormalMethodLine +3 ) = $ListBuild (" SampleNormalMethod+2" ,,,tIntCodeUnit .Hash ,tIntCodeUnit .MethodMap .GetAt (methodLabel )+2 )
51
-
61
+ Set tTestLines (tNormalMethodLine +2 ) = $ListBuild (" SampleNormalMethod+1" ,,,tIntCodeUnit .Hash ,tIntCodeUnit .MethodMap .GetAt (methodLabel )+1 , " INT" )
62
+ Set tTestLines (tNormalMethodLine +3 ) = $ListBuild (" SampleNormalMethod+2" ,,,tIntCodeUnit .Hash ,tIntCodeUnit .MethodMap .GetAt (methodLabel )+2 , " INT" )
63
+ Set tTestLines (tPythonMethodLine +2 ) = $ListBuild (" SamplePythonMethod+1" ,,,tPyCodeUnit .Hash ,tPyCodeUnit .MethodMap .GetAt (" SamplePythonMethod" )+1 , " PY" )
64
+ Set tTestLines (tPythonMethodLine +3 ) = $ListBuild (" SamplePythonMethod+2" ,,,tPyCodeUnit .Hash ,tPyCodeUnit .MethodMap .GetAt (" SamplePythonMethod" )+2 , " PY" )
52
65
Set tLine = " "
53
66
For {
54
67
Set tLine = $Order (tTestLines (tLine ),1 ,tInfo )
@@ -57,17 +70,17 @@ Method TestCodeUnitCreation()
57
70
}
58
71
59
72
// Overwrite with defined values, leave defaults in AssertLineHandledCorrectly for undefined values (passing byref)
60
- Kill tDescription , tExecutable , tMapped , tExpectedFromHash , tExpectedFromLine
61
- Set $ListBuild (tDescription , tExecutable , tMapped , tExpectedFromHash , tExpectedFromLine ) = tInfo
62
- Do ..AssertLineHandledCorrectly (tClsCodeUnit , tLine , .tDescription , .tExecutable , .tMapped , .tExpectedFromHash , .tExpectedFromLine )
73
+ Kill tDescription , tExecutable , tMapped , tExpectedFromHash , tExpectedFromLine , tType
74
+ Set $ListBuild (tDescription , tExecutable , tMapped , tExpectedFromHash , tExpectedFromLine , tType ) = tInfo
75
+ Do ..AssertLineHandledCorrectly (tClsCodeUnit , tLine , .tDescription , .tExecutable , .tMapped , .tExpectedFromHash , .tExpectedFromLine , . tType )
63
76
}
64
77
} Catch e {
65
78
Set tSC = e .AsStatus ()
66
79
}
67
80
Do $$$AssertStatusOK(tSC ," No unexpected errors occurred." )
68
81
}
69
82
70
- Method AssertLineHandledCorrectly (pClassCodeUnit As TestCoverage .Data .CodeUnit , pLine As %Integer , pDescription As %String = {" Line " _pLine }, pExecutable As %Boolean = 1 , pMapped As %Boolean = 1 , pExpectedFromHash As %String = " " , pExpectedFromLine As %Integer = " " ) As %Boolean
83
+ Method AssertLineHandledCorrectly (pClassCodeUnit As TestCoverage .Data .CodeUnit , pLine As %Integer , pDescription As %String = {" Line " _pLine }, pExecutable As %Boolean = 1 , pMapped As %Boolean = 1 , pExpectedFromHash As %String = " " , pExpectedFromLine As %Integer = " " , pType As %String = " INT " ) As %Boolean
71
84
{
72
85
Set tAllGood = 1
73
86
If pExecutable {
@@ -78,7 +91,7 @@ Method AssertLineHandledCorrectly(pClassCodeUnit As TestCoverage.Data.CodeUnit,
78
91
79
92
&sql (select count (* ),FromHash ,FromLine into :tCount ,:tFromHash ,:tFromLine
80
93
from TestCoverage _Data .CodeUnitMap
81
- where ToHash = :pClassCodeUnit .Hash and ToLine = :pLine and FromHash ->Type = ' INT ' )
94
+ where ToHash = :pClassCodeUnit .Hash and ToLine = :pLine and FromHash ->Type = : pType )
82
95
If (SQLCODE < 0 ) {
83
96
Throw ##class (%Exception.SQL ).CreateFromSQLCODE (SQLCODE ,%msg )
84
97
}
@@ -123,5 +136,10 @@ ClassMethod SampleNormalMethod()
123
136
Quit y
124
137
}
125
138
139
+ ClassMethod SamplePythonMethod () [ Language = python ]
140
+ {
141
+ import iris
142
+ return 50
126
143
}
127
144
145
+ }
0 commit comments