@@ -28,16 +28,16 @@ var fs = require('fs'),
2828 acorn = require ( 'acorn' ) ,
2929 escodegen = require ( './loader' ) ,
3030 chai = require ( 'chai' ) ,
31+ chaiExclude = require ( 'chai-exclude' ) ,
3132 expect = chai . expect ;
3233
33- function test ( code , expected ) {
34- var tree , actual , options , StringObject ;
34+ chai . use ( chaiExclude ) ;
3535
36- // alias, so that JSLint does not complain.
37- StringObject = String ;
36+ function test ( code , expected ) {
37+ var tree , actual , actualTree , options ;
3838
3939 options = {
40- ranges : true ,
40+ ranges : false ,
4141 locations : false ,
4242 ecmaVersion : 11 ,
4343 sourceType : 'module'
@@ -46,18 +46,18 @@ function test(code, expected) {
4646 tree = acorn . parse ( code , options ) ;
4747
4848 // for UNIX text comment
49- actual = escodegen . generate ( tree ) . replace ( / [ \n \r ] $ / , '' ) + '\n' ;
49+ actual = escodegen . generate ( tree ) ;
50+ actualTree = acorn . parse ( actual , options ) ;
51+
5052 expect ( actual ) . to . be . equal ( expected ) ;
53+ expect ( tree ) . excludingEvery ( [ 'start' , 'end' ] ) . to . deep . equal ( actualTree ) ;
5154}
5255
5356function testMin ( code , expected ) {
54- var tree , actual , options , StringObject ;
55-
56- // alias, so that JSLint does not complain.
57- StringObject = String ;
57+ var tree , actual , actualTree , options ;
5858
5959 options = {
60- ranges : true ,
60+ ranges : false ,
6161 locations : false ,
6262 ecmaVersion : 11 ,
6363 sourceType : 'module'
@@ -70,7 +70,10 @@ function testMin(code, expected) {
7070 format : escodegen . FORMAT_MINIFY ,
7171 raw : false
7272 } ) . replace ( / [ \n \r ] $ / , '' ) + '\n' ;
73+ actualTree = acorn . parse ( actual , options ) ;
74+
7375 expect ( actual ) . to . be . equal ( expected ) ;
76+ expect ( tree ) . excludingEvery ( [ 'start' , 'end' ] ) . to . deep . equal ( actualTree ) ;
7477}
7578
7679describe ( 'compare acorn es2020 test' , function ( ) {
@@ -91,4 +94,4 @@ describe('compare acorn es2020 test', function () {
9194 }
9295 } ) ;
9396} ) ;
94- /* vim: set sw=4 ts=4 et tw=80 : */
97+ /* vim: set sw=4 ts=4 et tw=80 : */
0 commit comments