-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathCodeGenDeclarationsTests.cs
More file actions
55 lines (46 loc) · 1.06 KB
/
CodeGenDeclarationsTests.cs
File metadata and controls
55 lines (46 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-FileCopyrightText: 2025 Cesium contributors <https://github.com/ForNeVeR/Cesium>
//
// SPDX-License-Identifier: MIT
using JetBrains.Annotations;
namespace Cesium.CodeGen.Tests;
public class CodeGenDeclarationsTests : CodeGenTestBase
{
[MustUseReturnValue]
private static Task DoTest(string source)
{
var assembly = GenerateAssembly(default, source);
var moduleType = assembly.Modules.Single().GetType("<Module>");
return VerifyMethods(moduleType);
}
[Fact]
public Task StaticDeclarationsInDifferentFunctions() => DoTest(
@"int main()
{
static int i = 0;
}
int test()
{
static int i = 2;
}");
[Fact]
public Task StaticDeclarationsFuncionAndGlobalContext() => DoTest(
@"int main()
{
static int i = 0;
}
static int i = 2;
");
[Fact]
public Task ConstTypeDef() => DoTest(
@"
typedef int myint;
static const myint i = 0;");
[Fact]
public Task AnonymousUnionVariableInsideFunction() => DoTest(
@"int main()
{
union {int i;} t;
t.i = 0;
}
");
}