winglang/wing

When `assert` fails it should hint to use `expect` instead

Open

#2,859 opened on 2023年6月8日

GitHub で見る
 (7 comments) (2 reactions) (0 assignees)TypeScript (214 forks)github user discovery
good first issue⌨️ cli✨ enhancement🛠️ compiler

Repository metrics

Stars
 (5,385 stars)
PR merge metrics
 (30d に merged PR はありません)

説明

Decided:

Note: This section was added after some discussion. The rest of the issue description was not changed. The requirement here is when assert fails and that cumbersome error message appears, the CLI should also emit a hint instructing the user to utilize expect instead of assert.

Feature Spec

It's easy to identify what the problem for the failed test assertion could be, without having to reach for additional logging statements.

Use Cases

Given the following test case

test "one plus one" {
    let one = 1;
    let other = 1;
    assert(one + other == 3);
}

Rather than seeing that that the assertion failed like we do at the moment:

fail ┌ main.wsim » root/env1/test:one plus one
Error: assertion failed: '((one + other) === 3)'
    at /var/folders/zl/z8nc41qs7010qsfngfc_z1zc0000gn/T/wing-bundles-T4JNhr/index.js:24:23
    at $Closure6.handle (/var/folders/zl/z8nc41qs7010qsfngfc_z1zc0000gn/T/wing-bundles-T4JNhr/index.js:25:15)...

It would be nice to see what the problem is. In this case something along the lines of "expected: 3, actual 2". Could and probably should be inspired by other test frameworks.

Implementation Notes

This depends on https://github.com/winglang/wing/issues/1977

Component

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.

コントリビューターガイド