@@ -6,7 +6,7 @@ import { globSync } from "glob";
66import { diff } from "../util/text.js" ;
77import { stdoutColors } from "../util/terminal.js" ;
88import * as optionsUtil from "../util/options.js" ;
9- import { Program , Options , ASTBuilder } from "../dist/assemblyscript.js" ;
9+ import { Program , Options , ASTBuilder , Feature } from "../dist/assemblyscript.js" ;
1010
1111const dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
1212
@@ -54,16 +54,28 @@ if (argv.length) {
5454}
5555
5656let failures = 0 ;
57+ const parserTestFeatures = new Map ( [
58+ [ "tuple.ts" , [ Feature . MultiValue ] ] ,
59+ [ "tuple-more.ts" , [ Feature . MultiValue ] ] ,
60+ [ "tuple-errors.ts" , [ Feature . MultiValue ] ]
61+ ] ) ;
5762
5863for ( const filename of tests ) {
5964 if ( filename . charAt ( 0 ) == "_" || filename . endsWith ( ".fixture.ts" ) ) continue ;
6065
6166 console . log ( stdoutColors . white ( "Testing parser/" + filename ) ) ;
6267
6368 let failed = false ;
64- const program = new Program ( new Options ( ) ) ;
65- const parser = program . parser ;
69+ const options = new Options ( ) ;
6670 const sourceText = fs . readFileSync ( basedir + "/" + filename , { encoding : "utf8" } ) . replace ( / \r ? \n / g, "\n" ) ;
71+ const features = parserTestFeatures . get ( filename ) ;
72+ if ( features ) {
73+ for ( const feature of features ) {
74+ options . setFeature ( feature ) ;
75+ }
76+ }
77+ const program = new Program ( options ) ;
78+ const parser = program . parser ;
6779 parser . parseFile ( sourceText , filename , true ) ;
6880 const serializedSourceText = ASTBuilder . build ( program . sources [ 0 ] ) ;
6981 const actual = serializedSourceText + parser . diagnostics . map ( diagnostic => "// " + diagnostic + "\n" ) . join ( "" ) ;
0 commit comments