Skip to content

Commit 97273d1

Browse files
committed
Fix unit tests
1 parent b8170d5 commit 97273d1

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

Examples/test-suite/fortran/arrays_global_twodim_runme.F90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ subroutine test_int_array
1818
integer(C_INT) :: cnt = 10
1919
integer(C_INT) :: x, y
2020
integer(C_INT), dimension(:,:), allocatable :: expected, actual
21+
integer(C_INT), dimension(2) :: dims
2122

23+
dims = [get_ARRAY_LEN_Y(), get_ARRAY_LEN_X()]
2224
constintarray2d = get_array_const_i()
2325
intarray2d = get_array_i()
2426

2527
call set_array_i(constintarray2d)
2628

27-
allocate(expected(ARRAY_LEN_Y, ARRAY_LEN_X))
28-
allocate(actual(ARRAY_LEN_Y, ARRAY_LEN_X))
29+
allocate(expected(dims(1), dims(2)))
30+
allocate(actual(dims(1), dims(2)))
2931

30-
do x = 1, ARRAY_LEN_X
31-
do y = 1, ARRAY_LEN_Y
32+
do x = 1, dims(2)
33+
do y = 1, dims(1)
3234
expected(y, x) = cnt
3335
cnt = cnt + 1
3436
actual(y, x) = get_2d_array(intarray2d, x - 1, y - 1)

Examples/test-suite/fortran/fortran_global_const_runme.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ subroutine test_constants
2929
ASSERT(all(compiletime_floats == 1.23))
3030

3131
allocate(runtime_ints(3), source= &
32-
[nofortranconst_int_global, MACRO_INT, &
32+
[get_nofortranconst_int_global(), MACRO_INT, &
3333
get_extern_const_int()])
3434
allocate(runtime_floats(2), source= &
35-
[constant_float_global, nofortranconst_float_global])
35+
[constant_float_global, get_nofortranconst_float_global()])
3636

3737
ASSERT(all(runtime_ints == 4))
3838
ASSERT(all(runtime_floats == 1.23))

Examples/test-suite/fortran/multi_import_runme.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
program imports_runme
66
use multi_import_a, only : ZZZ
77
use multi_import_b, only : YYY
8-
use multi_import_d, only : myval
8+
use multi_import_d, only : get_myval
99
use ISO_C_BINDING
1010
implicit none
1111
type(ZZZ) :: z
@@ -21,6 +21,6 @@ program imports_runme
2121
ASSERT(y%testx() == 0)
2222
call y%release()
2323

24-
ASSERT(myval == 1234)
24+
ASSERT(get_myval() == 1234)
2525

2626
end program

Examples/test-suite/fortran_global_const.i

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
%module fortran_global_const
22

3+
// Wrap as 'parameters'
34
%fortranconst fortranconst_int_global;
45
%fortranconst fortranconst_float_global;
56
%constant int fortranconst_int_global = 4;
67
%constant float fortranconst_float_global = 1.23f;
78

8-
// Neither of these is wrapped as native constants (disabled by default)
9+
// Wrap as externally-linked constants
10+
%fortranbindc constant_int_global;
11+
%fortranbindc constant_float_global;
912
%constant int constant_int_global = 4;
1013
%constant float constant_float_global = 1.23f;
1114

12-
%nofortranconst nofortranconst_int_global;
13-
%nofortranconst nofortranconst_float_global;
15+
// Default wrapping: getters
1416
%constant int nofortranconst_int_global = 4;
1517
%constant float nofortranconst_float_global = 1.23f;
1618

19+
%fortranbindc MACRO_INT;
1720
%fortranconstvalue(4) MACRO_HEX_INT;
1821

1922
%inline %{

Examples/test-suite/fortran_naming.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
%rename(m_x) MyStruct::_x;
1919
%rename(m_y) MyStruct::_y;
2020

21+
%fortranconst _123;
22+
2123
%inline %{
2224
// Forward-declare and operate on pointer
2325
class _Foo;
@@ -107,6 +109,7 @@ extern "C" int _0cboundfunc(const int _x) { return _x + 1; }
107109

108110
%}
109111

112+
%fortranconst;
110113
// This name is too long
111114
%constant int sixty_four_characters_is_way_too_long_for_fortran_or_punch_cards = 64;
112115
// This name shows that you can't simply truncate
@@ -115,6 +118,7 @@ extern "C" int _0cboundfunc(const int _x) { return _x + 1; }
115118
// This name is the maximum length but starts with an underscore
116119
%constant int _leading_underscore_with_sixty_four_characters_is_just_darn_long = 64;
117120
%constant int _leading_underscore_with_sixty_three_characters_might_be_tricky = 63;
121+
%nofortranconst;
118122

119123
// This class is poorly named, but the symname is OK.
120124
%inline %{

0 commit comments

Comments
 (0)