summaryrefslogtreecommitdiffstats
path: root/tests/nonRegression/bug1662.sci
blob: db30f7b5a245baf33cb2cf3258168b42ec779dfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// <-- Non-regression test for bug 1662 -->
//
// <-- Bugzilla URL -->
// http://www.scilab.org/cgi-bin/bugzilla_bug_II/show_bug.cgi?id=1662
//
// <-- Short Description -->
//    when converting Matlab switch case statements to Scilab select case 
//    statements using m2sci_syntax , if there is a comment line between the 
//    switch and case statement in the m file, the sytnax is rejected with an 
//    incorrect syntax error. Take the comment out and it works fine. Not a 
//    major problem but a slight nuisance

// Copyright INRIA
// Scilab Project - F. Belahcene


MFILECONTENTS=["function  y=bug1662(x)";
		"switch x % comment1";
		"% comment2";
		"case x>0 then y=''positive''";
		"case x<0 then y=''negative''";
		"else y=''null''";
		"end"]

MFILE=TMPDIR+"/bug1662.m"
SCIFILE=TMPDIR+"/bug1662.sci"

mputl(MFILECONTENTS,MFILE);
mfile2sci(MFILE,TMPDIR,%f,%t);
SCIFILECONTENTS=mgetl(SCIFILE);

SCIFILECONTENTSREF=["function [y] = bug1662(x)";
		""
		"// Ouput variables initialisation (not found in input variables)";
		"y=[];";
		""
		"// Display mode";
		"mode(0);";
		""
		"// Display warning for floating point exception";
		"ieee(1);";
		""
		"select x // comment1";
		" // comment2";
		"  case mtlb_logic(x,"">"",0) then y = ""positive""";
		"  case mtlb_logic(x,""<"",0) then y = ""negative""";
		"  else y = ""null""";
		"end;";
		"endfunction"]


if or(SCIFILECONTENTSREF<>SCIFILECONTENTS) then
	affich_result(%F,1662);
else
	affich_result(%T,1662);
end