@@ -21,7 +21,7 @@ let compileOptions = null;
21
21
let compile = null ;
22
22
23
23
function getName ( filename ) {
24
- const base = path . basename ( filename ) . replace ( ".html" , "" ) ;
24
+ const base = path . basename ( filename ) . replace ( '-v2' , '' ) . replace ( ".html" , "" ) ;
25
25
return base [ 0 ] . toUpperCase ( ) + base . slice ( 1 ) ;
26
26
}
27
27
@@ -46,7 +46,7 @@ describe("runtime", () => {
46
46
47
47
const failed = new Set ( ) ;
48
48
49
- function runTest ( dir , shared , hydrate ) {
49
+ function runTest ( dir , shared , hydrate , v2 ) {
50
50
if ( dir [ 0 ] === "." ) return ;
51
51
52
52
const config = loadConfig ( `./runtime/samples/${ dir } /_config.js` ) ;
@@ -55,7 +55,7 @@ describe("runtime", () => {
55
55
throw new Error ( "Forgot to remove `solo: true` from test" ) ;
56
56
}
57
57
58
- ( config . skip ? it . skip : config . solo ? it . only : it ) ( `${ dir } (${ shared ? 'shared' : 'inline' } helpers${ hydrate ? ' , hydration' : '' } )` , ( ) => {
58
+ ( config . skip ? it . skip : config . solo ? it . only : it ) ( `${ dir } (${ shared ? 'shared' : 'inline' } helpers${ hydrate ? ', hydration' : '' } ${ v2 ? ', v2 ' : '' } )` , ( ) => {
59
59
if ( failed . has ( dir ) ) {
60
60
// this makes debugging easier, by only printing compiled output once
61
61
throw new Error ( 'skipping test, already failed' ) ;
@@ -72,12 +72,13 @@ describe("runtime", () => {
72
72
compileOptions . dev = config . dev ;
73
73
compileOptions . store = ! ! config . store ;
74
74
compileOptions . immutable = config . immutable ;
75
+ compileOptions . parser = v2 ? 'v2' : 'v1' ;
75
76
76
77
// check that no ES2015+ syntax slipped in
77
78
if ( ! config . allowES2015 ) {
78
79
try {
79
80
const source = fs . readFileSync (
80
- `test/runtime/samples/${ dir } /main.html` ,
81
+ `test/runtime/samples/${ dir } /main${ v2 ? '-v2' : '' } .html` ,
81
82
"utf-8"
82
83
) ;
83
84
const { code } = compile ( source , compileOptions ) ;
@@ -100,7 +101,7 @@ describe("runtime", () => {
100
101
if ( err . frame ) {
101
102
console . error ( chalk . red ( err . frame ) ) ; // eslint-disable-line no-console
102
103
}
103
- showOutput ( cwd , { shared, format : 'cjs' , store : ! ! compileOptions . store } , compile ) ; // eslint-disable-line no-console
104
+ showOutput ( cwd , { shared, format : 'cjs' , store : ! ! compileOptions . store , v2 } , compile ) ; // eslint-disable-line no-console
104
105
throw err ;
105
106
}
106
107
}
@@ -143,7 +144,7 @@ describe("runtime", () => {
143
144
} ;
144
145
145
146
try {
146
- SvelteComponent = require ( `./samples/${ dir } /main.html` ) ;
147
+ SvelteComponent = require ( `./samples/${ dir } /main${ v2 ? '-v2' : '' } .html` ) ;
147
148
} catch ( err ) {
148
149
showOutput ( cwd , { shared, format : 'cjs' , hydratable : hydrate , store : ! ! compileOptions . store } , compile ) ; // eslint-disable-line no-console
149
150
throw err ;
@@ -203,12 +204,12 @@ describe("runtime", () => {
203
204
config . error ( assert , err ) ;
204
205
} else {
205
206
failed . add ( dir ) ;
206
- showOutput ( cwd , { shared, format : 'cjs' , hydratable : hydrate , store : ! ! compileOptions . store } , compile ) ; // eslint-disable-line no-console
207
+ showOutput ( cwd , { shared, format : 'cjs' , hydratable : hydrate , store : ! ! compileOptions . store , v2 } , compile ) ; // eslint-disable-line no-console
207
208
throw err ;
208
209
}
209
210
} )
210
211
. then ( ( ) => {
211
- if ( config . show ) showOutput ( cwd , { shared, format : 'cjs' , hydratable : hydrate , store : ! ! compileOptions . store } , compile ) ;
212
+ if ( config . show ) showOutput ( cwd , { shared, format : 'cjs' , hydratable : hydrate , store : ! ! compileOptions . store , v2 } , compile ) ;
212
213
} ) ;
213
214
} ) ;
214
215
}
@@ -218,6 +219,10 @@ describe("runtime", () => {
218
219
runTest ( dir , shared , false ) ;
219
220
runTest ( dir , shared , true ) ;
220
221
runTest ( dir , null , false ) ;
222
+
223
+ if ( fs . existsSync ( `test/runtime/samples/${ dir } /main-v2.html` ) ) {
224
+ runTest ( dir , shared , false , true ) ;
225
+ }
221
226
} ) ;
222
227
223
228
it ( "fails if options.target is missing in dev mode" , ( ) => {
0 commit comments