const fs=require('fs'),vm=require('vm'); const src=fs.readFileSync('engine.js','utf8'); const grab=(n)=>{const i=src.indexOf('function '+n+'(');let d=0;for(let k=src.indexOf('{',i);k{const got=sb.splitSentences(input);const ok=JSON.stringify(got)===JSON.stringify(want); console.log((ok?' PASS ':' FAIL ')+label); if(!ok)console.log(' got '+JSON.stringify(got)+'\n want '+JSON.stringify(want)); ok?pass++:fail++;}; console.log('\nAMEN MUST SURVIVE'); t('amen after a sentence','God is good. Amen.',['God is good.','Amen.']); t('amen alone','Amen.',['Amen.']); t('two short sentences','Jesus wept. Amen.',['Jesus wept.','Amen.']); t('hallelujah trailing','God is faithful. Hallelujah!',['God is faithful.','Hallelujah!']); t('three shorts','Yes. Amen. Hallelujah.',['Yes.','Amen.','Hallelujah.']); console.log('\nWHAT THE GLUE RULE WAS PROTECTING'); t('leading abbreviation','Dr. King said God is good.',['Dr. King said God is good.']); t('mid abbreviation','We heard Dr. King speak today.',['We heard Dr. King speak today.']); t('single initial','C. S. Lewis wrote that.',['C. S. Lewis wrote that.']); t('decimal rejoined','It cost 3.5 million.',['It cost 3.5 million.']); t('verse decimal','Read John 3.16 today.',['Read John 3.16 today.']); t('saint','St. Paul wrote it.',['St. Paul wrote it.']); console.log('\nORDINARY TEXT UNCHANGED'); t('one sentence','Today we are going to talk about Peter in the Bible.', ['Today we are going to talk about Peter in the Bible.']); t('two full sentences','God is love. He gave His only Son.',['God is love.','He gave His only Son.']); t('question','Do you believe that? I do.',['Do you believe that?','I do.']); t('semicolon stays','The Lord is my shepherd; I shall not want.', ['The Lord is my shepherd; I shall not want.']); console.log('\n'+pass+' passed, '+fail+' failed'); process.exit(fail?1:0);