Skip to content

Commit 7d04b21

Browse files
committed
Add tests for shadowed functions in core Octave (bug #46849).
* test/load-path/refresh-load-path.tst: Add tests that check that warnings for shadowed core functions are emitted. * test/load-path/shadowed-builtin/quad.m, test/load-path/shadowed-corelib/plot.m: Add new test files. * test/load-path/module.mk: Add new files to build system.
1 parent 3b5d4ff commit 7d04b21

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

test/load-path/module.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
load_path_TEST_FILES = \
22
%reldir%/refresh-load-path.tst \
33
%reldir%/in-load-path/load_path_fcn.m \
4-
%reldir%/not-in-load-path/load_path_fcn.m
4+
%reldir%/not-in-load-path/load_path_fcn.m \
5+
%reldir%/shadowed-builtin/var.m \
6+
%reldir%/shadowed-corelib/plot.m
57

68
TEST_FILES += $(load_path_TEST_FILES)

test/load-path/refresh-load-path.tst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@
3636
%! path (path_orig);
3737
%! cd (pwd_orig);
3838
%! end_unwind_protect
39+
40+
%!warning <shadows a built-in function>
41+
%! path_orig = path ();
42+
%! unwind_protect
43+
%! addpath (fullfile (pwd (), "shadowed-builtin"));
44+
%! unwind_protect_cleanup
45+
%! path (path_orig);
46+
%! end_unwind_protect
47+
48+
## The following test only works after Octave has been installed and
49+
## __pathorig__ is non-empty.
50+
## %!warning <shadows a core library function>
51+
## %! path_orig = path ();
52+
## %! unwind_protect
53+
## %! addpath (fullfile (pwd_orig, "shadowed-corelib"));
54+
## %! unwind_protect_cleanup
55+
## %! path (path_orig);
56+
## %! end_unwind_protect
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## function which shadows a built-in function with the same name
2+
function var ()
3+
endfunction
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## function which shadows a function with the same name in Octave's core library
2+
function plot ()
3+
endfunction

0 commit comments

Comments
 (0)