macr2tree fixed and test updated
[scilab.git] / scilab / modules / core / tests / nonreg_tests / bug_1304.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2010 - DIGITEO - Vincent COUVERT
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7
8 // <-- Non-regression test for bug 1304 -->
9 //
10 // <-- Bugzilla URL -->
11 // http://bugzilla.scilab.org/show_bug.cgi?id=1304
12 //
13 // <-- Short Description -->
14 // macr2tree(expression) doesn't work
15
16 //
17 // TESTS WITH A 'SIMPLE' FUNCTION
18 //
19
20 function bug_1304()
21     disp("bug_1304")
22 endfunction
23
24 // Reference tree generated using sci2exp
25 reftree = tlist(["program","name","outputs","inputs","statements","nblines"],"bug_1304",list(),..
26 list(),..
27 list(list("EOL"),..
28 tlist(["equal","expression","lhs","endsymbol"],..
29 tlist(["funcall","rhs","name","lhsnb"],list(tlist(["cste","value"],"bug_1304")),"disp",1),..
30 list(tlist(["variable","name"],"ans")),""),list("EOL"),..
31 tlist(["funcall","rhs","name","lhsnb"],[],"return",0),list("EOL")),3);
32
33 if ~and(macr2tree(bug_1304)==reftree) then pause;end
34 if ~and(macr2tree(evstr("bug_1304"))==reftree) then pause;end
35
36 clear bug_1304
37
38 //
39 // TESTS WITH A FUNCTION DEFINING AN OTHER FUNCTION
40 //
41
42 function f = bug_1304()
43     function internal_bug_1304()
44         disp("internal_bug_1304()")
45     endfunction
46     f = internal_bug_1304
47 endfunction
48
49 // Reference tree generated using sci2exp
50 reftree = tlist(["program","name","outputs","inputs","statements","nblines"],"bug_1304",..
51 list(tlist(["variable","name"],"f")),list(),..
52 list(list("EOL"),..
53 tlist(["inline","prototype","definition"],"internal_bug_1304()",..
54 ["disp(""internal_bug_1304()"")"]),list("EOL"),..
55 tlist(["equal","expression","lhs","endsymbol"],..
56 tlist(["variable","name"],"internal_bug_1304"),list(tlist(["variable","name"],"f")),""),..
57 list("EOL"),tlist(["funcall","rhs","name","lhsnb"],[],"return",0),list("EOL")),..
58 6);
59
60 if ~and(macr2tree(bug_1304)==reftree) then pause;end
61 if ~and(macr2tree(evstr("bug_1304"))==reftree) then pause;end
62
63 // Reference tree generated using sci2exp
64 reftree = tlist(["program","name","outputs","inputs","statements","nblines"],"internal_bug_1304",..
65 list(),list(),..
66 list(list("EOL"),..
67 tlist(["equal","expression","lhs","endsymbol"],..
68 tlist(["funcall","rhs","name","lhsnb"],list(tlist(["cste","value"],"internal_bug_1304()")),..
69 "disp",1),list(tlist(["variable","name"],"ans")),""),list("EOL"),..
70 tlist(["funcall","rhs","name","lhsnb"],[],"return",0),list("EOL")),3);
71
72 if ~and(macr2tree(bug_1304())==reftree) then pause;end