78d1debcc09a70e5d588c503014fd41b17b66fd6
[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"),list("EOL"),..
31         tlist(["funcall","rhs","name","lhsnb"],[],"return",0),list("EOL")),5);
32
33 if ~and(macr2tree(bug_1304)==reftree) then pause;end
34
35 // Test with input which is not a variable reference
36 reftree.name = "ans";
37 if ~and(macr2tree(evstr("bug_1304"))==reftree) then pause;end
38
39 clear bug_1304
40
41 //
42 // TESTS WITH A FUNCTION DEFINING AN OTHER FUNCTION
43 //
44
45 function f = bug_1304()
46 function internal_bug_1304()
47 disp("internal_bug_1304()")
48 endfunction
49 f = internal_bug_1304
50 endfunction
51
52 // Reference tree generated using sci2exp
53 reftree = tlist(["program","name","outputs","inputs","statements","nblines"],"bug_1304",..
54         list(tlist(["variable","name"],"f")),list(),..
55         list(list("EOL"),..
56         tlist(["inline","prototype","definition"],"internal_bug_1304()",..
57         ["";"disp(""internal_bug_1304()"")";" "]),list("EOL"),..
58         tlist(["equal","expression","lhs","endsymbol"],..
59         tlist(["variable","name"],"internal_bug_1304"),list(tlist(["variable","name"],"f")),""),..
60         list("EOL"),list("EOL"),tlist(["funcall","rhs","name","lhsnb"],[],"return",0),list("EOL")),..
61         6);
62 if ~and(macr2tree(bug_1304)==reftree) then pause;end
63
64 // Test with input which is not a variable reference
65 reftree.name = "ans";
66 if ~and(macr2tree(evstr("bug_1304"))==reftree) then pause;end
67
68 // Reference tree generated using sci2exp
69 reftree = tlist(["program","name","outputs","inputs","statements","nblines"],"ans",..
70         list(),list(),..
71         list(list("EOL"),..
72         tlist(["equal","expression","lhs","endsymbol"],..
73         tlist(["funcall","rhs","name","lhsnb"],list(tlist(["cste","value"],"internal_bug_1304()")),..
74         "disp",1),list(tlist(["variable","name"],"ans")),""),list("EOL"),list("EOL"),..
75         tlist(["funcall","rhs","name","lhsnb"],[],"return",0),list("EOL")),5);
76
77 if ~and(macr2tree(bug_1304())==reftree) then pause;end