Skip to content

Commit cb204d7

Browse files
Daniil KlimovGrayJack
Daniil Klimov
authored andcommitted
Added tests for as keyword inside array into structs
1 parent ccc1229 commit cb204d7

File tree

11 files changed

+195
-0
lines changed

11 files changed

+195
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
some_fn;
3+
};

tests/expectations/as_ty.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdarg.h>
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
#include <stdlib.h>
5+
6+
#define SIZE 4
7+
8+
typedef struct {
9+
uint32_t items[SIZE];
10+
} WithoutAs;
11+
12+
typedef struct {
13+
uint32_t items[SIZE];
14+
} WithAs;
15+
16+
void some_fn(WithoutAs a, WithAs b);

tests/expectations/as_ty.compat.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdarg.h>
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
#include <stdlib.h>
5+
6+
#define SIZE 4
7+
8+
typedef struct {
9+
uint32_t items[SIZE];
10+
} WithoutAs;
11+
12+
typedef struct {
13+
uint32_t items[SIZE];
14+
} WithAs;
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif // __cplusplus
19+
20+
void some_fn(WithoutAs a, WithAs b);
21+
22+
#ifdef __cplusplus
23+
} // extern "C"
24+
#endif // __cplusplus

tests/expectations/as_ty.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <cstdarg>
2+
#include <cstdint>
3+
#include <cstdlib>
4+
#include <ostream>
5+
#include <new>
6+
7+
constexpr static const intptr_t SIZE = 4;
8+
9+
struct WithoutAs {
10+
uint32_t items[SIZE];
11+
};
12+
13+
struct WithAs {
14+
uint32_t items[SIZE];
15+
};
16+
17+
extern "C" {
18+
19+
void some_fn(WithoutAs a, WithAs b);
20+
21+
} // extern "C"

tests/expectations/as_ty.pyx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
2+
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
3+
cdef extern from *:
4+
ctypedef bint bool
5+
ctypedef struct va_list
6+
7+
cdef extern from *:
8+
9+
const intptr_t SIZE # = 4
10+
11+
ctypedef struct WithoutAs:
12+
uint32_t items[SIZE];
13+
14+
ctypedef struct WithAs:
15+
uint32_t items[SIZE];
16+
17+
void some_fn(WithoutAs a, WithAs b);

tests/expectations/as_ty_both.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdarg.h>
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
#include <stdlib.h>
5+
6+
#define SIZE 4
7+
8+
typedef struct WithoutAs {
9+
uint32_t items[SIZE];
10+
} WithoutAs;
11+
12+
typedef struct WithAs {
13+
uint32_t items[SIZE];
14+
} WithAs;
15+
16+
void some_fn(struct WithoutAs a, struct WithAs b);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdarg.h>
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
#include <stdlib.h>
5+
6+
#define SIZE 4
7+
8+
typedef struct WithoutAs {
9+
uint32_t items[SIZE];
10+
} WithoutAs;
11+
12+
typedef struct WithAs {
13+
uint32_t items[SIZE];
14+
} WithAs;
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif // __cplusplus
19+
20+
void some_fn(struct WithoutAs a, struct WithAs b);
21+
22+
#ifdef __cplusplus
23+
} // extern "C"
24+
#endif // __cplusplus

tests/expectations/as_ty_tag.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdarg.h>
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
#include <stdlib.h>
5+
6+
#define SIZE 4
7+
8+
struct WithoutAs {
9+
uint32_t items[SIZE];
10+
};
11+
12+
struct WithAs {
13+
uint32_t items[SIZE];
14+
};
15+
16+
void some_fn(struct WithoutAs a, struct WithAs b);

tests/expectations/as_ty_tag.compat.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdarg.h>
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
#include <stdlib.h>
5+
6+
#define SIZE 4
7+
8+
struct WithoutAs {
9+
uint32_t items[SIZE];
10+
};
11+
12+
struct WithAs {
13+
uint32_t items[SIZE];
14+
};
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif // __cplusplus
19+
20+
void some_fn(struct WithoutAs a, struct WithAs b);
21+
22+
#ifdef __cplusplus
23+
} // extern "C"
24+
#endif // __cplusplus

tests/expectations/as_ty_tag.pyx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
2+
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
3+
cdef extern from *:
4+
ctypedef bint bool
5+
ctypedef struct va_list
6+
7+
cdef extern from *:
8+
9+
const intptr_t SIZE # = 4
10+
11+
cdef struct WithoutAs:
12+
uint32_t items[SIZE];
13+
14+
cdef struct WithAs:
15+
uint32_t items[SIZE];
16+
17+
void some_fn(WithoutAs a, WithAs b);

tests/rust/as_ty.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub const SIZE: isize = 4;
2+
3+
#[repr(C)]
4+
pub struct WithoutAs {
5+
items: [char; SIZE as usize],
6+
}
7+
8+
#[repr(C)]
9+
pub struct WithAs {
10+
items: [char; SIZE as usize],
11+
}
12+
13+
// dummy function to make `WithoutAs` and `WithAs` part of the public api
14+
#[no_mangle]
15+
pub extern fn some_fn(a: WithoutAs, b: WithAs) {
16+
17+
}

0 commit comments

Comments
 (0)