diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/function.err | 8 | ||||
-rw-r--r-- | tests/function.in | 13 | ||||
-rw-r--r-- | tests/function.out | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/tests/function.err b/tests/function.err index e69de29b..72671ac9 100644 --- a/tests/function.err +++ b/tests/function.err @@ -0,0 +1,8 @@ +function: function name shadows a builtin so you must use '--shadow-builtin' +fish: function pwd; end + ^ +yes, it failed as expected +function: function name does not shadow a builtin so you must not use '--shadow-builtin' +fish: function not_builtin --shadow-builtin; end + ^ +yes, it failed as expected diff --git a/tests/function.in b/tests/function.in index 747bbcec..8202fb13 100644 --- a/tests/function.in +++ b/tests/function.in @@ -44,3 +44,16 @@ for i in (seq 4) echo "Function name$i not found, but should have been" end end + +# Test that we can't define a function that shadows a builtin by accident. +function pwd; end +or echo 'yes, it failed as expected' >&2 + +# Test that we can define a function that shadows a builtin if we use the +# right flag. +function pwd --shadow-builtin; end +and echo '"function pwd --shadow-builtin" worked' + +# Using --shadow-builtin for a non-builtin function name also fails. +function not_builtin --shadow-builtin; end +or echo 'yes, it failed as expected' >&2 diff --git a/tests/function.out b/tests/function.out index 5a3da619..0d12479e 100644 --- a/tests/function.out +++ b/tests/function.out @@ -22,3 +22,4 @@ Function name1 found Function name2 found Function name3 found Function name4 found +"function pwd --shadow-builtin" worked |