Skip to content

Commit 2def8c2

Browse files
committed
added files missing in previous commit
1 parent 15dbf22 commit 2def8c2

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

test/TestAnonymousStruct/A.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
struct {
2+
int i;
3+
} s_global;
4+
5+
class A {
6+
struct {
7+
int i;
8+
} s_private;
9+
10+
public:
11+
struct {
12+
int i;
13+
} s_public;
14+
15+
struct {
16+
int j;
17+
};
18+
19+
struct S_public_named_type {
20+
int k = 5;
21+
} s_public_named;
22+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(TestAnonymousStruct)
4+
5+
set(WRAPPER_EXTRA_SRCS)
6+
7+
# All of the real work is done in the lower level CMake file
8+
include(../WrapitTestSetup.cmake)

test/TestAnonymousStruct/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#CXXFLAGS += -DVERBOSE_IMPORT #To enable the verbose mode of the libray loading
2+
#CXXFLAGS += -Wall -O0 -g #To compile with debugger infomation
3+
4+
MODULE_NAME=TestAnonymousStruct
5+
6+
-include ../make.rules
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module_name="TestAnonymousStruct"
2+
uuid = "28eb9369-de4c-45bd-ac6f-8997959d6fdf"
3+
4+
input = [ "A.h" ]
5+
6+
include_dirs = [ "." ]
7+
8+
cxx-std = "c++17"
9+
10+
auto_veto = false
11+
12+
export = "all"
13+
14+
# all generated code in a single file:
15+
n_classes_per_file = 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env julia
2+
3+
TEST_SCRIPT="runTestAnonymousStruct.jl"
4+
5+
#number of cores to use for code compilation
6+
ncores=Sys.CPU_THREADS
7+
8+
# Generate the wrapper and build the shared library:
9+
run(`cmake -B build .`)
10+
run(`cmake --build build -j $ncores`)
11+
12+
# Execute the test
13+
include(TEST_SCRIPT)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Test
2+
using Serialization
3+
4+
import Pkg
5+
Pkg.activate("$(@__DIR__)/build")
6+
Pkg.develop(path="$(@__DIR__)/build/TestAnonymousStruct")
7+
using TestAnonymousStruct
8+
9+
function runtest()
10+
@testset "AnonymousStructs" begin
11+
@test_throws UndefVarError TestAnonymousStruct.s_global
12+
@test_throws UndefVarError TestAnonymousStruct.s_private
13+
@test_throws UndefVarError TestAnonymousStruct.s_public
14+
@test_throws UndefVarError TestAnonymousStruct.i
15+
@test_throws UndefVarError TestAnonymousStruct.j
16+
s = TestAnonymousStruct.A()
17+
@test s |> s_public_named |> k == 5;
18+
@test names(TestAnonymousStruct) == [:A, :A!S_public_named_type, :TestAnonymousStruct, :k, :k!, :s_public_named, :s_public_named!]
19+
end
20+
end
21+
22+
if "-s" in ARGS #Serialize mode
23+
Test.TESTSET_PRINT_ENABLE[] = false
24+
serialize(stdout, runtest())
25+
else
26+
runtest()
27+
end

0 commit comments

Comments
 (0)