Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do deep eval for doctests #2110

Merged
merged 3 commits into from
Dec 24, 2024
Merged

Do deep eval for doctests #2110

merged 3 commits into from
Dec 24, 2024

Conversation

jneem
Copy link
Member

@jneem jneem commented Nov 27, 2024

Previously, we weren't doing deep eval of doctests, which would fail to catch some errors.

I think maybe there are use-cases where you don't want full evaluation, but I'm pretty sure it should be the default. (And then we could support a test annotation to make it lazy if anyone actually needs that)

@jneem jneem requested a review from yannham November 27, 2024 11:00
@jneem
Copy link
Member Author

jneem commented Nov 27, 2024

There's still one failing test in the stdlib, which I think is due to the unimplemented record freezing:

std.record.update "bar" 1 {foo = bar + 1, bar | default = 0 }

returns { foo = 1, bar = 1 }, but if I add an Equal contract then:

(std.record.update "bar" 1 {foo = bar + 1, bar | default = 0 }) | std.contract.Equal { foo = 1, bar = 1 }

gives

error: contract broken by a value
  ┌─ <unknown> (generated by evaluation):1:1
  │
1 │ std.contract.Equal { bar = 1, foo = 1, }
  │ ---------------------------------------- expected type
  │
  ┌─ /home/jneeman/tweag/nickel-doctest-deep-eq/core/stdlib/std.ncl:1:34
  │
1 │ std.record.update "bar" 1 {foo = bar + 1, bar | default = 0 }
  │                                  ^^^^^^^ applied to this expression
  │
  ┌─ <unknown> (generated by evaluation):1:1
  │
1 │ 2
  │ - evaluated to this value

@yannham
Copy link
Member

yannham commented Nov 27, 2024

Ah. Maybe it's a sign that it's time to implement freezing properly 😅 I can try to take a look at that after the ongoing PR that I have (a simple cleaning of the AstAlloc interface)

@jneem
Copy link
Member Author

jneem commented Dec 24, 2024

It works!

@jneem jneem added this pull request to the merge queue Dec 24, 2024
Merged via the queue into master with commit 691a522 Dec 24, 2024
5 checks passed
@jneem jneem deleted the doctest-deep-eq branch December 24, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants