mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 14:13:27 +03:00
3030196fdd
* Closes #2968 * Implements detection of function-like definitions, which either: - have some arguments on the left of `:`, or - have at least one clause. * Only function-like definitions are recursive. * Non-recursive definitions are not mutually recursive either, and can be used only after their definition. This necessitates rearranging some definitions in existing Juvix code. * Changes the scoping of identifiers in record updates. Now field names on the right side don't refer to the old values of the record fields but to identifiers in scope defined outside the record update. To refer to old values, one needs to explicitly use record projections, e.g. ``` r@Rec{x := Rec.x r} ```
487 lines
9.7 KiB
YAML
487 lines
9.7 KiB
YAML
working-directory: ./../../../tests/
|
|
|
|
tests:
|
|
- name: repl-non-terminating
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "let x (dummy : Bool) : Bool := x dummy in x true"
|
|
stdout:
|
|
matches: |
|
|
.*
|
|
stderr:
|
|
contains: |
|
|
The following function fails the termination checker:
|
|
• x
|
|
exit-status: 0
|
|
|
|
- name: repl-doc
|
|
command:
|
|
- juvix
|
|
- repl
|
|
- ../examples/milestone/HelloWorld/HelloWorld.juvix
|
|
stdin: ":doc Nat"
|
|
stdout:
|
|
contains: |
|
|
--- Inductive natural numbers. I.e. whole non-negative numbers.
|
|
exit-status: 0
|
|
|
|
- name: repl-doc-no-doc
|
|
command:
|
|
- juvix
|
|
- repl
|
|
- ../examples/milestone/HelloWorld/HelloWorld.juvix
|
|
stdin: ":doc suc"
|
|
stdout:
|
|
contains: |
|
|
No documentation available for suc
|
|
exit-status: 0
|
|
|
|
- name: repl-def
|
|
command:
|
|
- juvix
|
|
- repl
|
|
- ../examples/milestone/HelloWorld/HelloWorld.juvix
|
|
stdin: ":def suc"
|
|
stdout:
|
|
contains: |
|
|
--- Inductive natural numbers. I.e. whole non-negative numbers.
|
|
builtin nat
|
|
type Nat :=
|
|
| zero
|
|
| suc Nat
|
|
exit-status: 0
|
|
|
|
- name: repl-def-error
|
|
command:
|
|
- juvix
|
|
- repl
|
|
- ../examples/milestone/HelloWorld/HelloWorld.juvix
|
|
stdin: ":def 1 Nat"
|
|
stdout:
|
|
matches: |
|
|
.*
|
|
stderr:
|
|
contains: |
|
|
:def expects one or more identifiers
|
|
exit-status: 0
|
|
|
|
- name: repl-def-multiple
|
|
command:
|
|
- juvix
|
|
- repl
|
|
- ../examples/milestone/HelloWorld/HelloWorld.juvix
|
|
stdin: ":def >>> (>>>) (((>>>)))"
|
|
stdout:
|
|
contains: |
|
|
builtin IO-sequence
|
|
axiom >>> : IO -> IO -> IO
|
|
exit-status: 0
|
|
|
|
- name: repl-def-infix
|
|
command:
|
|
- juvix
|
|
- repl
|
|
- ../examples/milestone/HelloWorld/HelloWorld.juvix
|
|
stdin: ":def >>>"
|
|
stdout:
|
|
contains: |
|
|
builtin IO-sequence
|
|
axiom >>> : IO -> IO -> IO
|
|
exit-status: 0
|
|
|
|
- name: open
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdout:
|
|
contains: "Juvix REPL"
|
|
exit-status: 0
|
|
|
|
- name: infer-mutually-recursive-let-expression
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: ":type let odd : _ | zero := false | (suc n) := not (even n); even : _ | zero := true | (suc n) := not (odd n) in even 10"
|
|
stdout:
|
|
contains:
|
|
"Bool"
|
|
exit-status: 0
|
|
|
|
- name: eval-mutually-recursive-let-expression
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "let odd : _ | zero := false | (suc n) := not (even n); even : _ | zero := true | (suc n) := not (odd n) in even 10"
|
|
stdout:
|
|
contains:
|
|
"true"
|
|
exit-status: 0
|
|
|
|
- name: quit
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdout:
|
|
contains: "Juvix REPL"
|
|
stdin: ":quit"
|
|
exit-status: 0
|
|
|
|
- name: load-stdlib-by-default
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdout:
|
|
matches:
|
|
regex: |
|
|
Juvix REPL .*
|
|
OK loaded: .*/stdlib/Stdlib/Prelude.juvix
|
|
exit-status: 0
|
|
|
|
- name: version-shows-same-juvix-version
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: ":version"
|
|
stdout:
|
|
matches:
|
|
regex: |
|
|
Juvix REPL version ([0-9]+\.[0-9]+\.[0-9]\-[a-z0-9]+): .*
|
|
OK loaded: .*
|
|
Stdlib.Prelude> \1
|
|
exit-status: 0
|
|
|
|
- name: check-type-isEmpty
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdout:
|
|
contains: "{A : Type} -> (list : List A) -> Bool"
|
|
stdin: ":type isEmpty"
|
|
exit-status: 0
|
|
|
|
- name: check-type-suc
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdout:
|
|
contains: "Nat -> Nat"
|
|
stdin: ":type suc"
|
|
exit-status: 0
|
|
|
|
- name: check-type-suc-short
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdout:
|
|
contains: "Nat -> Nat"
|
|
stdin: ":t suc"
|
|
exit-status: 0
|
|
|
|
- name: check-type-suc-short-stdlib
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
cd ./../juvix-stdlib && juvix repl Stdlib/Prelude.juvix
|
|
stdout:
|
|
contains: "Nat -> Nat"
|
|
stdin: ":t suc"
|
|
exit-status: 0
|
|
|
|
- name: eval-and-operations
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "true && false"
|
|
stdout:
|
|
matches: |
|
|
Juvix REPL .*
|
|
OK loaded: .*
|
|
Stdlib.Prelude> false
|
|
exit-status: 0
|
|
|
|
- name: eval-and-operations-with-spaces
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: " true && false"
|
|
stdout:
|
|
contains:
|
|
"false"
|
|
exit-status: 0
|
|
|
|
- name: eval-suc-true
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "suc true"
|
|
stdout:
|
|
contains:
|
|
"Stdlib.Prelude> "
|
|
stderr:
|
|
contains: |
|
|
The expression true has type:
|
|
Bool
|
|
but is expected to have type:
|
|
Nat
|
|
exit-status: 0
|
|
|
|
- name: load-builtin-bool
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
cd ./Internal/positive/ && juvix repl
|
|
stdin: ":load BuiltinBool.juvix"
|
|
stdout:
|
|
contains:
|
|
"BuiltinBool>"
|
|
exit-status: 0
|
|
|
|
- name: load-builtin-bool-with-spaces
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
cd ./Internal/positive/ && juvix repl
|
|
stdin: ":load BuiltinBool.juvix"
|
|
stdout:
|
|
contains:
|
|
BuiltinBool>
|
|
exit-status: 0
|
|
|
|
- name: load-builtin-bool-short-form
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
cd ./Internal/positive/ && juvix repl
|
|
stdin: |
|
|
:l BuiltinBool.juvix
|
|
main
|
|
stdout:
|
|
contains: |
|
|
true
|
|
exit-status: 0
|
|
|
|
- name: repl-file
|
|
command:
|
|
- juvix
|
|
- repl
|
|
args:
|
|
- Internal/positive/BuiltinBool.juvix
|
|
stdin: main
|
|
stdout:
|
|
contains: |
|
|
true
|
|
exit-status: 0
|
|
|
|
- name: root-global
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: ":root"
|
|
stdout:
|
|
matches: |
|
|
Juvix REPL .*
|
|
OK loaded: .*
|
|
Stdlib.Prelude> .*/global-project/
|
|
exit-status: 0
|
|
|
|
- name: repl-trace
|
|
command:
|
|
- juvix
|
|
- repl
|
|
args:
|
|
- positive/issue1731/builtinTrace.juvix
|
|
stdin: trace 2 >-> printNatLn 3
|
|
stdout:
|
|
contains: |
|
|
3
|
|
stderr: |
|
|
2
|
|
exit-status: 0
|
|
|
|
- name: repl-trace-file
|
|
command:
|
|
- juvix
|
|
- repl
|
|
args:
|
|
- positive/issue1731/builtinTrace.juvix
|
|
stdin: f 4 0
|
|
stdout:
|
|
contains: |
|
|
0
|
|
stderr: |
|
|
4
|
|
3
|
|
2
|
|
1
|
|
exit-status: 0
|
|
|
|
- name: repl-fail
|
|
command:
|
|
- juvix
|
|
- repl
|
|
args:
|
|
- positive/issue1731/builtinFail.juvix
|
|
stdin: main
|
|
stdout:
|
|
contains: |
|
|
Get
|
|
stderr:
|
|
contains: |
|
|
evaluation error: failure: Enough
|
|
exit-status: 0
|
|
|
|
- name: print-values
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "nil"
|
|
stdout:
|
|
contains: "nil"
|
|
exit-status: 0
|
|
|
|
- name: core-repl-type
|
|
command:
|
|
- juvix
|
|
- dev
|
|
- core
|
|
- repl
|
|
stdin: ":t (\\(A : Type) \\(x : A) \\(y : A) \\(B : Type) \\(z : B) \\(_ : A) x) Int 1 2 String"
|
|
stdout:
|
|
contains: |
|
|
String -> Int -> Int
|
|
|
|
- name: repl-import-no-dependencies
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
cd positive/NoDependencies && juvix repl Empty.juvix
|
|
stdin: "import Foo\nFoo.bar"
|
|
stdout:
|
|
contains:
|
|
bar
|
|
exit-status: 0
|
|
|
|
- name: repl-import-no-dependencies-type
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
cd positive/NoDependencies && juvix repl Empty.juvix
|
|
stdin: "import Foo\n:t Foo.bar"
|
|
stdout:
|
|
contains:
|
|
Bar
|
|
exit-status: 0
|
|
|
|
- name: repl-invalid-import
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
cd positive/NoDependencies && juvix repl Empty.juvix
|
|
stdin: "import Invalid"
|
|
stdout:
|
|
contains: OK loaded
|
|
stderr:
|
|
contains:
|
|
The module Invalid does not exist
|
|
exit-status: 0
|
|
|
|
- name: repl-import-type-error
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
temp=$(mktemp -d)
|
|
trap 'rm -rf -- "$temp"' EXIT
|
|
cp negative/Internal/WrongType.juvix $temp
|
|
cd $temp
|
|
echo "module Empty;" > Empty.juvix
|
|
touch juvix.yaml
|
|
juvix repl Empty.juvix
|
|
stdin: "import WrongType"
|
|
stdout:
|
|
contains: OK loaded
|
|
stderr:
|
|
contains:
|
|
is expected to have type
|
|
exit-status: 0
|
|
|
|
- name: import-from-stdlib
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: |
|
|
import Stdlib.Data.Int.Ord as Int
|
|
1 Int.== 1
|
|
stdout:
|
|
contains: "true"
|
|
exit-status: 0
|
|
|
|
- name: import-then-open-from-stdlib
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "import Stdlib.Data.Int.Ord as Int open\n1 Int.== 1"
|
|
stdout:
|
|
contains: "true"
|
|
exit-status: 0
|
|
|
|
- name: open-import-from-stdlib
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "import Stdlib.Data.Int.Ord open\ncompare 1 1"
|
|
stdout:
|
|
contains: "Equal"
|
|
exit-status: 0
|
|
|
|
- name: infix-constructors
|
|
command:
|
|
- juvix
|
|
- repl
|
|
stdin: "(::) :: nil {Nat -> List Nat -> List Nat}"
|
|
stdout:
|
|
contains: "(::) :: nil"
|
|
exit-status: 0
|
|
|
|
- name: repl-no-filter-unreachable
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
temp=$(mktemp -d)
|
|
trap 'rm -rf -- "$temp"' EXIT
|
|
cd $temp
|
|
echo "module Test;import Stdlib.Prelude open" > Test.juvix
|
|
touch juvix.yaml
|
|
juvix repl Test.juvix
|
|
stdin: "suc 99"
|
|
stdout:
|
|
contains: "100"
|
|
exit-status: 0
|
|
|
|
- name: repl-symlink-XDG_CONFIG_HOME
|
|
command:
|
|
shell:
|
|
- bash
|
|
script: |
|
|
config=$(mktemp -d)
|
|
temp=$(mktemp -d)
|
|
trap 'rm -rf -- "$temp"' EXIT
|
|
trap 'rm -rf -- "$config"' EXIT
|
|
mkdir "$config/root"
|
|
ln -s "$config/root" "$config/symlink"
|
|
cd $temp
|
|
export XDG_CONFIG_HOME="$config/symlink"
|
|
juvix repl
|
|
stdout:
|
|
contains: "Stdlib.Prelude>"
|
|
exit-status: 0
|