diff test/bug-38576.tst @ 16360:11115c237231

recognize variables when parsing (bug #38576) * lex.h, lex.ll (lexical_feedback::mark_as_variable, lexical_feedback::maybe_mark_previous_token_as_variable, lexical_feedback::mark_as_variables, octave_lexer::is_variable): New fucntions. ("="): Call maybe_mark_previous_toke_as_variable. (handle_identifier): Don't tag variables as possible commands. (param_list): Mark names in list as variables. (octave_base_parser::validate_matrix_for_assignment): Likewise. * pt-arg-list.h, pt-arg-list.cc (tree_argument_list::variable_names): New function. * pt-misc.h, pt-misc.cc (tree_parameter_list::variable_names): New function. * token.h, token.cc (token::symbol_name, token::is_symbol): New functions. * test/bug-38576.tst: New file. * test/Makefile.am (FCN_FILES): Add bug-38576.tst to the list.
author John W. Eaton <jwe@octave.org>
date Sat, 23 Mar 2013 15:02:29 -0400
parents
children 730bc06134f9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-38576.tst	Sat Mar 23 15:02:29 2013 -0400
@@ -0,0 +1,16 @@
+%!function r = f1 ()
+%!  ls = svd (1);
+%!  r = eval ("ls -1;");
+%!endfunction
+%!function r = f2 ()
+%!  [u,ls,v] = svd (1);
+%!  r = eval ("ls -1;");
+%!endfunction
+%!function r = f3 (ls)
+%!  r = eval ("ls -1;");
+%!endfunction
+
+%!assert (f1 (), 0);
+%!assert (f2 (), 0);
+%!assert (ischar (f3 ()), true);
+%!assert (f3 (1), 0);