@@ -9,6 +9,65 @@ namespace TestCompiler;
99[ TestClass ]
1010public partial class BlacklistTest
1111{
12+
13+ [ TestMethod ]
14+ public async Task DefaultCompilerFailsWhitelist ( )
15+ {
16+ var codePath = System . IO . Path . GetFullPath ( "data/code/blacklist" ) ;
17+ var group = new CompileGroup ( "TestWhitelist" ) ;
18+
19+ var compiler = group . GetOrCreateCompiler ( "test" ) ;
20+ compiler . AddSourcePath ( codePath ) ;
21+ compiler . MarkForRecompile ( ) ;
22+ await group . BuildAsync ( ) ;
23+
24+ // Verify compilation failed due to whitelist violations
25+ var output = compiler . Output ;
26+ Assert . IsNotNull ( output ) ;
27+ Assert . IsFalse ( output . Successful , "Compiler should fail with default whitelist settings" ) ;
28+ Assert . IsTrue ( output . Diagnostics . Count > 0 , "Should have diagnostics for whitelist violations" ) ;
29+ }
30+
31+ [ TestMethod ]
32+ public async Task CompilerWithWhitelistFails ( )
33+ {
34+ var codePath = System . IO . Path . GetFullPath ( "data/code/blacklist" ) ;
35+ var group = new CompileGroup ( "TestWhitelist" ) ;
36+
37+ var compilerSettings = new Compiler . Configuration ( ) ;
38+ compilerSettings . Whitelist = true ;
39+ compilerSettings . Unsafe = false ;
40+
41+ var compiler = group . CreateCompiler ( "test" , codePath , compilerSettings ) ;
42+ await group . BuildAsync ( ) ;
43+
44+ // Verify compilation failed due to whitelist being enabled
45+ var output = compiler . Output ;
46+ Assert . IsNotNull ( output ) ;
47+ Assert . IsFalse ( output . Successful , "Compiler should fail when whitelist is explicitly enabled" ) ;
48+ Assert . IsTrue ( output . Diagnostics . Count > 0 , "Should have diagnostics for whitelist violations" ) ;
49+ }
50+
51+ [ TestMethod ]
52+ public async Task CompilerWithoutWhitelistSucceeds ( )
53+ {
54+ var codePath = System . IO . Path . GetFullPath ( "data/code/blacklist" ) ;
55+ var group = new CompileGroup ( "TestWhitelist" ) ;
56+
57+ var compilerSettings = new Compiler . Configuration ( ) ;
58+ compilerSettings . Whitelist = false ;
59+ compilerSettings . Unsafe = true ;
60+
61+ var compiler = group . CreateCompiler ( "test" , codePath , compilerSettings ) ;
62+ await group . BuildAsync ( ) ;
63+
64+ // Verify compilation succeeded with whitelist disabled
65+ var output = compiler . Output ;
66+ Assert . IsNotNull ( output ) ;
67+ Assert . IsTrue ( output . Successful , "Compiler should succeed when whitelist is disabled" ) ;
68+ Assert . IsNull ( output . Exception , "Should not have any exceptions" ) ;
69+ }
70+
1271 [ TestMethod ]
1372 public async Task EndToEndBuildFailure ( )
1473 {
0 commit comments