Skip to content

Commit

Permalink
Add test case for MatAtBread/nodent#108 (fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
matAtWork committed May 2, 2018
1 parent b4bcd0c commit 155e0ef
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodent-compiler",
"version": "3.2.4",
"version": "3.2.5",
"description": "NoDent - Asynchronous Javascript language extensions",
"main": "compiler.js",
"scripts": {
Expand All @@ -9,7 +9,7 @@
"dependencies": {
"acorn": ">=2.5.2",
"acorn-es7-plugin": "^1.1.7",
"nodent-transform": "^3.2.4",
"nodent-transform": "^3.2.5",
"source-map": "^0.5.7"
},
"devDependencies": {
Expand Down
16 changes: 13 additions & 3 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (!('Promise' in global)){

var fs = require('fs') ;
var args = process.argv.slice(2) ;
var passed = 0, failed = 0 ;
var passed = 0, failed = 0, impossible = 0 ;
var complete, p = new Promise(function(r){ complete = r }) ;
var options = [
{ sourcemap:false, promises: true, noRuntime: true },
Expand All @@ -26,6 +26,14 @@ var options = [
] ;
var totalTests = args.length*options.length ;

if (!Object.assign) {
Object.assign = function(d,s) {
Object.keys(s).forEach(function(k){
d[k] = s[k] ;
});
};
}

function check(file,sample,syncValue) {
if (syncValue===undefined)
throw new Error("undefined sync result") ;
Expand Down Expand Up @@ -74,11 +82,13 @@ for (var idx = 0; idx <args.length; idx++) (function(){
else
check(fileName,sample,s) ;
} catch(ex) {
console.log(fileName,"\tRequires a later version of nodejs to test",ex) ;
failed += options.length ;
impossible += options.length ;
console.log("FAIL",fileName,"requires a later version of nodejs",ex) ;
}
})();

p.then(function(){
console.log(passed+" test(s) passed") ;
failed && console.log(failed+" test(s) FAILED") ;
failed && console.log(failed+" test(s) FAILED",impossible ? "(of which "+impossible+" expected a later version of node)":"") ;
},$error) ;
17 changes: 17 additions & 0 deletions tests/semantics/dual-while-decl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
async function nop(x) { return x }
var resolve,p = new Promise(function(r){resolve = r}) ;
var i = 0, x = 0, s = 1 ;
while (i<5) {
const j = i+1 ;
await nop() ;
setTimeout(function(){
x += 1 ;
s *= j ;
if (x===5) {
resolve(s) ;
}
}, 0);
i++ ;
}

return await p ;

0 comments on commit 155e0ef

Please sign in to comment.