@@ -44,24 +44,27 @@ var testfiles = walkFiles(
44
44
45
45
//What databases to mimic when running tests
46
46
var mimic = [
47
+ 'unknown' ,
47
48
'sqlite' ,
48
49
'postgresql' ,
49
50
'mssql' ,
50
51
'oracle' ,
51
- 'mysql' ,
52
- 'Unspecified DB'
52
+ 'mysql'
53
53
]
54
54
55
55
56
+ var runOnlyDemo = true ;
56
57
57
58
//////////////////////////// CONFIG END /////////////////////////////////////
58
59
59
60
60
61
61
62
63
+ if ( runOnlyDemo ) {
64
+ mimic = [ mimic [ 0 ] ] ;
65
+ testfiles = [ "./demo.test" ] ;
66
+ }
62
67
63
-
64
- //testfiles=["./demo.test"]
65
68
alasql . options . modifier = "MATRIX" ;
66
69
alasql . options . cache = false ;
67
70
var mimicking = 0 ;
@@ -266,7 +269,7 @@ function runSQLtestFromFile(path, db, mimic){
266
269
} else {
267
270
score . fail . total ++ ;
268
271
269
- //console.log(test)
272
+
270
273
271
274
var errHash = test . msg . split ( '-----^' ) . pop ( ) /*.split("'").unshift()*/ . replace ( / [ ^ a - z ] / mig, '' )
272
275
@@ -293,16 +296,21 @@ function verifyTest(fragment, db){
293
296
//console.log('-----------------------------------------------')
294
297
var req = runTest ( fragment . sql , db )
295
298
req . ok = ( fragment . expectSuccess === req . success )
299
+
300
+
296
301
297
- if ( false ) // Converting returned values to expected result is still creating too many false positives
302
+ // if(false) // Converting returned values to expected result is still creating too many false positives
298
303
if ( fragment . result && req . success && req . ok ) {
299
304
var ok ;
305
+
306
+ console . log ( req . result )
300
307
req . result = cleanResults ( req . result )
301
- //console.log(fragment.result)
302
- //console.log(fragment.sql)
303
- //console.log(req.result)
304
308
305
- if ( ! ( req . result && req . result . length ) ) {
309
+ console . log ( fragment . result )
310
+ console . log ( req . result )
311
+
312
+
313
+ if ( ! ( req . result && req . result . length ) ) {
306
314
req . msg = 'Query was expected to return results (but did not): ' + JSON . stringify ( req . result )
307
315
req . ok = false
308
316
} else if ( 'list' === fragment . result . type ) {
@@ -314,7 +322,7 @@ if(false) // Converting returned values to expected result is still creating too
314
322
req . msg = 'Expected: ' + JSON . stringify ( fragment . result . values ) + ' but got ' + JSON . stringify ( req . result ) ;
315
323
//console.log('Expected:',fragment.result.values,'but got', req.result );
316
324
//console.log();
317
- // req.ok = ok
325
+ req . ok = ok
318
326
}
319
327
320
328
@@ -367,13 +375,22 @@ function cleanResults(result){
367
375
return "1" ;
368
376
} else if ( false === x ) {
369
377
return "0" ;
370
- } else if ( null === x ) {
371
- return "NULL" ;
378
+ } else if ( 'Infinity' === '' + x ) {
379
+ return null ;
380
+ } else if ( 'NaN' === '' + x ) {
381
+ return null ;
382
+ } else if ( 'undefined' === '' + x ) {
383
+ return null ;
372
384
} else if ( '' === x ) {
373
385
return "(empty)" ;
374
386
}
375
- //return x;
376
- // fix %3d for floats;
387
+
388
+ // Its a float
389
+ if ( x === + x && x !== ( x | 0 ) ) {
390
+ return '' + x . toFixed ( 3 ) ;
391
+ }
392
+
393
+ // remove printable chars
377
394
return ( '' + x ) . replace ( / [ \n \r \t \x00 \x08 \x0B \x0C \x0E - \x1F \x7F ] / gim, '@' ) ;
378
395
} ) ;
379
396
0 commit comments