mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Add (half-baked) test on module usage
Half-baked because clerk doesn't know to order the tests properly at the moment, and we spit compiled files into the source test directory.
This commit is contained in:
parent
a71b4e7f73
commit
b5baa91a2e
4
Makefile
4
Makefile
@ -315,10 +315,10 @@ CLERK=$(CLERK_BIN) --exe $(CATALA_BIN) \
|
||||
|
||||
.FORCE:
|
||||
|
||||
test_suite: .FORCE compiler
|
||||
test_suite: .FORCE install
|
||||
@$(MAKE) -C tests pass_all_tests
|
||||
|
||||
test_examples: .FORCE compiler
|
||||
test_examples: .FORCE install
|
||||
@$(MAKE) -C examples pass_all_tests
|
||||
|
||||
#> tests : Run interpreter tests
|
||||
|
22
tests/test_modules/good/mod_def.catala_en
Normal file
22
tests/test_modules/good/mod_def.catala_en
Normal file
@ -0,0 +1,22 @@
|
||||
# Test modules + inclusions 1
|
||||
|
||||
```catala-metadata
|
||||
declaration enumeration Enum1:
|
||||
-- Yes
|
||||
-- No
|
||||
-- Maybe
|
||||
|
||||
declaration scope S:
|
||||
output sr content money
|
||||
output e1 content Enum1
|
||||
```
|
||||
|
||||
```catala
|
||||
scope S:
|
||||
definition sr equals $1,000
|
||||
definition e1 equals Maybe
|
||||
```
|
||||
|
||||
```catala-test-inline
|
||||
$ catala module --compile --plugin-dir=../../../_build/default/compiler/plugins --disable_warnings
|
||||
```
|
23
tests/test_modules/good/mod_use.catala_en
Normal file
23
tests/test_modules/good/mod_use.catala_en
Normal file
@ -0,0 +1,23 @@
|
||||
# Test modules + inclusions 2
|
||||
|
||||
```catala
|
||||
declaration scope T2:
|
||||
t1 scope Mod_def.S
|
||||
# input i content Enum1
|
||||
output o1 content Mod_def.Enum1
|
||||
output o2 content Mod_def.Enum1
|
||||
output o3 content money
|
||||
|
||||
scope T2:
|
||||
definition o1 equals Mod_def.Enum1.No
|
||||
definition o2 equals t1.e1
|
||||
definition o3 equals t1.sr
|
||||
```
|
||||
|
||||
```catala-test-inline
|
||||
$ catala interpret -s T2 --disable_warnings --use mod_def.catala_en
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] o1 = No ()
|
||||
[RESULT] o2 = Maybe ()
|
||||
[RESULT] o3 = $1,000.00
|
||||
```
|
Loading…
Reference in New Issue
Block a user