mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
allow register to accept a const argument (#8758)
# Description this pr allows `register` to be used with const variables ```nu const math_plugin = "~/.config/nushell/plugins/nu_plugin_math" register $math_plugin ``` should close #8208, previous work #8435
This commit is contained in:
@ -487,3 +487,36 @@ fn unbalanced_delimiter2() -> TestResult {
|
||||
fn unbalanced_delimiter3() -> TestResult {
|
||||
fail_test(r#"{"#, "Unexpected end of code")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn register_with_string_literal() -> TestResult {
|
||||
fail_test(r#"register 'nu-plugin-math'"#, "File not found")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn register_with_string_constant() -> TestResult {
|
||||
let input = "\
|
||||
const file = 'nu-plugin-math'
|
||||
register $file
|
||||
";
|
||||
// should not fail with `not a constant`
|
||||
fail_test(input, "File not found")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn register_with_string_variable() -> TestResult {
|
||||
let input = "\
|
||||
let file = 'nu-plugin-math'
|
||||
register $file
|
||||
";
|
||||
fail_test(input, "Value is not a parse-time constant")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn register_with_non_string_constant() -> TestResult {
|
||||
let input = "\
|
||||
const file = 6
|
||||
register $file
|
||||
";
|
||||
fail_test(input, "expected string, found int")
|
||||
}
|
||||
|
Reference in New Issue
Block a user