catala/tests/modules/good/mod_def.catala_en
Louis Gesbert 403156b36e Computation and checking of module hashes
This includes a few separate changes:

- pass visibility information of declarations (depending on wether the
  declaration was in a ```catala-metadata block or not)

- add reasonable hash computation functions to discriminate the interfaces. In
  particular:
  * Uids have a `hash` function that depends on their string, but not on their
    actual uid (which is not stable between runs of the compiler) ; the existing
    `hash` function and its uses have been renamed to `id`.
  * The `Hash` module provides the tools to properly combine hashes, etc. While
    we rely on `Hashtbl.hash` for the atoms, we take care not to use it on any
    recursive structure (it relies on a bounded traversal).

- insert the hashes in the artefacts, and properly check and report those (for
  OCaml)

**Remains to do**:

- Record and check the hashes in the other backends

- Provide a way to get stable inline-test outputs in the presence of module
  hashes

- Provide a way to write external modules that don't break at every Catala
  update.
2024-05-28 11:43:50 +02:00

60 lines
954 B
Plaintext

# Test modules + inclusions 1
> Module Mod_def
```catala-metadata
declaration enumeration Enum1:
-- Yes
-- No
-- Maybe
declaration structure Str1:
data fld1 content Enum1
data fld2 content integer
declaration scope S:
output sr content money
output e1 content Enum1
declaration half content decimal
depends on x content integer
equals x / 2
declaration maybe content Enum1
depends on x content Enum1
```
```catala
scope S:
definition sr equals $1,000
definition e1 equals Maybe
declaration maybe content Enum1
depends on x content Enum1
equals Maybe
```
```catala-test-inline
$ catala Typecheck --check-invariants
┌─[RESULT]─
│ All invariant checks passed
└─
┌─[RESULT]─
│ Typechecking successful!
└─
```
```catala-test-inline
$ catala typecheck --disable-warnings
┌─[RESULT]─
│ Typechecking successful!
└─
```
```catala-test { id="ml" }
$ catala ocaml --disable-warnings
```