@@ -356,4 +356,145 @@ void main() {}
356356 expect (File (outFile).existsSync (), true ,
357357 reason: 'File not found: $outFile ' );
358358 });
359+
360+ test ('Compile AOT snapshot with sound null safety' , () {
361+ final p = project (mainSrc: '''void main() {}''' );
362+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
363+ final outFile = path.canonicalize (path.join (p.dirPath, 'myaot' ));
364+
365+ var result = p.runSync (
366+ [
367+ 'compile' ,
368+ 'aot-snapshot' ,
369+ '-o' ,
370+ outFile,
371+ inFile,
372+ ],
373+ );
374+
375+ expect (result.stdout, contains (soundNullSafetyMessage));
376+ expect (result.stderr, isEmpty);
377+ expect (result.exitCode, 0 );
378+ expect (File (outFile).existsSync (), true ,
379+ reason: 'File not found: $outFile ' );
380+ });
381+
382+ test ('Compile AOT snapshot with unsound null safety' , () {
383+ final p = project (mainSrc: '''
384+ // @dart=2.9
385+ void main() {}
386+ ''' );
387+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
388+ final outFile = path.canonicalize (path.join (p.dirPath, 'myaot' ));
389+
390+ var result = p.runSync (
391+ [
392+ 'compile' ,
393+ 'aot-snapshot' ,
394+ '-o' ,
395+ outFile,
396+ inFile,
397+ ],
398+ );
399+
400+ expect (result.stdout, contains (unsoundNullSafetyMessage));
401+ expect (result.stderr, isEmpty);
402+ expect (result.exitCode, 0 );
403+ expect (File (outFile).existsSync (), true ,
404+ reason: 'File not found: $outFile ' );
405+ });
406+
407+ test ('Compile kernel with sound null safety' , () {
408+ final p = project (mainSrc: '''void main() {}''' );
409+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
410+ final outFile = path.canonicalize (path.join (p.dirPath, 'mydill' ));
411+
412+ var result = p.runSync (
413+ [
414+ 'compile' ,
415+ 'kernel' ,
416+ '-o' ,
417+ outFile,
418+ inFile,
419+ ],
420+ );
421+
422+ expect (result.stdout, contains (soundNullSafetyMessage));
423+ expect (result.stderr, isEmpty);
424+ expect (result.exitCode, 0 );
425+ expect (File (outFile).existsSync (), true ,
426+ reason: 'File not found: $outFile ' );
427+ });
428+
429+ test ('Compile kernel with unsound null safety' , () {
430+ final p = project (mainSrc: '''
431+ // @dart=2.9
432+ void main() {}
433+ ''' );
434+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
435+ final outFile = path.canonicalize (path.join (p.dirPath, 'mydill' ));
436+
437+ var result = p.runSync (
438+ [
439+ 'compile' ,
440+ 'kernel' ,
441+ '-o' ,
442+ outFile,
443+ inFile,
444+ ],
445+ );
446+
447+ expect (result.stdout, contains (unsoundNullSafetyMessage));
448+ expect (result.stderr, isEmpty);
449+ expect (result.exitCode, 0 );
450+ expect (File (outFile).existsSync (), true ,
451+ reason: 'File not found: $outFile ' );
452+ });
453+
454+ test ('Compile JIT snapshot with sound null safety' , () {
455+ final p = project (mainSrc: '''void main() {}''' );
456+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
457+ final outFile = path.canonicalize (path.join (p.dirPath, 'myjit' ));
458+
459+ var result = p.runSync (
460+ [
461+ 'compile' ,
462+ 'jit-snapshot' ,
463+ '-o' ,
464+ outFile,
465+ inFile,
466+ ],
467+ );
468+
469+ expect (result.stdout, contains (soundNullSafetyMessage));
470+ expect (result.stderr, isEmpty);
471+ expect (result.exitCode, 0 );
472+ expect (File (outFile).existsSync (), true ,
473+ reason: 'File not found: $outFile ' );
474+ });
475+
476+ test ('Compile JIT snapshot with unsound null safety' , () {
477+ final p = project (mainSrc: '''
478+ // @dart=2.9
479+ void main() {}
480+ ''' );
481+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
482+ final outFile = path.canonicalize (path.join (p.dirPath, 'myjit' ));
483+
484+ var result = p.runSync (
485+ [
486+ 'compile' ,
487+ 'jit-snapshot' ,
488+ '-o' ,
489+ outFile,
490+ inFile,
491+ ],
492+ );
493+
494+ expect (result.stdout, contains (unsoundNullSafetyMessage));
495+ expect (result.stderr, isEmpty);
496+ expect (result.exitCode, 0 );
497+ expect (File (outFile).existsSync (), true ,
498+ reason: 'File not found: $outFile ' );
499+ });
359500}
0 commit comments