Commit Graph

72 Commits

Author SHA1 Message Date
Louis Gesbert
a9f8fa36b8 Reduce default verbosity of invariant checks
they break the tests too often for no good reason
2024-01-25 18:18:43 +01:00
Louis Gesbert
a1c1a7756f Update invariant tests outputs 2023-12-19 17:27:44 +01:00
Louis Gesbert
3779a249db Unify all CLI arguments to use - rather than _
it's more common on UNIXes and the mix was unpleasant.
2023-12-19 15:25:37 +01:00
adelaett
d7327e53c0
/!\ problematic tests 2023-12-07 11:27:14 +01:00
adelaett
a69776e6b5
checking invariants on all tests as well as on social benefits of french law 2023-12-07 11:27:14 +01:00
adelaett
dda09f0cc1 typed defaults: update passing tests. 2023-11-27 11:17:34 +01:00
adelaett
f6027109d8 Typed default: Update passing tests
For now, most tests involving only one scope and no context do pass.
More work is required for the rest.
2023-11-27 11:12:26 +01:00
Louis Gesbert
1d8e3748ea Improving the printer on arrays 2023-11-02 11:12:51 +01:00
Louis Gesbert
5efa61a0ce Clerk: rewrite 'clerk runtest' to use the new lightweight lexer
* Obsolete code for included tests has been removed

* The engine uses a proper lexer and is much simplified

* An inline test in the middle of the file now only "sees" the file up to that
  point. This fixes an issue where we had spurious errors when a type error was
  added at the end of a file, and it would pop up in tests before it. This makes
  files including many tests much more practical.

* diffing and resetting the tests has been reintroduced (done at the moment in
  Ninja, but for more control (count number of failed tests, etc.) we could put it
  back into Clerk at some point

* The Catala CLI can now take an input from stdin (with the possibility to link
  a (possibly fake) on-disk file for error reporting and file locations ; this
  is useful for running tests)
2023-09-27 13:18:18 +02:00
Louis Gesbert
edd6dce0d8 Disable recursive tests reset for now; remove rel paths in test out 2023-08-04 12:08:18 +02:00
Aminata-Dev
b087ca4f47 Improve suggestions
- Improved implementation of suggestions (suggestion_minimum_levenshtein_distance_association > suggestions.ml)
- Magnifying glass emoji added for suggestions
- Improve display by...
	- Fixing "Pos.ml" (pretty-printing box not closed)
	- Remove unnecessary spaces
- compiler/surface/parserdriver.ml
	- Optionnal suggestions added when raising a parser error
	- Function "levenshtein_distance" removed and replaced by "Suggestions.levenshtein_distance"
- Tests updated (mostly line breaks and spacing changes)
- Variable names renamed for greater clarity
- (Based on commit 0813f5c36e)
2023-07-12 11:55:11 +02:00
Denis Merigoux
50113586e3 With @aminata-dev update Messages.Content 2023-07-12 11:55:11 +02:00
Louis Gesbert
89e90271c1 Implement an additional localised, user-facing value printer 2023-07-03 16:42:54 +02:00
Louis Gesbert
0f9ee2c72e Refacter the main Driver module
- Use separate functions for successive passes in module `Driver.Passes`
- Use other functions for end results printing in module `Driver.Commands`

As a consequence, it is much more flexible to use by plugins or libs and we no
longer need the complex polymorphic variant parameter.

This patch leverages previous changes to use Cmdliner subcommands and
effectively specialises the flags of each Catala subcommand.

Other changes include:

- an attempt to normalise the generic options and reduce the number of global
  references. Some are ok, like `debug` ; some would better be further cleaned up,
  e.g. the ones used by Proof backend were moved to a `Proof.globals` module and
  need discussion. The printer no longer relies on the global languages and prints
  money amounts in an agnostic way.
- the plugin directory is automatically guessed and loaded even in dev setups.
  Plugins are shown by the main `catala` command and listed in `catala --help`
- exception catching at the toplevel has been refactored a bit as well; return
  codes are normalised to follow the manpage and avoid codes >= 128 that are
  generally reserved for shells.

Update tests
2023-07-03 16:42:54 +02:00
Louis Gesbert
e4c1216848 Tweak whitespace in messages 2023-06-08 14:36:28 +02:00
Louis Gesbert
fcadd9808e Update tests with whitespace changes 2023-06-08 14:03:08 +02:00
Denis Merigoux
09bcefbcc1 Update tests 2023-06-03 18:02:57 +02:00
Denis Merigoux
579e66a500 Restore testing (formatting is better!) 2023-06-02 10:50:33 +02:00
Denis Merigoux
bcd91f5dea
Merge branch 'master' into aides_logement_outre_mer 2023-05-04 11:04:28 +02:00
Louis Gesbert
3e7a2a34ab More printer improvements 2023-05-02 11:49:09 +02:00
Denis Merigoux
9b056f3ca1
Update assets and fix errors after rebase 2023-04-27 12:18:50 +02:00
Denis Merigoux
75c2a24b98
Changed position formatting 2023-04-27 12:09:22 +02:00
adelaett
5e46253140
removed one remaning debuging print, and updating all the tests 2023-04-14 17:59:08 +02:00
adelaett
91805bfa43
fixing tests 2023-04-14 16:22:39 +02:00
Louis Gesbert
e19e4af12d Vastly improve the printer
* fix lots of Format boxes
* add parens based on precedence in the printer
* fix interaction of Format and the colored line debug tags
2023-04-13 18:15:22 +02:00
Denis Merigoux
e80143b3ca
Last linting pass and update tests 2023-03-31 17:56:45 +02:00
Denis Merigoux
3d86a12261
Update error messages 2023-03-31 14:01:04 +02:00
Louis Gesbert
5bcc0a65eb Improve some messages on structure disambiguation 2022-12-13 11:47:21 +01:00
Louis Gesbert
8960e5dbbc Add typing-based disambiguation pass after desugaring
Some typing errors are changed a little, because they get triggered during the
typing of the disambiguation pass, which does not specify the expected return
type (it's an expected invariant that it should not be needed for
disambiguation).

It would be possible to still specify these types during disambiguation just to
get the same errors, but since the newer ones don't appear to be clearly worse
at the moment, it has not been done.
2022-11-28 16:38:09 +01:00
Louis Gesbert
af2f5dbe19 Tweak error message location printing 2022-11-28 16:38:09 +01:00
Louis Gesbert
a5ea9451bc Fix extra spacing in struct printer 2022-11-21 17:11:53 +01:00
Louis Gesbert
4ae392c900 AST refactoring
Many changes got bundled in here and would be too tedious to separate.

Closes #330

See changes in `shared_ast/definitions.ml` to check the main point.

- the biggest change is a modification of the struct and enum types in
  expressions: they are now stored as `Map`s throughout passes, and no longer
  converted to indexed lists after scopelang. Their accessors are also changed,
  and tuples only exist in Lcalc (they're used for closure conversion).

  This implied adding some more information in the contexts, to keep the mapping
  between struct fields and scope output variables. It should also be much more
  robust (no longer relying on assumptions upon different orderings).

- another very pervasive change is more cosmetic: the rewrite of the main AST to
  use inline records, labelling individual subfields.

- moved the checks for correct definitions and accesses of structures from
  `Scope_to_dcalc` to `Typing`

- defining some new shallow iterators in module `Shared_ast.Expr`, and
  factorising a few same-pass rewriting functions accordingly (closure
  conversion, optimisations, etc.)

- some smaller style improvements (ensuring we use the proper compare/equal
  functions instead of `=` in a few `when` closes, for example)
2022-11-17 18:16:09 +01:00
Louis Gesbert
4d4dac6727 Some fancy unicode for error outlines
Normally I would make sure this is not by default, or at leat disableable; but
here the code we print may contain utf8 anyway, so the terminal really needs to
support it. Anyway, it's just a little fancier, doesn't add much.
2022-11-07 14:13:01 +01:00
Louis Gesbert
429911024c Add parseable line-column info to error messages
a quick fix for now, ideally we want an option for editor-friendly output.
But for now this is a very cheap way to at least have clickable error messages
which are a big time-saver.
2022-11-07 14:03:38 +01:00
Louis Gesbert
41d6d3cbe9 Make scopes directly callable
Quite a few changes are included here, some of which have some extra
implications visible in the language:

- adds the `Scope of { -- input_v: value; ... }` construct in the language

- handle it down the pipeline:
  * `ScopeCall` in the surface AST
  * `EScopeCall` in desugared and scopelang
  * expressions are now traversed to detect dependencies between scopes
  * transformed into a normal function call in dcalc

- defining a scope now implicitely defines a structure with the same name, with
  the output variables of the scope defined as fields. This allows us to type
  the return value from a scope call and access its fields easily.
  * the implications are mostly in surface/name_resolution.ml code-wise
  * the `Scope_out` struct that was defined in scope_to_dcalc is no longer
    needed/used and the fields are no longer renamed (changes some outputs; the
    explicit suffix for variables with multiple states is ignored as well)
  * one benefit is that disambiguation works just like for structures when there
    are conflicts on field names
  * however, it's now a conflict if a scope and a structure have the same
    name (side-note: issues with conflicting enum / struct names or scope
    variables / subscope names were silent and are now properly reported)

- you can consequently use scope names as types for variables as well. Writing
  literals is not allowed though, they can only be obtained by calling the
  scope.

Remaining TODOs:

- context variables are not handled properly at the moment

- error handling on invalid calls

- tests show a small error message regression; lots of examples will need
  tweaking to avoid scope/struct name or struct fields / output variable
  conflicts

- add a `->` syntax to make struct field access distinct from scope output var
  access, enforced with typing. This is expected to reduce confusion of users
  and add a little typing precision.

- document the new syntax & implications (tutorial, cheat-sheet)

- a consequence of the changes is that subscope variables also can now be typed.
  A possible future evolution / simplification would be to rewrite subscopes as
  explicit scope calls early in the pipeline. That could also allow to manipulate
  them as expressions (bind them in let-ins, return them...)
2022-10-21 17:17:26 +02:00
Louis Gesbert
1b3a1f7219 Update test results
These are just variable renumberings, and type error message changes but still
pointing to the same information; the latter are slightly better in general,
pointing to actual expressions rather than scope declarations.
2022-10-04 14:50:37 +02:00
Louis Gesbert
12d2833306 Fix cyclic type test
Make it type so that it's actually the cycle error that is raised
(now that expression typing is done earlier)
2022-10-04 14:50:37 +02:00
Louis Gesbert
abd5a4de96 Tests: cleanup remaining whitespace 2022-09-26 14:27:47 +02:00
Louis Gesbert
0c0ef1ae1a Add test return codes
Simply re-generated with 'make tests CLERK_OPTS=--reset'
2022-09-23 14:50:02 +02:00
Louis Gesbert
0ab7a0f9ce Turn all existing tests to inline tests
Done using
```bash
process() { FILE=$1; awk 'match($0, /^```catala-test *{ *id *= *"(.*)" *}/, a) {print "```catala-test-inline"; f="'"$(dirname $FILE)/output/$(basename $FILE)"'." a[1]; getline; print "$ " $0; while ((getline<f) > 0) print; next} {print}' $FILE >$FILE.new; mv $FILE.new $FILE; }
for f in tests/test_*/*/*.catala_* examples/**/*.catala_*; do process $f; git add $f; done
for d in $(find -name output -type d); do git rm -r $d; done
```
2022-09-23 14:45:10 +02:00
Louis Gesbert
2e5050481d Register all existing tests through the new engine
I removed the '.out' extension for now to preserve the test output file names and avoid a million file renames.

This makes the patch easier to read, and we can do the rename easily in another patch afterwards, without mixing with semantic changes.

(beautiful script àlarrache:
```bash
for f in */*/output/*; do
  target_base=${f##*/}
  target_base=${target_base%%.*}
  echo $f | awk -F. '{
    f=$1"."$2; if ($4 == "") { mode=$3; id=$3 } else { scope="-s "$3; mode=$4; id=$3"."$4}
    printf "\n```catala-test {id=\"%s\"}\ncatala %s %s\n```\n",id,mode,scope;
  }' >> $(dirname $f)/../${target_base}.*; done
```
2022-07-08 17:06:20 +02:00
Denis Merigoux
3f49824150
Merge branch 'master' into c_backend 2022-04-04 18:02:33 +02:00
Denis Merigoux
ce7e756af1
Nice error messages for empty structs and enums 2022-03-28 14:43:38 +02:00
Denis Merigoux
2263dd7dab
Update syntax highlighting and test suite [skip ci] 2022-02-07 12:04:48 +01:00
Denis Merigoux
72274057cd
Better Dcalc printing 2022-02-06 18:25:37 +01:00
Denis Merigoux
b2a5551961
Test folders, nice doc and messages 2022-01-11 12:51:34 +01:00
Denis Merigoux
2b6e7c8b98
Working prototype of clerk, the new build system for Catala 2022-01-10 17:57:58 +01:00
Denis Merigoux
56baf91923
Remove prefixes to each line in messages, keep only first line 2021-11-06 23:04:12 +01:00
Denis Merigoux
b72d8e09ee
Restore typechecking version of CGI example 2021-09-28 12:01:08 +02:00
EmileRolley
0ffbb9b266 refactor(tests)!: migrate test file from the abbreviated syntax to the english one 2021-05-26 21:16:29 +02:00