Skip to content

Commit 5f99baa

Browse files
committed
doc(example): update example test suite for 2.1.0
1 parent 37bcc95 commit 5f99baa

8 files changed

Lines changed: 204 additions & 255 deletions

File tree

example/example-test-suite/README.md

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
11
Example Test Suite Classes
22
==========================
3+
This directory and its subdirectories contain a sample project that defines a library and a corresponding test suite in the `src` and `test` subdirectories, respectively.
4+
The example project has been verified to work with compilers and commands listed in the following table:
5+
6+
|Vendor |Tested shell command|
7+
|---------|--------------------|
8+
|LLVM 20 | `fpm test --compiler flang-new --flag`
9+
|GCC |
10+
|NAG |
11+
|Intel |
312

413
Getting Started
514
---------------
615
Likely the fastest way to get started with Julienne is to copy the source code in this directory and modify it for your purposes:
716

8-
1. If you build your project with the Fortran Package Manager ([`fpm`](https://github.com/fotran-lang/fpm)), then you might move the `main.F90` and `specimen_test_m.F90` files from this subdirectory to a `test/` subdirectory in the root of your project's source tree.
17+
1. If you build your project with the Fortran Package Manager ([`fpm`](https://github.com/fotran-lang/fpm)), then you might copy the `main.F90` and `specimen_test_m.F90` files from this subdirectory to a `test/` subdirectory in the root of your project's source tree.
918
2. Rename the `specimen_test_m.F90` file, the `specimen_test_m` module, and the `specimen_test_t` derived type and any references thereto, replacing `specimen` with the name of an entity that you intend to test -- most likely a module containing procedures or derived type with type-bound procedures.
1019
3. Similarly replace occurrences of `specimen` in the resulting`test/main.F90` file.
11-
4. Modify the `test_descriptions_t` array constructor in your new `*_test_m.F90` file, adding elements for each test to be performed:
12-
```fortran
13-
test_descriptions = [ &
14-
test_description_t("the type-bound function zero() producing a result of 0", check_zero) &
15-
]
16-
```
17-
5. Replace the above string (`"the type-bound..."`) with a description of your intended test. The test output will read most naturally if your description contains a gerund: a verb ending in "ing" and used as a noun, such as `producing` above.
18-
6. Replace the `check_zero` function name with the name of a function that will perform your test.
19-
7. Edit the correspondingly-renamed function to perform the test. The function must take no arguments and define a `test_diagnosis_t` result. An example result might be the following:
20-
```fortran
21-
test_diagnosis = test_diagnosis_t( &
22-
test_passed = actual_value == expected_value &
23-
,diagnostics_string = "expected value " // string_t(expected_value) //", actual value " // string_t(actual_value) &
24-
)
25-
```
26-
The above `test_diagnosis_t` constructor function invocation demonstrates the recommended pattern for writing tests with Julienne:
20+
4. In the `results()` function body of your new `*_test_m.F90` file, replace the `test_descriptions_t` array constructor elements with your own test descriptions. The test output will read most naturally if your description string (the first argument) contains a gerund: a verb ending in "ing" and used as a noun, such as `producing` above
21+
5. Replace the function name (the second argument) with the name of a function that will perform your test.
22+
7. Edit the correspondingly-renamed function to perform the test. The function must take no arguments and define a `test_diagnosis_t` result.
2723

28-
* Define the `test_passed` keyword argument by writing an expression that will evaluate to `.true.` if and only if the test succeeds.
29-
* Define the `diagnostics_string` keyword argument from character literal values interspersed with`string_t` constructor, all strung together by instances of the string concatenation operator `//`.
24+
The functions provided in `specimen_test_m` demonstrate several of the common options for constructing a `test_diagnosis_t` as the diagnosis function result.
25+
The options include
3026

27+
1. Writing an expression using Julienne's operators such as `.approximate.`, `.within`., and `.equalsExpected.`.
28+
2. Invoking the `test_diagnosis_t` constructor and using Julienne's `string_t` constructors to form a diagnostic string.
3129
`String_t` is a generic interface to various specific functions, each of which takes an argument of a different data type, kind, and rank (TKR) and defines a `string_t` result containing a charater representation of the function argument.
3230
Please see Julienne's online [documentation](https:///berkeleylab.github.io/julienne/) for the currently supported TKR.
3331
Please submit an issue to request support for additional TKR or submit a pull request to contribute such support.
3432

3533
#### Forming diagnostic strings from array data
3634

37-
An especially useful pattern for forming diagnostic string involves invoking Julienne's `operator(.csv.)` to produce a string of comma-separated values (CSV) from a one-dimensional (1D) array.
35+
An especially useful pattern for forming diagnostic strings involves invoking Julienne's `operator(.csv.)` to produce a string of comma-separated values (CSV) from a one-dimensional (1D) array.
3836
For example, consider the following test description:
3937
```fortran
4038
test_description_t(" returning the counting numbers up to 3", check_counting_numbers)
@@ -59,13 +57,8 @@ FAILS on returning the counting numbers up to 3
5957
```
6058
To support a common array notation, Julienne also supports bracketing strings.
6159

62-
**Exercise 1:** Make `check_counting_numbers` more robust by testing the equivalence of `expected_array` and `actual_array` only if the array sizes match and by treating a size-mismatch as a test failure.
63-
64-
**Exercise 2:** Revise `check_counting_numbers` by defining CSV strings `expected_string` and `actual_string` _before_ invoking `test_diagnostics_t`.
65-
Bracket the CSV strings in the `diagnostics_string` keyword argument by invoking `bracket` type-bound procedure, e.g., `expected_string%bracket()`.
66-
67-
Scalar Diagnosis Function
68-
-------------------------
60+
Diagnosis Function
61+
------------------
6962
The Unified Modeling Language ([UML](https://wikipedia.org/Unified_modeling_langauge)) class diagram below depicts the class relationships involved in making the above example work:
7063

7164
```mermaid
@@ -104,29 +97,6 @@ class test_diagnosis_t{
10497
}
10598
```
10699

107-
Vector Diagnosis Function
108-
-------------------------
109-
The UML class diagram below depicts the class relationships involved when test function performs multiple checks and defines a result containing an array of corresponding `test_diagnosis_t` objects:
110-
```mermaid
111-
%%{init: { 'theme':'default', "class" : {"hideEmptyMembersBox": true} } }%%
112-
classDiagram
113-
114-
class vector_test_description_t{
115-
vector_test_description_t(description : string_t[1..*], vector_diagnosis_function : vector_diagnosis_function_i)
116-
run() test_result_t[1..*]
117-
}
118-
vector_test_description_t --> test_diagnosis_t : run() invokes vector_diagnosis_function to construct array of
119-
vector_test_description_t --> test_result_t : run() uses test_diagnostics_t array to construct array of
120-
121-
class test_result_t{
122-
test_result_t(test_passed : logical, diagnosis : test_diagnosis_t)
123-
}
124-
125-
class test_diagnosis_t{
126-
test_diagnosis_t(test_passed : logical, diagnostics_string : string_t)
127-
}
128-
```
129-
130100
Skipping Tests
131101
--------------
132102
When a test is known to cause a compile-time or runtime crash in a specific scenario, e.g., with a specific compiler or compiler version, including that test will prevent the test suite from building or running to completion.
@@ -175,3 +145,30 @@ class string_t{
175145
base_name(string_t) string_t
176146
}
177147
```
148+
149+
Deprecated: Vector Diagnosis Function
150+
-------------------------------------
151+
Julienne's `vector_diagnosis_function_i` abstract interface and the corresponding `vector_test_description_t` type were developed before Julienne's `operator(.all.)` and `operator(.and.)`.
152+
Becaue the operators replace the interface and type with simpler functionality, it is likely that a future release will remove the `vector_*` entities.
153+
154+
The UML class diagram below depicts the class relationships involved when test function performs multiple checks and defines a result containing an array of corresponding `test_diagnosis_t` objects:
155+
```mermaid
156+
%%{init: { 'theme':'default', "class" : {"hideEmptyMembersBox": true} } }%%
157+
classDiagram
158+
159+
class vector_test_description_t{
160+
vector_test_description_t(description : string_t[1..*], vector_diagnosis_function : vector_diagnosis_function_i)
161+
run() test_result_t[1..*]
162+
}
163+
vector_test_description_t --> test_diagnosis_t : run() invokes vector_diagnosis_function to construct array of
164+
vector_test_description_t --> test_result_t : run() uses test_diagnostics_t array to construct array of
165+
166+
class test_result_t{
167+
test_result_t(test_passed : logical, diagnosis : test_diagnosis_t)
168+
}
169+
170+
class test_diagnosis_t{
171+
test_diagnosis_t(test_passed : logical, diagnostics_string : string_t)
172+
}
173+
```
174+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name = "Example-Test-Suite"
2+
3+
[dependencies]
4+
julienne = {git = "https://github.com/berkeleylab/julienne", tag = "2.0.0"}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
! Copyright (c) 2024-2025, The Regents of the University of California
2+
! Terms of use are as specified in LICENSE.txt
3+
4+
#ifndef _JULIENNE_LANGUAGE_SUPPORT_H
5+
#define _JULIENNE_LANGUAGE_SUPPORT_H
6+
7+
! If not already determined, make a compiler-dependent determination of whether Julienne may pass
8+
! procedure actual arguments to procedure pointer dummy arguments, a feature introduced in
9+
! Fortran 2008 and described in Fortran 2023 clause 15.5.2.10 paragraph 5.
10+
#ifndef HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
11+
# if defined(__GFORTRAN__)
12+
# define HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY 0
13+
# else
14+
# define HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY 1
15+
# endif
16+
#endif
17+
18+
! If not already determined, make a compiler-dependent determination of whether Julienne may use
19+
! multi-image features such as `this_image()` and `sync all`.
20+
#ifndef HAVE_MULTI_IMAGE_SUPPORT
21+
# if defined(__flang__)
22+
# define HAVE_MULTI_IMAGE_SUPPORT 0
23+
# else
24+
# define HAVE_MULTI_IMAGE_SUPPORT 1
25+
# endif
26+
#endif
27+
28+
! If not already determined, make a compiler-dependent determination of whether Julienne may use
29+
! kind type parameters for derived types.
30+
#ifndef HAVE_DERIVED_TYPE_KIND_PARAMETERS
31+
# if defined(__GFORTRAN__)
32+
# define HAVE_DERIVED_TYPE_KIND_PARAMETERS 0
33+
# else
34+
# define HAVE_DERIVED_TYPE_KIND_PARAMETERS 1
35+
# endif
36+
#endif
37+
38+
#endif

example/example-test-suite/scalar_and_vector_test_description_m.f90

Lines changed: 0 additions & 125 deletions
This file was deleted.

example/example-test-suite/specimen_test_m.F90

Lines changed: 0 additions & 80 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)