catala/tests/test_struct/good/nested3.catala_en
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

49 lines
929 B
Plaintext

## Article
```catala
declaration structure S:
data x content integer
data y content boolean
declaration structure T:
data a content S
data b content S
declaration scope A:
context output t content T
declaration scope B:
context output t content T
a scope A
context output out content integer
scope A:
definition t equals T {
-- a : S {
-- x : 0
-- y : false
}
-- b : S {
-- x : 1
-- y : true
}
}
scope B:
definition t equals a.t
definition out equals if t.a.y then t.a.x else (if t.b.y then t.b.x else 42)
```
```catala-test-inline
$ catala Interpret -s A
[RESULT] Computation successful! Results:
[RESULT] t = T {"a"= S {"x"= 0; "y"= false}; "b"= S {"x"= 1; "y"= true}}
```
```catala-test-inline
$ catala Interpret -s B
[RESULT] Computation successful! Results:
[RESULT] out = 1
[RESULT] t = T {"a"= S {"x"= 0; "y"= false}; "b"= S {"x"= 1; "y"= true}}
```