@@ -26,15 +26,36 @@ private module TranslateModels<
2626 )
2727 }
2828
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+ )
3154 }
3255
3356 /** Lists the renumbered and pretty-printed models used in the edges relation. */
3457 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 )
3859 }
3960
4061 private predicate translateModelsPart ( string model1 , string model2 , int i ) {
@@ -46,7 +67,7 @@ private module TranslateModels<
4667 translateModelsPart ( model1 , part , i - 1 ) and
4768 madId = s .regexpCapture ( "([0-9]*)(.*)" , 1 ) and
4869 rest = s .regexpCapture ( "([0-9]*)(.*)" , 2 ) and
49- rankedMadIds ( madId , r ) and
70+ translateModel ( madId , r ) and
5071 model2 = part + "MaD:" + r + rest
5172 )
5273 )
@@ -102,17 +123,6 @@ module TestPostProcessing {
102123
103124 private module Models = TranslateModels< interpretModelForTest / 2 , provenance / 1 > ;
104125
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-
116126 query predicate results ( string relation , int row , int column , string data ) {
117127 queryResults ( relation , row , column , data ) and
118128 ( relation != "edges" or column != provenanceColumn ( ) )
@@ -124,11 +134,11 @@ module TestPostProcessing {
124134 Models:: translateModels ( model , data )
125135 )
126136 or
127- exists ( int r , string model |
137+ exists ( string model |
128138 relation = "models" and
129- rankedModels ( row , r , model )
139+ Models :: models ( row , model )
130140 |
131- column = 0 and data = r .toString ( )
141+ column = 0 and data = row .toString ( )
132142 or
133143 column = 1 and data = model
134144 )
0 commit comments