@@ -26,15 +26,36 @@ private module TranslateModels<
26
26
)
27
27
}
28
28
29
- private predicate rankedMadIds ( string madId , int r ) {
30
- madId = rank [ r ] ( string madId0 | madIds ( madId0 ) | madId0 order by madId0 .toInt ( ) )
29
+ private QlBuiltins:: ExtensionId getModelId ( string model ) {
30
+ madIds ( result .toString ( ) ) and
31
+ interpretModelForTest ( result , model )
32
+ }
33
+
34
+ // collapse models with the same textual representation, in order to not rely
35
+ // on the order of `ExtensionId`s
36
+ private module ExtensionIdSets =
37
+ QlBuiltins:: InternSets< string , QlBuiltins:: ExtensionId , getModelId / 1 > ;
38
+
39
+ private predicate rankedMadIds ( ExtensionIdSets:: Set extIdSet , int r ) {
40
+ extIdSet =
41
+ rank [ r ] ( ExtensionIdSets:: Set extIdSet0 , string model |
42
+ extIdSet0 = ExtensionIdSets:: getSet ( model )
43
+ |
44
+ extIdSet0 order by model
45
+ )
46
+ }
47
+
48
+ private predicate translateModel ( string id , int r ) {
49
+ exists ( QlBuiltins:: ExtensionId madId , ExtensionIdSets:: Set extIdSet |
50
+ id = madId .toString ( ) and
51
+ extIdSet .contains ( madId ) and
52
+ rankedMadIds ( extIdSet , r )
53
+ )
31
54
}
32
55
33
56
/** Lists the renumbered and pretty-printed models used in the edges relation. */
34
57
predicate models ( int r , string model ) {
35
- exists ( QlBuiltins:: ExtensionId madId |
36
- rankedMadIds ( madId .toString ( ) , r ) and interpretModelForTest ( madId , model )
37
- )
58
+ exists ( string madId | translateModel ( madId , r ) and getModelId ( model ) .toString ( ) = madId )
38
59
}
39
60
40
61
private predicate translateModelsPart ( string model1 , string model2 , int i ) {
@@ -46,7 +67,7 @@ private module TranslateModels<
46
67
translateModelsPart ( model1 , part , i - 1 ) and
47
68
madId = s .regexpCapture ( "([0-9]*)(.*)" , 1 ) and
48
69
rest = s .regexpCapture ( "([0-9]*)(.*)" , 2 ) and
49
- rankedMadIds ( madId , r ) and
70
+ translateModel ( madId , r ) and
50
71
model2 = part + "MaD:" + r + rest
51
72
)
52
73
)
@@ -102,17 +123,6 @@ module TestPostProcessing {
102
123
103
124
private module Models = TranslateModels< interpretModelForTest / 2 , provenance / 1 > ;
104
125
105
- private newtype TModelRow = TMkModelRow ( int r , string model ) { Models:: models ( r , model ) }
106
-
107
- private predicate rankedModels ( int i , int r , string model ) {
108
- TMkModelRow ( r , model ) =
109
- rank [ i ] ( TModelRow row , int r0 , string model0 |
110
- row = TMkModelRow ( r0 , model0 )
111
- |
112
- row order by r0 , model0
113
- )
114
- }
115
-
116
126
query predicate results ( string relation , int row , int column , string data ) {
117
127
queryResults ( relation , row , column , data ) and
118
128
( relation != "edges" or column != provenanceColumn ( ) )
@@ -124,11 +134,11 @@ module TestPostProcessing {
124
134
Models:: translateModels ( model , data )
125
135
)
126
136
or
127
- exists ( int r , string model |
137
+ exists ( string model |
128
138
relation = "models" and
129
- rankedModels ( row , r , model )
139
+ Models :: models ( row , model )
130
140
|
131
- column = 0 and data = r .toString ( )
141
+ column = 0 and data = row .toString ( )
132
142
or
133
143
column = 1 and data = model
134
144
)
0 commit comments