Skip to content

Commit b198157

Browse files
committed
result list compare working. Next step hash compare results
1 parent bf3ff34 commit b198157

File tree

3 files changed

+55
-16
lines changed

3 files changed

+55
-16
lines changed

sqllogic/demo.test

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
query I nosort
2+
SELECT 1<2, 2<1, 1/0, 'NaN', 'undefined', '', 2, 1.1234, 1.123, 1.12
3+
----
4+
1
5+
0
6+
NULL
7+
null
8+
null
9+
(empty)
10+
2
11+
1.123
12+
1.123
13+
1.120
14+
15+
16+
halt
17+
18+
19+
20+
21+
122
# So far, this only runs well on SQLite and MySQL.
223

324
# skip this entire file if ms sql server

sqllogic/parser.peg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
PEG.JS gramma for sqllogictest files as described at http://www.sqlite.org/sqllogictest/doc/trunk/about.wiki
3+
By Mathias Rangel Wulff
34
*/
45

56
{
@@ -111,7 +112,7 @@ resultHash
111112

112113

113114
resultList
114-
= list:(v:$[^\n]+ (nl/!.){if('NULL' === v){v = null};return v})+
115+
= list:(v:$[^\n]+ (nl/!.){if(v.match(/NULL/i)){v = null};return v})+
115116
{
116117
return {
117118
type:'list',

sqllogic/run_md.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,27 @@ var testfiles = walkFiles(
4444

4545
//What databases to mimic when running tests
4646
var mimic = [
47+
'unknown',
4748
'sqlite',
4849
'postgresql',
4950
'mssql',
5051
'oracle',
51-
'mysql',
52-
'Unspecified DB'
52+
'mysql'
5353
]
5454

5555

56+
var runOnlyDemo = true;
5657

5758
//////////////////////////// CONFIG END /////////////////////////////////////
5859

5960

6061

6162

63+
if(runOnlyDemo){
64+
mimic = [mimic[0]];
65+
testfiles=["./demo.test"];
66+
}
6267

63-
64-
//testfiles=["./demo.test"]
6568
alasql.options.modifier = "MATRIX";
6669
alasql.options.cache = false;
6770
var mimicking = 0;
@@ -266,7 +269,7 @@ function runSQLtestFromFile(path, db, mimic){
266269
} else {
267270
score.fail.total++;
268271

269-
//console.log(test)
272+
270273

271274
var errHash = test.msg.split('-----^').pop()/*.split("'").unshift()*/.replace(/[^a-z]/mig, '')
272275

@@ -293,16 +296,21 @@ function verifyTest(fragment, db){
293296
//console.log('-----------------------------------------------')
294297
var req = runTest(fragment.sql, db)
295298
req.ok = (fragment.expectSuccess === req.success)
299+
300+
296301

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
298303
if(fragment.result && req.success && req.ok){
299304
var ok;
305+
306+
console.log(req.result)
300307
req.result = cleanResults(req.result)
301-
//console.log(fragment.result)
302-
//console.log(fragment.sql)
303-
//console.log(req.result)
304308

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)){
306314
req.msg = 'Query was expected to return results (but did not): '+JSON.stringify(req.result)
307315
req.ok = false
308316
}else if('list' === fragment.result.type){
@@ -314,7 +322,7 @@ if(false) // Converting returned values to expected result is still creating too
314322
req.msg = 'Expected: '+JSON.stringify(fragment.result.values)+' but got '+JSON.stringify(req.result);
315323
//console.log('Expected:',fragment.result.values,'but got', req.result );
316324
//console.log();
317-
//req.ok = ok
325+
req.ok = ok
318326
}
319327

320328

@@ -367,13 +375,22 @@ function cleanResults(result){
367375
return "1";
368376
}else if(false === x){
369377
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;
372384
}else if('' === x){
373385
return "(empty)";
374386
}
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
377394
return (''+x).replace(/[\n\r\t\x00\x08\x0B\x0C\x0E-\x1F\x7F]/gim, '@');
378395
});
379396

0 commit comments

Comments
 (0)