Skip to content

Commit cf268d9

Browse files
committed
Add soft cast syntax compile test
1 parent e889605 commit cf268d9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/java/com/laytonsmith/core/MethodScriptCompilerTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,4 +1422,26 @@ public void testInvalidFQCNTypingCompileFailsStrict() throws Exception {
14221422
sa.setLocalEnable(true);
14231423
MethodScriptCompiler.compile(MethodScriptCompiler.lex(script, env, null, true), env, env.getEnvClasses(), sa);
14241424
}
1425+
1426+
@Test
1427+
public void testSoftCastSyntaxCompiles() throws Exception {
1428+
String script = """
1429+
<!strict>
1430+
int @a = (int) 1;
1431+
number @b = (int) 1;
1432+
mixed @c = (ms.lang.int) 1;
1433+
int @d = (int) (1);
1434+
int @e = (ms.lang.int) 1;
1435+
int @f = (int) (1 + 2);
1436+
int @g = (int) 1 + 2;
1437+
msg((string) 'Hello World!');
1438+
msg((string) 'Hello '.(string) 'World!');
1439+
mixed @h = (number) (int) 1;
1440+
mixed @i = (mixed) (number) (int) (int) (int) 1;
1441+
""";
1442+
Environment env = Static.GenerateStandaloneEnvironment();
1443+
StaticAnalysis sa = new StaticAnalysis(true);
1444+
sa.setLocalEnable(true);
1445+
MethodScriptCompiler.compile(MethodScriptCompiler.lex(script, env, null, true), env, env.getEnvClasses(), sa);
1446+
}
14251447
}

0 commit comments

Comments
 (0)