@@ -88,6 +88,7 @@ function loadContent(content) {
8888 var m = new Module ( ) ;
8989 m . _compile ( content , "tmp.js" ) ;
9090 m . exports . ignore_order = content . indexOf ( "\n// ignore-order\n" ) !== - 1 ;
91+ m . exports . exact_check = content . indexOf ( "\n// exact-check\n" ) !== - 1 ;
9192 return m . exports ;
9293}
9394
@@ -179,6 +180,7 @@ function main(argv) {
179180 const expected = loadedFile . EXPECTED ;
180181 const query = loadedFile . QUERY ;
181182 const ignore_order = loadedFile . ignore_order ;
183+ const exact_check = loadedFile . exact_check ;
182184 var results = loaded . execSearch ( loaded . getQuery ( query ) , index ) ;
183185 process . stdout . write ( 'Checking "' + file + '" ... ' ) ;
184186 var error_text = [ ] ;
@@ -191,13 +193,17 @@ function main(argv) {
191193 break ;
192194 }
193195 var entry = expected [ key ] ;
194- var prev_pos = 0 ;
196+ var prev_pos = - 1 ;
195197 for ( var i = 0 ; i < entry . length ; ++ i ) {
196198 var entry_pos = lookForEntry ( entry [ i ] , results [ key ] ) ;
197199 if ( entry_pos === null ) {
198200 error_text . push ( "==> Result not found in '" + key + "': '" +
199201 JSON . stringify ( entry [ i ] ) + "'" ) ;
200- } else if ( entry_pos < prev_pos && ignore_order === false ) {
202+ } else if ( exact_check === true && prev_pos + 1 !== entry_pos ) {
203+ error_text . push ( "==> Exact check failed at position " + ( prev_pos + 1 ) + ": " +
204+ "expected '" + JSON . stringify ( entry [ i ] ) + "' but found '" +
205+ JSON . stringify ( results [ key ] [ i ] ) + "'" ) ;
206+ } else if ( ignore_order === false && entry_pos < prev_pos ) {
201207 error_text . push ( "==> '" + JSON . stringify ( entry [ i ] ) + "' was supposed to be " +
202208 " before '" + JSON . stringify ( results [ key ] [ entry_pos ] ) + "'" ) ;
203209 } else {
0 commit comments