Skip to content

Commit

Permalink
Add regression test for sharkdp#570
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp authored and David Peter committed Sep 28, 2024
1 parent 1f9640f commit d83f28b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions numbat-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ version = "4"
features = ["suggestions", "color", "wrap_help", "derive"]

[dev-dependencies]
insta = { version = "1.34", features = ["filters"] }
insta-cmd = "0.6"

[[bin]]
Expand Down
33 changes: 33 additions & 0 deletions numbat-cli/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,36 @@ fn info_text() {
----- stderr -----
"###);
}

#[test]
fn identifier_clash_errors() {
// https://github.com/sharkdp/numbat/issues/570

let expr = "@aliases(malaysian_ringgits, MYR: short, myr, RM, rm) \n\
unit malaysian_ringgit: Money = 1.234 EUR";

insta::with_settings!({filters => vec![
(r"\bFile .*:[0-9]+:[0-9]+\b", "[redacted path]"), // redact absolute file system paths
(r"[ 0-9][0-9] │", "XX │"), // redact line numbers so we don't have to change this all the time
]}, {
assert_cmd_snapshot!(numbat().arg("--expression").arg(expr), @r###"
success: false
exit_code: 1
----- stdout -----
----- stderr -----
error: identifier clash in definition
┌─ Module 'units::time', [redacted path]
XX │ unit year: Time = 365.242_188_1 days
│ ---- Previously defined here
┌─ <input:1>:1:42
XX │ @aliases(malaysian_ringgits, MYR: short, myr, RM, rm)
│ ^^^ identifier is already in use
Interpreter stopped
"###);
});
}

0 comments on commit d83f28b

Please sign in to comment.