Skip to content

Handle in-test definitions #4

@newsch

Description

@newsch

A common pattern is defining a function while testing and using it in further tests. Right now each test is evaluated in it's own environment, so any inline definitions are unknown to successive tests.
One potential approach is to naively use the same ocaml terminal for each suite, and either only parsing and returning the outputs at the end of the suite or communicating/parsing with the program and returning results while running them.
Another is to find any let statements in suites and run them with any following tests in a suite (or parsing following tests to determine if they use the defined statements).

For example, this test defines the function sqrt to be used in following tests:

val sqrt : float -> float network = 

- : float list =
[1.; 2.5; 2.05; 2.00060975609756087; 2.00000009292229475;
 2.00000000000000222; 2.; 2.; 2.; 2.]
- : float list =
[1.; 5.; 3.4; 3.0235294117647058; 3.00009155413138; 3.00000000139698386; 3.;
 3.; 3.; 3.]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions