You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: example/example-test-suite/README.md
+47-50Lines changed: 47 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,40 +1,38 @@
1
1
Example Test Suite Classes
2
2
==========================
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 |
3
12
4
13
Getting Started
5
14
---------------
6
15
Likely the fastest way to get started with Julienne is to copy the source code in this directory and modify it for your purposes:
7
16
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.
9
18
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.
10
19
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.
27
23
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
30
26
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.
31
29
`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.
32
30
Please see Julienne's online [documentation](https:///berkeleylab.github.io/julienne/) for the currently supported TKR.
33
31
Please submit an issue to request support for additional TKR or submit a pull request to contribute such support.
34
32
35
33
#### Forming diagnostic strings from array data
36
34
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.
38
36
For example, consider the following test description:
39
37
```fortran
40
38
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
59
57
```
60
58
To support a common array notation, Julienne also supports bracketing strings.
61
59
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
+
------------------
69
62
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:
70
63
71
64
```mermaid
@@ -104,29 +97,6 @@ class test_diagnosis_t{
104
97
}
105
98
```
106
99
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:
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{
175
145
base_name(string_t) string_t
176
146
}
177
147
```
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:
0 commit comments