@@ -310,6 +310,74 @@ void main() {}
310310 reason: 'File not found: $outFile ' );
311311 });
312312
313+ test ('Compile and run exe with --sound-null-safety' , () {
314+ final p = project (mainSrc: '''void main() {
315+ print((<int?>[] is List<int>) ? 'oh no' : 'sound');
316+ }''' );
317+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
318+ final outFile = path.canonicalize (path.join (p.dirPath, 'myexe' ));
319+
320+ var result = p.runSync (
321+ [
322+ 'compile' ,
323+ 'exe' ,
324+ '--sound-null-safety' ,
325+ '-o' ,
326+ outFile,
327+ inFile,
328+ ],
329+ );
330+
331+ expect (result.stderr, isEmpty);
332+ expect (result.stdout, contains (soundNullSafetyMessage));
333+ expect (result.exitCode, 0 );
334+ expect (File (outFile).existsSync (), true ,
335+ reason: 'File not found: $outFile ' );
336+
337+ result = Process .runSync (
338+ outFile,
339+ [],
340+ );
341+
342+ expect (result.stdout, contains ('sound' ));
343+ expect (result.stderr, isEmpty);
344+ expect (result.exitCode, 0 );
345+ });
346+
347+ test ('Compile and run exe with --no-sound-null-safety' , () {
348+ final p = project (mainSrc: '''void main() {
349+ print((<int?>[] is List<int>) ? 'unsound' : 'oh no');
350+ }''' );
351+ final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
352+ final outFile = path.canonicalize (path.join (p.dirPath, 'myexe' ));
353+
354+ var result = p.runSync (
355+ [
356+ 'compile' ,
357+ 'exe' ,
358+ '--no-sound-null-safety' ,
359+ '-o' ,
360+ outFile,
361+ inFile,
362+ ],
363+ );
364+
365+ expect (result.stderr, isEmpty);
366+ expect (result.stdout, contains (unsoundNullSafetyMessage));
367+ expect (result.exitCode, 0 );
368+ expect (File (outFile).existsSync (), true ,
369+ reason: 'File not found: $outFile ' );
370+
371+ result = Process .runSync (
372+ outFile,
373+ [],
374+ );
375+
376+ expect (result.stdout, contains ('unsound' ));
377+ expect (result.stderr, isEmpty);
378+ expect (result.exitCode, 0 );
379+ });
380+
313381 test ('Compile exe without info' , () {
314382 final p = project (mainSrc: '''void main() {}''' );
315383 final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
0 commit comments