Commit Graph

44 Commits

Author SHA1 Message Date
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
Denis Merigoux
09bcefbcc1 Update tests 2023-06-03 18:02:57 +02:00
Denis Merigoux
5d765676b5 Format rather than print 2023-06-02 10:58:03 +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
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
Raphaël Monat
d5cd5b206a Show conflicting date rounding mode declarations when they happen 2023-03-16 18:51:01 +01:00
Raphaël Monat
8981b21edb Add test for date rounding option conflict 2023-03-16 17:20:14 +01:00
Raphaël Monat
5cf6bdffb8 Add tests for date rounding option 2023-03-16 17:20:13 +01:00
Louis Gesbert
71bb67163c Remove explicitely typed operators in tests and examples
Command used: `sed -i 's/\([-+*/><=]=\?\)[.$@^€$]/\1/g' **/*/*.catala_*`

The overload test, of course, is kept unchanged and ensures that explicit
operators still work.
2022-12-13 12:00:04 +01:00
Louis Gesbert
af2f5dbe19 Tweak error message location printing 2022-11-28 16:38: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
8c1696d0ff Inline tests: cleanup trailing whitespace 2022-09-23 16:56:21 +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
Denis Merigoux
a1e6d992a9
Fix test output 2022-09-05 10:48:05 +02:00
Raphaël Monat
d9cc2dbb43 Fix format in excepted test 2022-09-05 09:31:39 +02:00
Denis Merigoux
755b1212a2
Remove division durations 2022-08-19 15:21:29 +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
8782168632
Added test for month multiplication 2022-06-01 15:20:32 +02:00
kescher
db9eec3b9f add support for duration multiplication
Signed-off-by: Jonathan Protzenko <protz@microsoft.com>
2022-05-31 11:17:38 -07:00
Denis Merigoux
2263dd7dab
Update syntax highlighting and test suite [skip ci] 2022-02-07 12:04:48 +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
EmileRolley
4e53358fd6 feat(compiler): add the Runtime.IndivisableDurations exception handling 2021-05-31 10:26:51 +02:00
EmileRolley
1572244e2d fix(tests): add test case for the good utilisation of the duration division operator 2021-05-31 10:26:51 +02:00
EmileRolley
4e84f424eb feat(compiler): start to add the duration division operator 2021-05-31 10:26:51 +02:00
EmileRolley
f907431504 refactor(compiler): factorize the UncomparableDurations exception managment in Dcalc.interpreter + add unit tests 2021-05-29 20:17:22 +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
Denis Merigoux
3c8d187be0
Big refactoring of the literate programming structure
Partially fixes #120
Removes the distinction between headers and articles, streamlines the surface AST
Changes affects lexers and parser
2021-05-15 01:16:08 +02:00
EmileRolley
b40abce52f refactor(tests): change the date format to ISO 2021-03-16 12:10:33 +01:00
EmileRolley
c0a9344eca refactor(tests): update tests based on the abbreviated english lexer 2021-03-09 22:07:31 +01:00
Aymeric Fromherz
ba03d2db78 Move tests to appropriate folders 2021-01-25 01:16:46 -05:00
Aymeric Fromherz
483400ea19 Move tests to their appropriate directory 2021-01-23 20:49:17 -05:00
Denis Merigoux
c562cc25be Fixed date/month US inversion 2021-01-14 13:13:32 +01:00
Denis Merigoux
852a6412eb Changed odate to calendarLib 2021-01-14 13:04:15 +01:00
Denis Merigoux
ebf14f6121 Added assertions, starting to execute section132 2020-12-10 18:11:43 +01:00
Denis Merigoux
a195a64677 Duration is number of days 2020-12-10 14:00:00 +01:00
Denis Merigoux
5004ee12d2 Added duration literals but comparison buggy 2020-12-10 11:51:50 +01:00
Denis Merigoux
902c3f8d7d Added date and durations handling 2020-12-10 11:35:56 +01:00